Skip to content

item-trigger update: specify inventory mode#49

Merged
lethosor merged 2 commits intoDFHack:masterfrom
AtomicChicken:item-trigger-update
Mar 27, 2018
Merged

item-trigger update: specify inventory mode#49
lethosor merged 2 commits intoDFHack:masterfrom
AtomicChicken:item-trigger-update

Conversation

@AtomicChicken
Copy link
Copy Markdown
Member

Previously, item-trigger's inventory update checks only differentiated between equipping and unequipping items. This means that something like
modtools/item-trigger -itemType ITEM_HELM_CAP -onEquip -command [ foo ]
would trigger foo both in cases where a cap was being worn, and in cases where it was simply being held in the unit’s hand.

With this update, the user will now be able to specify the inventory mode alongside onEquip and onUnequip to allow for greater selectivity. Taking the above example, if we wanted to trigger foo only in cases where a cap was being worn, we could specify this via
modtools/item-trigger -itemType ITEM_HELM_CAP -onEquip 2 -command [ foo ]
or
modtools/item-trigger -itemType ITEM_HELM_CAP -onEquip [ 2 ] -command [ foo ]
where ‘2’ is the mode type corresponding to ‘Worn’.

Multiple inventory modes can be specified. For example,
modtools/item-trigger -itemType RING -onUnequip [ 0 1 2 ] -command [ foo ]
would trigger foo when a ring is unequipped in cases where it was being hauled, held or worn.

A list of inventory mode values has been included in the -help printout.
Specifying mode remains optional, preserving backwards compatibility.

Previously, item-trigger's inventory update checks only differentiated between equipping and unequipping items. This means that something like
modtools/item-trigger -itemType ITEM_HELM_CAP -onEquip -command [ foo ]
would trigger foo both in cases where a cap was being worn, and in cases where it was simply being held in the unit’s hand.

With this update, the user will now be able to specify the inventory mode alongside onEquip and onUnequip to allow for greater selectivity. Taking the above example, if we wanted to trigger foo only in cases were a cap was being worn, we could specify this via
modtools/item-trigger -itemType ITEM_HELM_CAP -onEquip 2 -command [ foo ]
or
modtools/item-trigger -itemType ITEM_HELM_CAP -onEquip [ 2 ] -command [ foo ]
where ‘2’ is the mode type corresponding to ‘Worn’.

Multiple inventory mode can be specified. For example, 
modtools/item-trigger -itemType RING -onUnequip [ 0 1 2 ] -command [ foo ]
would trigger foo when a ring in unequipped in cases were it was being hauled, held or worn.

A list of inventory mode values has been included in the -help printout.
Specifying mode remains optional, preserving backwards compatibility.
utils.fillTable(command,table)
processTrigger(command)
utils.unfillTable(command,table)
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tab -> 4 spaces

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, now how did that get in there?

-onUnequip
Optionally, the equipment mode can be specified
Possible values for mode:
0 = Hauled
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a DF enum? If so, you should use human-readable names instead of making people look up numbers every time they want to want to read/write a command.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second glance, it looks like you just documented this. Not a big deal, then, but it would be nice to be able to use enum values (if this is in fact an enum).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. I suppose it'd cause far less hassle to everyone involved.

table.item = df.item.find(item)
table.unit = df.unit.find(unit)
if table.item and table.unit then -- they must both be not nil or errors will occur after this point with instant reactions.
if table.item and table.unit then--they must both be not nil or errors will occur after this point with instant reactions.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces around comments make them more readable. No need to remove them.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, not sure why I did that.

… + other minor corrections

as per lethosor's feedback
@lethosor lethosor merged commit 9f2231b into DFHack:master Mar 27, 2018
@AtomicChicken AtomicChicken deleted the item-trigger-update branch March 27, 2018 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants