Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Invasion of the Reaction-Raw-Tokens  (Read 2000 times)

Bogus

  • Bay Watcher
    • View Profile
Invasion of the Reaction-Raw-Tokens
« on: October 01, 2015, 04:39:07 pm »

while i was working on my project the idea for this little script came to my mind. i noticed that reagents used in reactions can have many more flags and settings than you can control with raw files. so what this script does is it allows you to use additional tokens in reaction raws, one for each flag that a reagent can have.

for example [MELT_DESIGNATED] and [ALLOW_MELT_DUMP]. or [MILK] and [PROCESSABLE_TO_VIAL]. possibly even [DEEP_MATERIAL], [EXTRACT_BEARING_FISH] or [MURDERED]. there are many others.

i have little to no idea what most of the flags will do, if anything. some sound more useful than others, some might even do something that cant be done right now. what exactly will happen if you use a [MILKABLE][TAMEABLE_VERMIN] reagent in your reaction is for you to find out!

how does it work: you need to run this script before loading a world, that means, at start of game. it will then whenever a world is loaded read all the reaction raws from the save folder. whenever it finds a token that is in the list, it sets the corresponding flag in the reaction struct in game.

i didnt figure out yet how auto-loading script works maybe you can tell me. presumably you have to write the name of the script into your dfhack-init?

disclaimer: i didnt test this beyond making sure it does what it does. i am in no way responsible for any financial, physical, mental and/or spiritual damages that result from the usage of this script. it is also very much an alpha version.


flags that dont have a name but just a number need to be tokenized as [number:number], where the first number stands for number of the bitfield the flag belongs to (0 for the field thats just named "flags"). the second number is the flag obviously. al flags are boolean values.

to write a reaction from memory into a file, use <scriptname>.reactionToRaw(), which will return a table of strings which can then be written into a file in the order provided. takes the reaction struct as its only argument. this will also write non-standard tokens.

code:
Spoiler (click to show/hide)
« Last Edit: November 04, 2015, 12:50:25 pm by Bogus »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Invasion of the Reaction-Raw-Tokens
« Reply #1 on: October 01, 2015, 05:23:39 pm »

Ok, stuff that's awesome:

FURNITURE  => for custom engraving/decorations of furniture. Saves a ton of time and space making copy+paste reactions for every single piece.

ALLOW_BURYABLE => This could be for civ-member corpses. Nice for a morgue or funeral rites/preparation.

ANY_TOOTH_MATERIAL and ANY_HORN_MATERIAL  are interesting, because they seemed to be interchangeable so far.

MELT_DESIGNATED is nice for custom melting of items.

The rest seems either useless or already accessable as token.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

expwnent

  • Bay Watcher
    • View Profile
Re: Invasion of the Reaction-Raw-Tokens
« Reply #2 on: October 03, 2015, 04:42:45 pm »

raw/onLoad.init would be a good place for initialization. It would have to re-run every time you load the game but that's perfectly fine.

Interesting concept. Anything more advanced would require shenanigans because DFHack can't intercept the part of DF's code which makes jobs look for appropriate items so if you want something really advanced you would get lag, job cancellation spam, or excessive manual user input.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: Invasion of the Reaction-Raw-Tokens
« Reply #3 on: October 07, 2015, 10:32:08 am »

I set MELT_DESIGNATED on the reaction for my custom item melting system, if I remember correctly there is another flag that is set too, but I forget what it does...

OK, a quick look at the code shows I set "flags2.allow_melt_dump" as well. I have no idea what it does, but I set it because... I don't remember, but I had a good reason at the time :p

Some of the other flags could be very useful. How does DF react to finding "undefined" tags in the raws?
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Bogus

  • Bay Watcher
    • View Profile
Re: Invasion of the Reaction-Raw-Tokens
« Reply #4 on: October 07, 2015, 10:45:53 am »

no at all afaik, or more specifically, it will likely report an undefined token into errorlog.txt and just process the rest of the reaction as normal.
Logged

Bogus

  • Bay Watcher
    • View Profile
Re: Invasion of the Reaction-Raw-Tokens
« Reply #5 on: November 04, 2015, 05:54:18 am »

added a function to translate reactions from df memory into raw code, outputs them as a sorted table containing strings which you can then write into a file as is.

if at any time you want to create a reaction during run time and want it to not break your savegame, this is what you want to do.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Invasion of the Reaction-Raw-Tokens
« Reply #6 on: November 04, 2015, 11:36:11 am »

There  also a way to inject raws. It requires reloading save but otherwise works quite well. See devel/inject-raws.lua

Button

  • Bay Watcher
  • Plants Specialist
    • View Profile
Re: Invasion of the Reaction-Raw-Tokens
« Reply #7 on: December 01, 2015, 12:05:35 pm »

PTW.
Logged
I used to work on Modest Mod and Plant Fixes.

Always assume I'm not seriously back