Denizen/Triggers: Difference between revisions
< Denizen
(Created page with "Triggers are what allow NPCs to react to player actions such as chatting to the NPC, clicking the NPC, attacking the NPC, or just walking near the NPC. = How To Make A trigg...") |
No edit summary |
||
Line 6: | Line 6: | ||
First, you must enable the trigger: | First, you must enable the trigger: | ||
You can enable them just by running the command [http://wiki.citizensnpcs. | You can enable them just by running the command [http://wiki.citizensnpcs.co/Denizen/Commands#trigger - Trigger] | ||
<pre>- trigger [name:chat/click/damage/proximity] (state:true/false) (cooldown:<#.#>) (radius:<#>)</pre> | <pre>- trigger [name:chat/click/damage/proximity] (state:true/false) (cooldown:<#.#>) (radius:<#>)</pre> | ||
This is usually done in the [http://wiki.citizensnpcs. | This is usually done in the [http://wiki.citizensnpcs.co/Denizen/Types_of_Scripts#Assignment_Script assignment script - on assignment], but it can be done anywhere else as well. | ||
Then you must make an [http://wiki.citizensnpcs. | Then you must make an [http://wiki.citizensnpcs.co/Denizen/Types_of_Scripts#Interact_Scripts Interact Script] and include the trigger to react however. | ||
You can also use Assignment script actions "on click", "on enter proximity", and "on exit proximity". | You can also use Assignment script actions "on click", "on enter proximity", and "on exit proximity". |
Revision as of 14:08, 1 October 2013
Triggers are what allow NPCs to react to player actions such as chatting to the NPC, clicking the NPC, attacking the NPC, or just walking near the NPC.
How To Make A trigger
First, you must enable the trigger:
You can enable them just by running the command - Trigger
- trigger [name:chat/click/damage/proximity] (state:true/false) (cooldown:<#.#>) (radius:<#>)
This is usually done in the assignment script - on assignment, but it can be done anywhere else as well.
Then you must make an Interact Script and include the trigger to react however.
You can also use Assignment script actions "on click", "on enter proximity", and "on exit proximity".
Chat Trigger
A Chat trigger is written like so:
chat Trigger: '1': Trigger: "/Hello/ there npc!" Script: - CHAT "Hello, <player.name>!" '2': Trigger: "/Bye/ npc!" Script: - CHAT "Goodbye, <player.name>!" '3': Trigger: /REGEX:.+/ Script: - CHAT "I don't know what <player.chat_history> is!"
Any message that contains the /Message/ will activate that part of the trigger.
You can also include any RegEx by prefixing it with REGEX:
Click Trigger
click Trigger: Script: - CHAT "Hehe, that tickles!"
Click triggers happen when a player right-clicks an NPC.
Damage Trigger
Damage Trigger: Script: - CHAT "Ow! That hurt, <player.name>!"
Click triggers happen when a player right-clicks an NPC.
Proximity Trigger
Proximity Trigger: enter: Script: - CHAT "Hello there, <player.name>! exit: Script: - CHAT "Goodbye, <player.name>!"
Proximity triggers fire when a player enters or leaves the radius defined by the - trigger command.