Line 1: |
Line 1: |
− | {{upcoming|1.6}}
| |
− |
| |
| ← [[Modding:Index|Index]] | | ← [[Modding:Index|Index]] |
| | | |
Line 26: |
Line 24: |
| ! action | | ! action |
| ! effect | | ! effect |
| + | |- |
| + | | <samp>AddBuff {{t|buff ID}}</samp><br /><samp>RemoveBuff {{t|buff ID}}</samp> |
| + | | Apply or remove a buff ID for the current player. |
| |- | | |- |
| | <samp>AddConversationTopic {{t|topic ID}} {{t|day duration}}</samp> | | | <samp>AddConversationTopic {{t|topic ID}} {{t|day duration}}</samp> |
Line 32: |
Line 33: |
| | <samp>RemoveConversationTopic {{t|topic ID}}</samp> | | | <samp>RemoveConversationTopic {{t|topic ID}}</samp> |
| | End a [[Modding:Dialogue#Conversation topics|conversation topic]], if it's active. | | | End a [[Modding:Dialogue#Conversation topics|conversation topic]], if it's active. |
− | |-
| |
− | | <samp>AddCookingRecipe {{t|player}} {{t|recipe ID}}</samp><br /><samp>AddCraftingRecipe {{t|player}} {{t|recipe key}}</samp>
| |
− | | Add a [[Modding:Recipe data|cooking or crafting recipe]] to the [[#Target player|specified player(s)]].
| |
| |- | | |- |
| | <samp>AddFriendshipPoints {{t|NPC name}} {{t|count}}</samp> | | | <samp>AddFriendshipPoints {{t|NPC name}} {{t|count}}</samp> |
Line 77: |
Line 75: |
| | <samp>AddSpecialOrder {{t|order ID}}</samp><br /><samp>RemoveSpecialOrder {{t|order ID}}</samp> | | | <samp>AddSpecialOrder {{t|order ID}}</samp><br /><samp>RemoveSpecialOrder {{t|order ID}}</samp> |
| | Add or remove a [[Modding:Special orders|special order]]. | | | Add or remove a [[Modding:Special orders|special order]]. |
| + | |- |
| + | | <samp>If {{t|query}} ## {{t|action if true}}</samp><br /><samp>If {{t|query}} ## {{t|action if true}} ## {{t|action if false}}</samp> |
| + | | Check a [[Modding:Game state queries|game state query]] and perform an action based on the result. |
| + | |
| + | For example, this only sends a mail if the player doesn't have it in their received, mailbox, or queued-for-tomorrow mail: |
| + | <syntaxhighlight lang="js"> |
| + | "ActionsOnPurchase": [ |
| + | "If !PLAYER_HAS_MAIL Current SomeFlag ## AddMail Current SomeFlag" |
| + | ] |
| + | </syntaxhighlight> |
| + | |- |
| + | | <samp>IncrementStat {{t|stat key}} {{o|amount}}</samp> |
| + | | Increment a stat value by the given amount (default 1) for the current player. This can be a vanilla stat key (see the <samp>PLAYER_STAT</samp> [[Modding:Game state queries|game state query]] for a list) or a custom stat key. The amount can be negative to decrement it. |
| |- | | |- |
| | <samp>MarkActionApplied {{t|player}} {{t|answer ID}} {{o|applied}}</samp> | | | <samp>MarkActionApplied {{t|player}} {{t|answer ID}} {{o|applied}}</samp> |
| | Mark a <samp>Data/TriggerActions</samp> entry as applied or non-applied for the [[#Target player|specified player(s)]], depending on {{o|applied}} (default <samp>true</samp>). This can be used to skip or re-run an entry, since <samp>Data/TriggerActions</samp> entries are only applied once by default. | | | Mark a <samp>Data/TriggerActions</samp> entry as applied or non-applied for the [[#Target player|specified player(s)]], depending on {{o|applied}} (default <samp>true</samp>). This can be used to skip or re-run an entry, since <samp>Data/TriggerActions</samp> entries are only applied once by default. |
| | | |
− | Note that an entry can't mark ''itself'' unapplied (but you can add a second entry which marks the first one unapplied). | + | Note that an entry can't use this to mark ''itself'' unapplied; see [[#Make Data/TriggerActions repeat|''Make <samp>Data/TriggerActions</samp> repeat'']] if you want to do that. |
| + | |- |
| + | | <samp>MarkCookingRecipeKnown {{t|player}} {{t|recipe ID}} {{o|known}}</samp><br /><samp>MarkCraftingRecipeKnown {{t|player}} {{t|recipe key}} {{o|known}}</samp> |
| + | | Set whether [[#Target player|specified player(s)]] know a [[Modding:Recipe data|cooking or crafting recipe]], depending on {{o|known}} (default <samp>true</samp>). |
| + | |
| + | Note that forgetting a recipe will also reset its times-cooked/crafted counter to zero. |
| |- | | |- |
| | <samp>MarkEventSeen {{t|player}} {{t|event ID}} {{o|seen}}</samp> | | | <samp>MarkEventSeen {{t|player}} {{t|event ID}} {{o|seen}}</samp> |
Line 88: |
Line 104: |
| | <samp>MarkQuestionAnswered {{t|player}} {{t|answer ID}} {{o|answered}}</samp> | | | <samp>MarkQuestionAnswered {{t|player}} {{t|answer ID}} {{o|answered}}</samp> |
| | Mark [[Modding:Dialogue#Response IDs|a dialogue answer]] as selected or non-selected for the [[#Target player|specified player(s)]], depending on {{o|answered}} (default <samp>true</samp>). | | | Mark [[Modding:Dialogue#Response IDs|a dialogue answer]] as selected or non-selected for the [[#Target player|specified player(s)]], depending on {{o|answered}} (default <samp>true</samp>). |
| + | |- |
| + | | <samp>MarkSongHeard {{t|player}} {{t|song ID}} {{o|heard}}</samp> |
| + | | Mark a song track's cue name heard or non-heard for the [[#Target player|specified player(s)]], depending on {{o|heard}} (default <samp>true</samp>). This affects whether the song appears in the [[jukebox]] selection. |
| |- | | |- |
| | <samp>Null</samp> | | | <samp>Null</samp> |
| | ''(Specialized)'' Does nothing. This is used internally; there's generally no benefit to using it yourself. | | | ''(Specialized)'' Does nothing. This is used internally; there's generally no benefit to using it yourself. |
| + | |- |
| + | | <samp>RemoveTemporaryAnimatedSprites</samp> |
| + | | Remove all temporary animated sprites in the current location. For example, this can be used in the [[Modding:Event data|event]] <samp>setSkipActions</samp> command to clean up the event's temporary sprites. |
| |- | | |- |
| | <samp>SetNpcInvisible {{t|NPC name}} {{t|day duration}}</samp> | | | <samp>SetNpcInvisible {{t|NPC name}} {{t|day duration}}</samp> |
Line 160: |
Line 182: |
| |- | | |- |
| | <samp>Id</samp> | | | <samp>Id</samp> |
− | | The [[Modding:Modder Guide/Game Fundamentals#Unique string IDs|unique string ID]] for this trigger action. | + | | The [[Modding:Common data field types#Unique string ID|unique string ID]] for this trigger action. |
| |- | | |- |
| | <samp>Trigger</samp> | | | <samp>Trigger</samp> |
Line 190: |
Line 212: |
| | | |
| This is just a shortcut for <samp>Actions</samp> with one action. Technically you can use both together, but usually you should just pick one property to set. | | This is just a shortcut for <samp>Actions</samp> with one action. Technically you can use both together, but usually you should just pick one property to set. |
− | |-
| |
− | | <samp>Location</samp>
| |
− | | ''(Optional)'' If set, the internal location name where this action should be applied. This is a shortcut for (and more efficient than) using a <samp>LOCATION_NAME</samp> game state query. Default none.
| |
| |- | | |- |
| | <samp>HostOnly</samp> | | | <samp>HostOnly</samp> |
| | ''(Optional)'' Whether this trigger action can only run for the main player. If true, the action will be ignored for farmhands in [[multiplayer]]. | | | ''(Optional)'' Whether this trigger action can only run for the main player. If true, the action will be ignored for farmhands in [[multiplayer]]. |
| + | |- |
| + | | <samp>MarkActionApplied</samp> |
| + | | ''(Optional)'' Whether to mark the action applied when it's applied. Default true. |
| + | |
| + | * If true: the action is added to the player's <samp>triggerActionsRun</samp> list, [[Modding:Game state queries|queries]] like <samp>PLAYER_HAS_RUN_TRIGGER_ACTION</samp> will return true, and the action won't run again (unless you use the <samp>MarkActionApplied</samp> action to mark it unapplied). |
| + | * If false: the action can repeat immediately when the same trigger is raised, and [[Modding:Game state queries|queries]] like <samp>PLAYER_HAS_RUN_TRIGGER_ACTION</samp> will return false for it. |
| |- | | |- |
| | <samp>Condition</samp> | | | <samp>Condition</samp> |
Line 216: |
Line 241: |
| <syntaxhighlight lang="js"> | | <syntaxhighlight lang="js"> |
| "{{ModId}}_Event": "continue/64 15/farmer 64 16 2 Abigail 64 18 0/pause 1500/speak Abigail \"Hi. Here's 10g and a parsnip.\"/action AddMoney 10/action AddItem (O)24/pause 500/end" | | "{{ModId}}_Event": "continue/64 15/farmer 64 16 2 Abigail 64 18 0/pause 1500/speak Abigail \"Hi. Here's 10g and a parsnip.\"/action AddMoney 10/action AddItem (O)24/pause 500/end" |
− | </syntaxhighlight></li> | + | </syntaxhighlight> |
| + | |
| + | See also the <samp>setSkipActions</samp> command. |
| + | </li> |
| | | |
| <li>A [[Modding:Mail data|mail letter]] using the <samp>%action</samp> command. For example: | | <li>A [[Modding:Mail data|mail letter]] using the <samp>%action</samp> command. For example: |
Line 257: |
Line 285: |
| { | | { |
| // get args | | // get args |
− | if (!ArgUtility.TryGet(args, 1, out string soundId, out string error, allowBlank: false)) | + | if (!ArgUtility.TryGet(args, 1, out string soundId, out error, allowBlank: false)) |
| return false; | | return false; |
| | | |
Line 276: |
Line 304: |
| </ul> | | </ul> |
| | | |
− | To avoid conflicts, custom trigger names should be [[Modding:Modder Guide/Game Fundamentals#Unique string IDs|unique string IDs]]. | + | To avoid conflicts, custom trigger names should be [[Modding:Common data field types#Unique string ID|unique string IDs]]. |
| | | |
| ==FAQs== | | ==FAQs== |
Line 288: |
Line 316: |
| | | |
| ===Make <samp>Data/TriggerActions</samp> repeat=== | | ===Make <samp>Data/TriggerActions</samp> repeat=== |
− | Each entry in <samp>Data/TriggerActions</samp> is only applied once per player, but you can use the <samp>MarkActionApplied</samp> action to forget that it was applied. (Note that an action can't forget itself though.)
| + | By default, each entry in <samp>Data/TriggerActions</samp> is only applied once per player. |
| + | |
| + | There are two main ways to repeat actions: |
| + | <ul> |
| + | <li>To make it repeatable immediately, set <samp>"MarkActionApplied": false</samp> on the <samp>Data/TriggerActions</samp> entry.</li> |
| + | <li>To enable repeating at a different time, you can use the <samp>MarkActionApplied</samp> action to forget that it was applied. |
| | | |
| For example, this patch will set alternating 'work' or 'weekend' mail flags depending on the day of week: | | For example, this patch will set alternating 'work' or 'weekend' mail flags depending on the day of week: |
Line 327: |
Line 360: |
| } | | } |
| </nowiki>|lang=js}} | | </nowiki>|lang=js}} |
− |
| |
| | | |
| [[Category:Modding]] | | [[Category:Modding]] |