-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add graphics support for building-hacks #4380
base: develop
Are you sure you want to change the base?
Conversation
Can the plugin automatically enable itself if it detects that it is used in the raws, the same way that
as useful as
it depends which tile ids you're getting. will it be a vanilla texpos or one added by DFHack? |
It depends: for basic functionality it should be possible. It can be split in a few different things that this plugin does:
It's vanilla texpos but e.g. you do:
and then you need yet another tile for animated part. Or you need to do something similar in the lua part. |
for looking up the graphics tile from a loaded page, I think you'd use |
714c6ce
to
0c5c753
Compare
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 Another issue that plagues this module for many years: buildings need to built in specific order to connect to machines... |
0391bfc
to
a59a3d3
Compare
This is now relatively done. Needs more testing. The "make it work from raws" is a separate project and probably lua only. |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed docs and lifecycle code; will review business logic once some questions are answered.
- could you add a changelog entry for the update?
- could you update docs/plugins/building-hacks.rst and replace the "unavailable" tag with "fort gameplay buildings". Maybe "adventure fort gameplay buildings" if it's intended to work in adventure mode too.
- we need a full example of the RAWs and scripts for how to make this all work. It could be added to the modding guide as a case study. You could link to the modding guide from both the Lua API docs and buiding-hacks.rst.
docs/dev/Lua API.rst
Outdated
:make_graphics_too: replace same tiles in graphics mode with tiles from vanilla df mechanism | ||
:frame_skip: How many ticks to display one frame. If set to negative number (or skipped) frames | ||
are synchronized with machine animation. | ||
:gear_tiles: Optional array of 2 or 4 indexes. First two define ascii tiles and next two graphics tiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this for overriding the default gear graphics? If so, that should be communicated.
------ | ||
|
||
This module exports two events. However only one is documented here and is intended to be used directly. To use | ||
``onUpdateAction`` instead call ``setOnUpdate`` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does onUpdateAction exist as a Lua event, then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin lua part still uses that event (i.e. setOnUpdate
function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced this is sufficient reasoning. Why do you need a lua event to communicate with your own Lua layer? Why can't you call the Lua functions directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs changelog entry
I added some code examples in my comments to show what my understanding is of how these functions are to be used. If the examples are wrong, then I didn't understand something important.
|
||
:name: | ||
custom workshop id e.g. ``SOAPMAKER`` | ||
Set workshop to be included in zones (such as bedroom or inn). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be a good idea to always allow the building to be ownable? If in zone, and zone owned, then building owned?
plugin export a function it's recommended to use lua decorated function. | ||
This plugin extends DF workshops to support custom powered buildings. | ||
|
||
.. note:: when using numeric ids for workshops be aware that those id can change between worlds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. note:: when using numeric ids for workshops be aware that those id can change between worlds | |
.. note:: | |
When using numeric ids for workshop types, be aware that those ids can change | |
between worlds, depending on what other custom types exist in the raws for that | |
world. |
``registerBuilding(table)`` where table must contain name, as a workshop raw name, the rest are optional: | ||
* ``setOwnableBuilding(workshop_type)`` | ||
|
||
Set workshop to be included in zones (such as bedroom or inn). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set workshop to be included in zones (such as bedroom or inn). | |
Set workshop to be included in zones (such as a bedroom or tavern). |
|
||
Set workshop to be included in zones (such as bedroom or inn). | ||
|
||
:workshop_type: custom workshop string id e.g. ``SOAPMAKER`` or numeric id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:workshop_type: custom workshop string id e.g. ``SOAPMAKER`` or numeric id | |
:workshop_type: custom workshop string id, e.g. ``SOAPMAKER`` or numeric id |
|
||
Set workshop non walkable tiles to also block liquids (i.e. water and magma). | ||
|
||
:workshop_type: custom workshop string id e.g. ``SOAPMAKER`` or numeric id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:workshop_type: custom workshop string id e.g. ``SOAPMAKER`` or numeric id | |
:workshop_type: custom workshop string id, e.g. ``SOAPMAKER`` or numeric id |
|
||
``setPower(building,produced,consumed)`` sets current power production and consumption for a building. | ||
Returns two number - produced and consumed power if building can be modified and returns nothing otherwise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns two number - produced and consumed power if building can be modified and returns nothing otherwise. | |
If this building is of a type registered with building-hacks, returns values for | |
produced and consumed power. Otherwise, returns ``nil``. |
Sets current power production and consumption for a specific workshop building. Can be used to make buildings that | ||
dynamically change power consumption and production. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sets current power production and consumption for a specific workshop building. Can be used to make buildings that | |
dynamically change power consumption and production. | |
Dynamically sets current power production and consumption for a specific workshop | |
(which must be of a type registered with building-hacks). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I note that the order of consumed and produced power is in the opposite order compared to setPower
. They should match.
------ | ||
|
||
This module exports two events. However only one is documented here and is intended to be used directly. To use | ||
``onUpdateAction`` instead call ``setOnUpdate`` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced this is sufficient reasoning. Why do you need a lua event to communicate with your own Lua layer? Why can't you call the Lua functions directly?
This module exports two events. However only one is documented here and is intended to be used directly. To use | ||
``onUpdateAction`` instead call ``setOnUpdate`` function. | ||
|
||
* ``onSetTriggerState(workshop,state)`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* ``onSetTriggerState(workshop,state)`` | |
* ``onSetTriggerState(workshop, state)`` |
frames={ | ||
{{x=0,y=0,42,7,0,0}}, --first frame, 1 changed tile | ||
{{x=0,y=0,15,7,0,0}} -- second frame, same | ||
local bld=require('plugins.building-hacks') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
local bld=require('plugins.building-hacks') | |
local bhacks = require('plugins.building-hacks') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bld
is consistently used throughout DFHack to refer to "current building". using the name to refer to the module would be confusing
how is this coming along? I'm looking forward to using dragon fire spitters in my base defense : ) |
…ints and animation
Co-authored-by: Myk <myk.taylor@gmail.com>
313469b
to
135c802
Compare
This intends to reenable building-hacks namely machine workshops with animations.
Things to consider:
Edit: less theoretical musings, more "works for now" logic.
make stuff automagically work from rawsmoved to a lua only module (different pull req later)