item-trigger: support multiple conditions#50
item-trigger: support multiple conditions#50lethosor merged 4 commits intoDFHack:masterfrom AtomicChicken:item-trigger-updates
Conversation
A significant rewrite allowing the user to specify any combination of itemType, material and contaminant. Previously, only one of the above could be used at a time, which greatly restricted the script's flexibility and limited its usefulness to modders. Also fixed the outdated(?) creature/plant material token format demonstrated in the -help printout, and added a few more examples.
modtools/item-trigger.lua
Outdated
| function checkMode(triggerArgs,table) | ||
| local mode = table.mode | ||
| for _,argArray in ipairs(triggerArgs) do | ||
| if argArray[""..mode..""] then |
There was a problem hiding this comment.
tostring(mode) or ""..mode should work
| INORGANIC:IRON | ||
| CREATURE_MAT:DWARF:BRAIN | ||
| PLANT_MAT:MUSHROOM_HELMET_PLUMP:DRINK | ||
| CREATURE:DWARF:BRAIN |
There was a problem hiding this comment.
Not familiar with this script... does this break backwards compatibility?
There was a problem hiding this comment.
I suppose so? The issue is that dfhack.matinfo.decode(item):getToken() returns strings in the format displayed above, which is incongruous with the format previously documented in this script's -help printout. Specifying something like "-material CREATURE_MAT:DWARF:BRAIN" shouldn't have worked at all in recent versions (tested it as far back as 0.43.05 to check), and the fact that this has gone unreported for so long indicates that the script probably hasn't seen much use in this regard.
There was a problem hiding this comment.
Oh, I missed that part in the PR description, and thought you had actually changed the format here. I really don't know much about the modtools scripts, so thanks for putting in the time to work on them.
replaced ""..mode.."" with tostring(mode), as per lethosor's feedback.
A significant rewrite allowing the user to specify any combination of itemType, material and contaminant.
Previously, only one of the above could be used at a time, which greatly restricted the script's flexibility and limited its usefulness to modders.
Also fixed the outdated(?) creature/plant material token format demonstrated in the -help printout, and added a few more examples.