Line 17: |
Line 17: |
| | | |
| Remember that quotes and backslashes inside JSON strings need to be escaped too. For example, <code>"AddFriendshipPoints \"Mister Qi\" 10"</code> will send <code>AddFriendshipPoints "Mister Qi" 10</code> to the game code. Alternatively, you can use single-quotes for the JSON string instead, like <code>'AddFriendshipPoints "Mister Qi" 10'</code>. | | Remember that quotes and backslashes inside JSON strings need to be escaped too. For example, <code>"AddFriendshipPoints \"Mister Qi\" 10"</code> will send <code>AddFriendshipPoints "Mister Qi" 10</code> to the game code. Alternatively, you can use single-quotes for the JSON string instead, like <code>'AddFriendshipPoints "Mister Qi" 10'</code>. |
− |
| |
− | ===Trigger actions vs map actions===
| |
− | ''Actions'' can refer to two different systems:
| |
− |
| |
− | * ''Trigger actions'' (this page) let you perform generic background tasks that can be done anytime, like sending a letter or starting a quest. These can be triggered automatically based on conditions, or via commands in dialogue, events, etc.
| |
− | * ''[[Modding:Maps|Map actions]]'' refer to the <samp>Action</samp> and <samp>TouchAction</samp> map properties, which do something when you walk on or interact with a map tile. These can perform a wide array of map- and interaction-specific things like showing a message box, changing the map, opening shop menus, etc. These only work in maps, and generally don't make sense in other contexts.
| |
− |
| |
− | Aside from the similar names, they're not interchangeable and there's fairly little overlap.
| |
| | | |
| ==Actions== | | ==Actions== |
Line 285: |
Line 277: |
| | | |
| 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:Modder Guide/Game Fundamentals#Unique string IDs|unique string IDs]]. |
| + | |
| + | ==FAQs== |
| + | ===Trigger actions vs map actions=== |
| + | ''Actions'' can refer to two different systems: |
| + | |
| + | * ''Trigger actions'' (this page) let you perform generic background tasks that can be done anytime, like sending a letter or starting a quest. These can be triggered automatically based on conditions, or via commands in dialogue, events, etc. |
| + | * ''[[Modding:Maps|Map actions]]'' refer to the <samp>Action</samp> and <samp>TouchAction</samp> map properties, which do something when you walk on or interact with a map tile. These can perform a wide array of map- and interaction-specific things like showing a message box, changing the map, opening shop menus, etc. These only work in maps, and generally don't make sense in other contexts. |
| + | |
| + | Aside from the similar names, they're not interchangeable and there's fairly little overlap. |
| + | |
| + | ===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.) |
| + | |
| + | For example, this patch will set alternating 'week' or 'weekend' mail flags depending on the day of week: |
| + | {{#tag:syntaxhighlight|<nowiki> |
| + | { |
| + | "Format": "</nowiki>{{Content Patcher version}}<nowiki>", |
| + | "Changes": [ |
| + | { |
| + | "Action": "EditData", |
| + | "Target": "Data/TriggerActions", |
| + | "Entries": { |
| + | // set 'week' flag on weekdays, and reset weekend action |
| + | "{{ModId}}_Week": { |
| + | "Id": "{{ModId}}_Week", |
| + | "Trigger": "DayStarted", |
| + | "Condition": "!DAY_OF_WEEK Saturday Sunday", |
| + | "Actions": [ |
| + | "AddMail Current {{ModId}}_Week Received", |
| + | "RemoveMail Current {{ModId}}_Weekend", |
| + | "MarkActionApplied Current {{ModId}}_Weekend false" |
| + | ] |
| + | }, |
| + | |
| + | // set 'weekend' flag on weekends, and reset week action |
| + | "{{ModId}}_Weekend": { |
| + | "Id": "{{ModId}}_Weekend", |
| + | "Trigger": "DayStarted", |
| + | "Condition": "DAY_OF_WEEK Saturday Sunday", |
| + | "Actions": [ |
| + | "AddMail Current {{ModId}}_Weekend Received", |
| + | "RemoveMail Current {{ModId}}_Week", |
| + | "MarkActionApplied Current {{ModId}}_Week false" |
| + | ] |
| + | }, |
| + | } |
| + | } |
| + | ] |
| + | } |
| + | </nowiki>|lang=js}} |
| + | |
| | | |
| [[Category:Modding]] | | [[Category:Modding]] |