Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Talking about powered workshops  (Read 5054 times)

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Talking about powered workshops
« Reply #15 on: February 04, 2014, 02:31:14 am »

Thanks :)

One more problem for today... Kind of a really weird one.
Basically I'm trying to check if there are powered or unpowered machine components adjacent to a building.  The gear positions are fine, the buildings being checked are correct, but for some reason the check for whether the machine is active or not doesn't work right.  Instead, it seems to always respond with whatever state the machine was in when the building was built - even though it's checking the building again from the start.  Is this something weird about how the dfhack.buildings.findAtTile function works?  Maybe it tries to speed up the function by returning the same building data if the same position is called twice, but botches things whenever machines are concerned?


Never mind, it was simply not updating properly.

What would you say is the best way of determining when the state of a machine changes?  Buildings being created or destroyed can be listened for with eventful, but what about for when the power level of a machine changes, or when a gear assembly is engaged or disengaged?
interpose the setTriggerState(x) vmethod. This way it will only drain cpu cycles when it's triggered (as opposed to checking every nth ticks) and will trigger instantly when it changes (and for each change). Though it's a bit more complicated method and needs to be in c++ side.

IndigoFenix

  • Bay Watcher
  • All things die, but nothing dies forever.
    • View Profile
    • Boundworlds: A Browser-Based Multiverse Creation and Exploration Game
Re: Talking about powered workshops
« Reply #16 on: February 05, 2014, 11:08:11 am »

I found another way - storing machine data from the previous frame in a parallel array, then checking them against each other every frame.  If the number of machines or the order of their id changes, then I know a gear assembly was engaged or disengaged and run a full re-check on all custom machines to determine what machine they are attached to.  If the power levels change, then the custom machines just have to readjust their power levels accordingly.  Parallel array checking is quick, so even checking every frame the slowdown is basically negligible.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Talking about powered workshops
« Reply #17 on: February 05, 2014, 11:37:31 am »

still more complicated and error prone.

Xyon

  • Bay Watcher
    • View Profile
Re: Talking about powered workshops
« Reply #18 on: April 13, 2017, 04:55:32 pm »

Hope the necro isnt a bother.  I'm wondering if any progress has been made towards figuring out how to use RAWs to make workshops that require/use power.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Talking about powered workshops
« Reply #19 on: April 14, 2017, 02:59:17 am »

Hope the necro isnt a bother.  I'm wondering if any progress has been made towards figuring out how to use RAWs to make workshops that require/use power.
"Figuring out" is wrong imho. There is no system dedicated for that. On the other hand you can use Lua to have complicated powered workshops (or simple too).

E.g. bone grinder, which only works when power is supplied;
Lua api docs See the auto-gears version. In that version you need to have "gears" tile on the building.

Xyon

  • Bay Watcher
    • View Profile
Re: Talking about powered workshops
« Reply #20 on: April 14, 2017, 06:40:46 am »

Hope the necro isnt a bother.  I'm wondering if any progress has been made towards figuring out how to use RAWs to make workshops that require/use power.
"Figuring out" is wrong imho. There is no system dedicated for that. On the other hand you can use Lua to have complicated powered workshops (or simple too).

E.g. bone grinder, which only works when power is supplied;
Lua api docs See the auto-gears version. In that version you need to have "gears" tile on the building.

Mhmm,  I've never used Lua before, I guess its something I'll need to get into to figure this stuff out.

Just another question though, would all-new reactions need to be made for the powered workshops, like say you are making a duplicate of the carpenter workshop, but powered so that it can do all the same reactions faster, similar to how the quern and millstone do the same stuff, just that the millstone is faster?

Does the speed of the reaction need to be coded in the raws of the reaction or is it something that could be scriped to the workshop in lua?
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Talking about powered workshops
« Reply #21 on: April 14, 2017, 02:27:54 pm »

Hope the necro isnt a bother.  I'm wondering if any progress has been made towards figuring out how to use RAWs to make workshops that require/use power.
"Figuring out" is wrong imho. There is no system dedicated for that. On the other hand you can use Lua to have complicated powered workshops (or simple too).

E.g. bone grinder, which only works when power is supplied;
Lua api docs See the auto-gears version. In that version you need to have "gears" tile on the building.

Mhmm,  I've never used Lua before, I guess its something I'll need to get into to figure this stuff out.

Just another question though, would all-new reactions need to be made for the powered workshops, like say you are making a duplicate of the carpenter workshop, but powered so that it can do all the same reactions faster, similar to how the quern and millstone do the same stuff, just that the millstone is faster?

Does the speed of the reaction need to be coded in the raws of the reaction or is it something that could be scriped to the workshop in lua?
Making reactions work faster AFAIK is not simple (or to be frank, i don't know how to do it). One idea that comes to mind is either have better efficiency (less mass loss) or use more (e.g. 3 wood) and produce more thus being overall faster.

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Talking about powered workshops
« Reply #22 on: April 18, 2017, 10:33:16 am »

If you want to see powered workshops in action you can download Rubble.

It comes with addons (in the "User/Powered" group) containing more examples of powered workshops in action than any other mod. Also Rubble has some super-powerful APIs for making powered workshops in a trivial manner (you need to use Lua, but you don't really need to understand it).
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS
Pages: 1 [2]