EDIT: New question:
I want to create webs next to a workshop. createitem.lua doesnt allow webs (invalid item), but create-items.rb does. But as location it only accepts the df-cursor, nothing else.
How can I rewrite the ruby script to take location arguments? In in the end it should be triggered by a dwarf in a workshop using reaction-trigger; check the worker location, then spawn a web
next to the workshop. For this I'd need to tell it to change the x coordinate by +1 or -1, and for above/below the workshop, the y coordinate +1 or -1.
I would really appreciate the help.
Old Question, already answered: Hey guys,
tl;dr: How do I trigger transform-unit through a reaction? And how does it only target a specific caste of worker?
I tried porting my old guild-system to the new version, but I have issues with transforming units with the new dfhack syntax. All I found is this:
https://dfhack.readthedocs.io/en/stable/docs/_auto/modtools.html?highlight=transform#modtools-transform-unit which doesnt explain much.
The old version I used was this:
[REACTION:JOIN_GUILD_CARPENTER]
[NAME:Join the carpenters guild for 500 sovereigns]
[BUILDING:GUILDHALL:CUSTOM_C]
[REAGENT:A:500:COIN:NONE:INORGANIC:GOLD]
[PRODUCT:100:1:BOULDER:NONE:INORGANIC:GUILD_CARPENTER_M]
[PRODUCT:100:1:BOULDER:NONE:INORGANIC:GUILD_CARPENTER_F]
A reaction that creates a boulder that triggers reaction-trigger.
It created this inorganic, one for males and one for females.
[INORGANIC:GUILD_CARPENTER_M]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE]
[STATE_NAME_ADJ:ALL:Join the Carpenters Guild]
[SYNDROME][SYN_CLASS:\AUTO_SYNDROME][SYN_CLASS:\COMMAND][MELTING_POINT:9000][BOILING_POINT:905][SOLID_DENSITY:55520]
[SYN_AFFECTED_CREATURE:DWARF:MALE]
[SYN_AFFECTED_CREATURE:DWARF:MERCHANT_MALE]
[SYN_AFFECTED_CREATURE:DWARF:MASON_MALE]
[SYN_AFFECTED_CREATURE:DWARF:BEAST_WARDEN_MALE]
[SYN_AFFECTED_CREATURE:DWARF:SMITH_MALE]
[SYN_AFFECTED_CREATURE:DWARF:JEWELER_MALE]
[SYN_AFFECTED_CREATURE:DWARF:CRAFTDWARF_MALE]
[SYN_AFFECTED_CREATURE:DWARF:FISHERMAN_MALE]
[SYN_AFFECTED_CREATURE:DWARF:FARMER_MALE]
[SYN_AFFECTED_CREATURE:DWARF:HEALER_MALE]
[SYN_AFFECTED_CREATURE:DWARF:ENGINEER_MALE]
[SYN_AFFECTED_CREATURE:DWARF:ALCHEMIST_MALE]
[SYN_AFFECTED_CREATURE:DWARF:LEGIONNAIRE_MALE]
[SYN_AFFECTED_CREATURE:DWARF:MARKSMAN_MALE]
[SYN_AFFECTED_CREATURE:DWARF:GUARD_MALE]
[SYN_AFFECTED_CREATURE:DWARF:WRESTLER_MALE]
[CE_CAN_DO_INTERACTION:START:0:END:299]
[CDI:INTERACTION:TRANSFORM_GUILD_CARPENTER_M]
[CDI:TARGET:A:SELF_ONLY]
[CDI:ADV_NAME:joins the guild]
[CDI:TARGET_RANGE:A:1]
[CDI:MAX_TARGET_NUMBER:A:1]
[CDI:WAIT_PERIOD:300]
And the interaction used with the commands for dfhack were these:
[INTERACTION:TRANSFORM_GUILD_CARPENTER_M]
[I_TARGET:A:CREATURE]
[IT_LOCATION:CONTEXT_CREATURE] [IT_CANNOT_HAVE_SYNDROME_CLASS:NO_TRANSFORM]
[IT_MANUAL_INPUT:self]
[I_EFFECT:ADD_SYNDROME]
[IE_TARGET:A]
[IE_IMMEDIATE]
[SYNDROME]
[CE_BODY_TRANSFORMATION:PROB:100:START:0:END:8400]
[CE:CREATURE:GUILD:INTERMEDIATE]
[SYN_CLASS:\PERMANENT]
[SYN_CLASS:DWARF]
[SYN_CLASS:CARPENTER_MALE]
In short: truetransform \permanent dwarf carpenter_male.
Now I try to figure out how to do this with modtools/transform-unit. I put this in the Onload.init:
modtools/reaction-trigger -reactionName JOIN_GUILD_ALCHEMIST -command [ transform-unit \\WORKER_ID DWARF CARPENTER_MALE]
But only gets an error message about "transform-unit is not a recognized command".
And in addition to that: How can the new system figure out if the worker is male or female? Obviously I want to transform male dwarves into male guild members, female dwarves into female guild members. In the old system I used the syndromes that only affect male or female castes.
Thanks!