Modding:Right click events: Difference between revisions

From Vintage Story Wiki
(Add the footer and header to right click events page)
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
The system will attempt to start the interaction on the priority target. If the priority target rejects the interaction on the client side, then the system will attempt to start the interaction with the other target (held item / selected block). Which target has priority depends on whether the shift button is held, whether the held item has [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.CollectibleObject.html#Vintagestory_API_Common_CollectibleObject_HeldPriorityInteract <code>HeldPriorityInteract</code>] set, and whether the selected block has [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.Block.html#Vintagestory_API_Common_Block_PlacedPriorityInteract <code>PlacedPriorityInteract</code>] set. Whichever criteria is met first in the following list determines the priority target.
The system will attempt to start the interaction on the priority target. If the priority target rejects the interaction on the client side, then the system will attempt to start the interaction with the other target (held item / selected block). Which target has priority depends on whether the shift button is held, whether the held item has [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.CollectibleObject.html#Vintagestory_API_Common_CollectibleObject_HeldPriorityInteract <code>HeldPriorityInteract</code>] set, and whether the selected block has [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.Block.html#Vintagestory_API_Common_Block_PlacedPriorityInteract <code>PlacedPriorityInteract</code>] set. Whichever criteria is met first in the following list determines the priority target.


# No shift held -> selected block has priority
# Shift not held -> selected block has priority
# Shift held and '''HeldPriorityInteract''' set on item -> held item has priority
# Shift held and '''HeldPriorityInteract''' set on item -> held item has priority
# Shift held and '''PlacedPriorityInteract''' set on selected block -> selected block has priority
# Shift held and '''PlacedPriorityInteract''' set on selected block -> selected block has priority
Line 20: Line 20:


There are 3 ways to stop an interaction. Note that it is recommended to have the client stop the interaction, because stopping the interaction on the client also stops the interaction on the server. If the server stops the interaction, then it will continue on the client until the client stops it too.
There are 3 ways to stop an interaction. Note that it is recommended to have the client stop the interaction, because stopping the interaction on the client also stops the interaction on the server. If the server stops the interaction, then it will continue on the client until the client stops it too.
# OnXXInteractStart - reject it before it starts, by returning false for a block or setting the '''handling''' reference parameter to '''NotHandled''' for an item. The system will attempt to send the interaction to the other target (held item / selected block) if there is one.
# '''OnXXInteractStart''' - reject it before it starts, by returning false for a block or setting the '''handling''' reference parameter to '''NotHandled''' for an item. The system will attempt to send the interaction to the other target (held item / selected block) if there is one.
# OnXXInteractStep - return false to signal a block/item initiated stop. For example, this is used by the poultice item to indicate that the poultice has been successfully applied.
# '''OnXXInteractStep''' - return false to signal a block/item initiated stop. For example, this is used by the poultice item to indicate that the poultice has been successfully applied.
# OnXXInteractCancel - return true to accept a player initiated stop. Some of the ways the player can attempt to cancel the interaction are by releasing the mouse button or looking at another block.
# '''OnXXInteractCancel''' - return true to accept a player initiated stop. Some of the ways the player can attempt to cancel the interaction are by releasing the mouse button or looking at another block.


The interaction can be thought of as going through several phases, which are summarized below. The interaction advances to the next phase unless the table describes otherwise.
The interaction can be thought of as going through several phases, which are summarized below. The interaction advances to the next phase unless the table describes otherwise.
Confirmedusers
272

edits