Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Question about create-items.rb  (Read 1489 times)

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Question about create-items.rb
« on: May 02, 2016, 12:00:56 pm »

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:

Code: [Select]
[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.

Code: [Select]
[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:

Code: [Select]
[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:
Code: [Select]
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!
« Last Edit: May 16, 2016, 12:46:08 am by Meph »
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 :::

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: Question about modtools/transform-unit
« Reply #1 on: May 02, 2016, 12:41:46 pm »

You need the modtools/ path before the command, then it should work except for ignoring gender.

You can get a reference to the worker as part of reaction-trigger, then have a Lua script figure out which transformation to use based on that unit's caste.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Roses

  • Bay Watcher
    • View Profile
Re: Question about modtools/transform-unit
« Reply #2 on: May 02, 2016, 02:36:14 pm »

Actually it should be

Code: [Select]
modtools/transform-unit -unit \\WORKER_ID -race DWARF -caste CARPENTER_MALE -keepInventory
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Question about modtools/transform-unit
« Reply #3 on: May 02, 2016, 03:49:28 pm »

So...
Code: [Select]
modtools/reaction-trigger -reactionName JOIN_GUILD_ALCHEMIST -command [ modtools/transform-unit -unit \\WORKER_ID -race DWARF -caste CARPENTER_MALE -keepInventory ]? EDIT: Yeah, that works.

But there seems to be no way to sort the genders out, except by writing a new script again.

Somehow I never understood why expwnent got rid of the old system. Yes, the new one is shorter, but why not keep it downwards compatible? *grumbles in my beard.

Sorry for being difficult. I spend all day looking at my 34.11 mod raws and at all the things I have to throw away/redo.

Edit: I temporarily solved it by copying the reactions and using one for male and one for female and then making two reaction categories in the building. The players have to do some micromanagement, but it works. :)
« Last Edit: May 02, 2016, 04:39:30 pm by Meph »
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 :::

Roses

  • Bay Watcher
    • View Profile
Re: Question about modtools/transform-unit
« Reply #4 on: May 02, 2016, 07:40:53 pm »

I actually have a transform-unit like script that I have been working on. It calls the modtools/transform-unit for the actually heavy lifting but has extra features. It isn't release ready yet, but gender preserving transformations are one of the things it does. Pretty much everything that was possible with the old system I have written for the new system. Most I simply haven't released because there was no interest. If there is something in particular you are looking for just ask.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Question about create-items.rb
« Reply #5 on: May 16, 2016, 12:46:21 am »

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. :)
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 :::

lethosor

  • Bay Watcher
    • View Profile
Re: Question about create-items.rb
« Reply #6 on: May 16, 2016, 07:56:53 pm »

What is createitem.lua?
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Question about create-items.rb
« Reply #7 on: May 16, 2016, 08:09:08 pm »

I'd guess modtools/create-item or the plugin createitem.

I think we should probably purge some of these.