Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Automatic manager orders to fill production mandates?  (Read 611 times)

Trabber Shir

  • Bay Watcher
    • View Profile
Automatic manager orders to fill production mandates?
« on: November 13, 2022, 07:55:23 pm »

I thought I had found a script for this years ago, but can not find one now, so I went looking for a way to do it myself and the only solution I can find leaves a bad taste in my mouth.

Is there any way to get the data about a production order in lua without parsing it from the human readable string that gets sent to announcements?

My current best option seems to be using ancc-monitor.lua as a starting point and then invoking workorder.lua to make an order with parsed data from any announcements of type announcement_type::NEW_MANDATE assuming it matches some regular expression.

There has to be a cleaner way? I am okay with hooking up to the plugins.eventful.REPORT event to know when a mandate has been issued, but I would prefer to get the mandate type and amount without string parsing.

I could probably write C++ to parse world->mandates and expose that to LUA, but then I would have to get the DFHack build running locally where the closest thing I have to a dev environment is Notepad++ and learn how to navigate the df namespace at a minimum (I can't find the definition of df::mandate or the possible values of T_mode currently, just the usages in Items.cpp). All told the C++ approach is too much work right now so I am hoping someone can give me a better option on the LUA side.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Automatic manager orders to fill production mandates?
« Reply #1 on: November 16, 2022, 03:12:49 am »

You could probably just read world->mandates with Lua directly (via df.global.world.mandates)?

Trabber Shir

  • Bay Watcher
    • View Profile
Re: Automatic manager orders to fill production mandates?
« Reply #2 on: November 16, 2022, 05:11:31 pm »

Thank you. That looks like exactly what I need.

Where do I find documentation for the df namespace?
Logged

Trabber Shir

  • Bay Watcher
    • View Profile
Re: Automatic manager orders to fill production mandates?
« Reply #3 on: November 16, 2022, 06:08:40 pm »

I think I just discovered the documentation (as far as it exists).

/library/xml/df.world.xml (https://github.com/DFHack/df-structures/blob/7513311fc4f490bd7510fe79f6834731ea1581c8/df.world.xml is the schema with a few helpful comments and the in game viewer from gm-editor can make it easier to understand and parse with an actice world
Code: [Select]
gui/gm-editor df.global.world
Logged