dfhack
dfhack copied to clipboard
Add graphics support for building-hacks
This intends to reenable building-hacks namely machine workshops with animations.
Things to consider:
- [x] general "is this useful to anyone else"?
- [x] doc update not done yet
- [x] (?) redo the api as it sucks. Lua part simplifies the api a little...
- [x] how do you get tile ids (ala raws) in lua (i.e. how to make the api work?)
- [x] getImpassableOccupancy fix still needed?
- [x] canBeRoomSubset thingy for interesting room manipulations, but not sure about usecases
- [x] not very kosher use of random reference for machine power tracking...
- [x] updateAction - probably could be removed and replaced with a lua on tick update or sth...
Edit: less theoretical musings, more "works for now" logic.
- ~make stuff automagically work from raws~ moved to a lua only module (different pull req later)
Can the plugin automatically enable itself if it detects that it is used in the raws, the same way that add-spatter
does? That way the player won't have to manually enable it to get things working.
- [ ] general "is this useful to anyone else"?
as useful as add-spatter
, which I'm also happy to include
- [ ] how do you get tile ids (ala raws) in lua (i.e. how to make the api work?)
it depends which tile ids you're getting. will it be a vanilla texpos or one added by DFHack?
Can the plugin automatically enable itself if it detects that it is used in the raws, the same way that
add-spatter
does? That way the player won't have to manually enable it to get things working.
It depends: for basic functionality it should be possible. It can be split in a few different things that this plugin does:
- Impassable fix - this might be already in df? Need to check. Basically fixes that workshop impassible tiles would allow water through.
- Generate power - unlikely that it's useful. Usually need some sort of "when fuel exists/etc" and probably used from lua
- Consume power - probably useful straight from raws, but it needs an argument (i.e. how much power do you need)
- animation - have no idea how to do it from raws
- canBeRoomSubset - ugh...
- [ ] how do you get tile ids (ala raws) in lua (i.e. how to make the api work?)
it depends which tile ids you're getting. will it be a vanilla texpos or one added by DFHack?
It's vanilla texpos but e.g. you do:
graphics_dragon_engine
[OBJECT:GRAPHICS]
[TILE_GRAPHICS:DRAGON_ENGINE_TILES:0:0:WORKSHOP_CUSTOM:DRAGON_ENGINE_N:3:0:0]
[TILE_GRAPHICS:DRAGON_ENGINE_TILES:0:1:WORKSHOP_CUSTOM:DRAGON_ENGINE_N:3:0:1]
[TILE_GRAPHICS:DRAGON_ENGINE_TILES:0:2:WORKSHOP_CUSTOM:DRAGON_ENGINE_N:3:0:2]
[TILE_GRAPHICS:DRAGON_ENGINE_TILES:0:3:WORKSHOP_CUSTOM:DRAGON_ENGINE_N:3:0:3]
[TILE_GRAPHICS:DRAGON_ENGINE_TILES:0:4:WORKSHOP_CUSTOM:DRAGON_ENGINE_N:3:0:4]
and then you need yet another tile for animated part. Or you need to do something similar in the lua part.
add_spatter
looks for SPATTER_ADD_
in any reaction. Could this look for a similar token prefix across the loaded building raws?
for looking up the graphics tile from a loaded page, I think you'd use dfhack.screen.findGraphicsTile(pagename,x,y)
that's slow, though, so you'd probably want to cache it and wipe your cache on a map load event.
So api is still terrible but less so. The rest of stuff doesn't matter that much, so i think i'll add (or at least try to add) automagical way of this loading stuff from raws and auto-enabling itself. In perfect case having a line [DFHACK_MACHINE:25]
would make any workshop to have power drain of 25 to work. This ofc is not perfect (e.g. how about interface, what if you want to provide power, etc...) but it would lower cost of entry for a lot of modders.
Another issue that plagues this module for many years: buildings need to built in specific order to connect to machines...
This is now relatively done. Needs more testing.
The "make it work from raws" is a separate project and probably lua only.
~Ok, this is as done as I currently can make it be.~ ~Spoke too soon. Some issue remains with 0 or 1 based building tile indexing?~ Ok NOW it's done 👯
how is this coming along? I'm looking forward to using dragon fire spitters in my base defense : )