Fair warning, this post is basically an incoherent mess of topics that I've been building up to posting. If you're just looking for one post to answer, skip to the last one, since that's really what I came for :b
Eventful's interaction event still seems to be broken (though I think it has been for some time)
The following doesn't seem to trigger in any mode (I'd done the testing in r2, but didn't notice anything in the changelogs about fixes to it, so I assume the same still applies to the current version):
eventful = require "plugins.eventful"
eventful.enableEvent(eventful.eventType.INTERACTION,1)
eventful.onInteraction.test = function()
print("An interaction happened!")
end
Just thought I'd bring it up in case for some reason it hasn't been already
While messing around with the action menu (
viewscreen_layer_unit_actionst) for a script, I noted down a few possibilities for currently unmapped values:
- anon_1 might be where reaction categories are stored, based on how the already mapped reactions entry works. Basically, the reactions entry is an indexed table the length of the number of options available in the "create" list of the menu. Each of the entries links to the reaction associated with the option at that position in the create list, however since reaction categories also appear in the create list, and aren't reactions, the entries at their position in the table are nil, rather than linking to a reaction. Since the information for what on the create list is actually a reaction category (rather than a reaction) has to be stored somewhere, and anon_1 happens to grow and shrink in size to match the number of options in the create list, it makes sense that that information is probably stored there (possibly following a similar format to reactions, but with options for reactions being nil).
- anon_8 might be options for natural abilities. As a creature with 3 natural abilities, it's the only option with a length of 3. With 2 abilities, it's length of 2.
- anon_15 might be related to the compose option. A unit that knows 1 form of poem has that at length 1. A unit that knows no forms has length 0.
- anon_11, anon_12, and anon_13 are in some way related to acquired powers. While they were previously all length 0, after learning a necromancer secret with 2 powers, anon_11 became 2 length, while anon_12 and anon_13 became 1 length.
On the topic of finding out what everyone's working on: in addition to checking github, we could also encourage scripters to make more use of the
What's going on in your modding? thread as a way of keeping people up to date. I for one will at least try to post more there when working on my own stuff.
I've been going crazy trying to figure out how, as a lua scripter, I'm supposed to make data persistent.
- There's the persistence module that got added/updated, but I'm not sure how that works. The documentation for dfhack.persistent hasn't changed at all since it was added, so does it just work the same as it always did? How does it work? As someone who's more of a scripter than a programmer, the explanation is a bit too confusing for me. Am I misunderstanding that entries seem to each be limited to a single string / 7 ints? If so how come? I thought that having json as the storage method would mean that it wouldn't need to be so limited (though that could just be because it's old documentation).
- There's persist-table, which hasn't been updated since the persistence module change, and notes that it is limited to only saving strings. Whereas just directly using the json library to save data wouldn't have that limitation (if I've read up on jf json correctly).
- Then there's just creating my own method for saving that uses the json library. How would I go about ensuring that I save the data at the right times? I vaguely know that with the persistence module, there was an event added to tell plugins to save before the world is unloaded. Is that event just for plugins, or is it also available to lua scripts, and if it is, how can I access it? If it's not available, is there anything better than this hack to reliably trigger saves during autosaves?