Submitting first version of Enlinker to try to get feedback #349
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After a few weeks of posting mostly idiotic questions out on the DFHack Discord, I finally managed to implement what I had long since wanted in DF: an alternative logic system that allows the user to set a threshold (and optional delay) for building activation and de-activation, providing endless new exciting possibilities for dwarfputing in general, on one hand, but also massively simplifying relatively simple things such as e. g. opening and closing a fortress "door" made of both bridges and floodgates through a single lever. Given my chronic lack of inspiration for good names, I call this Enlinker, but I'm sure we could figure out something better...
Along the way, I decided it would be a good idea to store this information such that it would also work in Adventure Mode, so one could build e. g. a trap-filled maze for others to explore or an alternative entrance to a fortress that an adventurer could also use. This led me to develop some sort of system (still mostly experimental) that could load and save information based on the site-id, as suggested by the helpful folks over on the Discord.
The bulk of the logic is implemented in a C++ plugin that I will be also submitting to consideration through the main DFHack repo, but here I present the Lua code that implements the GUI that allows for user interaction.
Examples in Fortress Mode:
Building whose state is not managed by Enlinker:
Building whose state is managed by Enlinker:
Setting the building's state to depend on itself (this is bound to be useful at some point...):
Seeing a list of currently linked-to buildings and their weight in the input count:
Example in Adventure Mode:
Alternative view (all functionalities of Fortress Mode except adding new links - current links can be re-weighted, but no new buildings selected).