Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DFHack LUA Reference  (Read 1345 times)

Novaris

  • Bay Watcher
    • View Profile
DFHack LUA Reference
« on: January 08, 2020, 11:14:09 am »

Is there a quick reference for LUA & DFHack?

I'm not familiar with LUA itself but with a few other languages and I want to create a little script that I can hook up to the repeat command and have it run once a day that reduces a specific field in the current soul of every dwarf in my fort by 5% until it reaches 0 and caps there and I figure LUA would be the best approach to accomplish this.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack LUA Reference
« Reply #1 on: January 08, 2020, 02:34:23 pm »

This document is the one documenting DFHack from a Lua perspective https://dfhack.readthedocs.io/en/latest/docs/Lua%20API.html#enabling-and-disabling-scripts (the operation for setting up a callback timeout is dfhack.timeout, with "callback" being the function that's called).
Once the callback is called, it will have to set up itself for being called again if you want the timeout to be periodic.

gui/gm-editor is the tool to use to look at structures inside of DF to find the data you want to change in you script.
Logged