General question about dfhack: what's its inner timing in regards to the game's engine inner timing?
- At what point of the game loop does DFhack read and update its properties?
- Or, if all the properties are direct access to actual value in memory, then at what stage in the game loop do dfhack scripts get executed?
They've been direct access since DFHack moved to being in-process. I don't remember when exactly this was, but it was probably around 2009-2010.
Like Japa said, SDL_GetNumJoysticks() is called once per game tick (corresponding to the "FPS" indicator), on the simulation thread, and DFHack hooks into that to run anything that needs to access DF data. This includes most plugin commands and all scripts.
- what is the liberty of the scripter to move its script execution earlier or later in the game loop?
Impossible, and I don't know why you would want to. Is there something specific you're trying to do? If so, there's probably already a way to do it that doesn't require hooking into the game loop at different points.
(Is the timing different with DFHack plugins? Are there several native game events that can trigger a script execution from DFhack or do they always play at the same stage in the game loop?)
Plugins have access to C++ features and can do whatever they want - they can spin off separate threads, for example, and run things whenever they want. However, the whole point of the per-tick hook is that it's
safe to access game data at that point, because DF's simulation thread isn't doing anything else.
Plugins can intercept virtual method calls, which is usually safe. Scripts can't do that. In theory, a plugin could call a Lua script from an interposed vmethod (with some limitations, like being unable to make screens, I think).
- can you do a very rough presentation of the order of computations that take place inside a native game loop?
Nope. Disassembly could reveal some stuff, but it would take a lot of effort.
Again, is there something specific you're looking for? These questions seem like they have a purpose that isn't specified.