Changes

m
→‎World: Fixing some GSQ documentation formatting
Line 1: Line 1: −
{{upcoming|1.6}}
  −
   
← [[Modding:Index|Index]]
 
← [[Modding:Index|Index]]
   Line 23: Line 21:  
Which you use is mainly a performance tradeoff:
 
Which you use is mainly a performance tradeoff:
 
* Content Patcher's <samp>When</samp> conditions are highly optimized and cached, so thousands of patches can check the same condition without impacting performance and the resulting changes are written once to the asset. Then there's no performance impact after the asset edit, since it's just plain unconditional data. However the asset is reloaded when patches are added/removed, which may impact performance if they change often in some cases (like reloading a map or indoor/outdoor NPC appearance).
 
* Content Patcher's <samp>When</samp> conditions are highly optimized and cached, so thousands of patches can check the same condition without impacting performance and the resulting changes are written once to the asset. Then there's no performance impact after the asset edit, since it's just plain unconditional data. However the asset is reloaded when patches are added/removed, which may impact performance if they change often in some cases (like reloading a map or indoor/outdoor NPC appearance).
* A game state query has no caching, so it can significantly affect performance when it's checked often. For example, a thousand game state queries checked each update tick means sixty thousand condition evaluations per second. On the other hand, game state queries are faster in cases where the conditions are checked rarely and doing so avoids reloading textures or maps (like <samp>ChooseAppearance</samp> in <samp>Data/Characters</samp> or <samp>Music</samp> in <samp>Data/Locations</samp>).
+
* A game state query has no caching, so it can significantly affect performance when it's checked often. For example, a thousand game state queries checked each update tick means sixty thousand condition evaluations per second. On the other hand, game state queries are faster in cases where the conditions are checked rarely and doing so avoids reloading textures or maps (like <samp>Appearance</samp> in <samp>Data/Characters</samp> or <samp>Music</samp> in <samp>Data/Locations</samp>).
    
==Built-in queries==
 
==Built-in queries==
Line 40: Line 38:  
Here's an example.
 
Here's an example.
   −
<pre> "ANY \"LOCATION_NAME Here BathHouse_Pool\" \"LOCATION_NAME Here BathHouse_MensLocker\" \"LOCATION_NAME Here BathHouse_WomensLocker\" \"LOCATION_NAME Here Beach, WEATHER Sun Wind, SEASON Summer\" \"EVENT_ID festival_summer5, {{HasMod|contains=spacechase0.SurfingFestival}}\""</pre>
+
<pre> "ANY \"LOCATION_NAME Here BathHouse_Pool\" \"LOCATION_NAME Here BathHouse_MensLocker\" \"LOCATION_NAME Here BathHouse_WomensLocker\" \"LOCATION_NAME Here Beach, WEATHER Sun Wind, SEASON Summer\" \"IS_EVENT festival_summer5, {{HasMod|contains=spacechase0.SurfingFestival}}\""</pre>
    
Broken down, this means:
 
Broken down, this means:
Line 112: Line 110:  
! effect
 
! effect
 
|-
 
|-
| <samp>EVENT_ID {{t|event ID}}+</samp>
+
| <samp>IS_EVENT</samp>
| Whether one of the given [[Modding:Event data|event]] IDs are currently playing.
+
| Whether the player is viewing any [[Modding:Event data|event]] or attending any active festival. This doesn't cover passive festivals like the [[Night Market]].
 
+
|-
This also works for non-passive festivals, which have IDs in the form <samp>festival_{{t|season}}{{t|day}}</samp>. For example, <samp>festival_spring13</samp> for the [[Egg Festival]].
+
| <samp>IS_EVENT {{t|event ID}}+</samp>
 +
| Whether the player is viewing an [[Modding:Event data|event]] or attending an active festival whose ID matches one of the specified {{t|event ID}} values. Festivals have IDs in the form <samp>festival_{{t|season}}{{t|day}}</samp> (like <samp>festival_spring13</samp> for the [[Egg Festival]]).
 
|}
 
|}
   Line 144: Line 143:  
| Whether there are fewer of the given building constructed than there are cabins.
 
| Whether there are fewer of the given building constructed than there are cabins.
 
|-
 
|-
| <samp>FARM_CAVE {{t|type}}</samp>
+
| <samp>FARM_CAVE {{t|type}}+</samp>
 
| The current [[The Farm#The Cave|farm cave]] (one of <samp>Bats</samp>, <samp>Mushrooms</samp>, or <samp>None</samp>).
 
| The current [[The Farm#The Cave|farm cave]] (one of <samp>Bats</samp>, <samp>Mushrooms</samp>, or <samp>None</samp>).
 
|-
 
|-
Line 150: Line 149:  
| The name of the farm.
 
| The name of the farm.
 
|-
 
|-
| <samp>FARM_TYPE {{t|type}}</samp>
+
| <samp>FARM_TYPE {{t|type}}+</samp>
 
| The [[Farm Maps|farm type]]. The {{t|type}} can be one of...
 
| The [[Farm Maps|farm type]]. The {{t|type}} can be one of...
 
* a numeric ID for a vanilla farm type: <samp>1</samp> (standard), <samp>2</samp> (riverland), <samp>3</samp> (forest), <samp>4</samp> (hilltop), <samp>5</samp> (combat), <samp>6</samp> (four corners), or <samp>7</samp> (beach);
 
* a numeric ID for a vanilla farm type: <samp>1</samp> (standard), <samp>2</samp> (riverland), <samp>3</samp> (forest), <samp>4</samp> (hilltop), <samp>5</samp> (combat), <samp>6</samp> (four corners), or <samp>7</samp> (beach);
Line 186: Line 185:  
| Whether the [[#Target location|given location]] is accessible. For vanilla locations, this is relevant to <samp>CommunityCenter</samp>, <samp>JojaMart</samp>, or <samp>Railroad</samp>; any other location will return true unless a mod customizes the query.
 
| Whether the [[#Target location|given location]] is accessible. For vanilla locations, this is relevant to <samp>CommunityCenter</samp>, <samp>JojaMart</samp>, or <samp>Railroad</samp>; any other location will return true unless a mod customizes the query.
 
|-
 
|-
| <samp>LOCATION_CONTEXT {{t|location}}</samp>
+
| <samp>LOCATION_CONTEXT {{t|location}} {{t|context ID}}+</samp>
| The location context name for the [[#Target location|given location]].
+
| The location context ID for the [[#Target location|given location]].
 +
|-
 +
| <samp>LOCATION_HAS_CUSTOM_FIELD {{t|location}} {{t|key}} {{o|value}}</samp>
 +
| Checks to see if the location has a given value in its CustomFields. If the value is omitted, checks to see if the key exists at all.
 
|-
 
|-
 
| <samp>LOCATION_IS_INDOORS {{t|location}}</samp><br /><samp>LOCATION_IS_OUTDOORS {{t|location}}</samp><br /><samp>LOCATION_IS_MINES {{t|location}}</samp><br /><samp>LOCATION_IS_SKULL_CAVE {{t|location}}</samp>
 
| <samp>LOCATION_IS_INDOORS {{t|location}}</samp><br /><samp>LOCATION_IS_OUTDOORS {{t|location}}</samp><br /><samp>LOCATION_IS_MINES {{t|location}}</samp><br /><samp>LOCATION_IS_SKULL_CAVE {{t|location}}</samp>
Line 256: Line 258:  
| For numeric properties only, whether a property on <samp>Game1.netWorldState</samp> has a value between {{t|min}} and {{o|max}} (default unlimited). If {{o|max}} is omitted or the properties isn't numeric, the previous form is used. See the previous entry for a list of useful properties.
 
| For numeric properties only, whether a property on <samp>Game1.netWorldState</samp> has a value between {{t|min}} and {{o|max}} (default unlimited). If {{o|max}} is omitted or the properties isn't numeric, the previous form is used. See the previous entry for a list of useful properties.
 
|-
 
|-
| <samp>WORLD_STATE_ID {{t|id}}</samp>
+
| <samp>WORLD_STATE_ID {{t|id}}+</samp>
| Whether any world state flag with the given {{t|id}} is set.
+
| Whether any world state flag matching the given {{t|id}} values is set.
 
|}
 
|}
   Line 296: Line 298:  
| Whether the [[#Target player|specified player(s)]] have a [[Modding:Dialogue#Conversation topics|conversation topic]] with the ID {{t|id}} active.
 
| Whether the [[#Target player|specified player(s)]] have a [[Modding:Dialogue#Conversation topics|conversation topic]] with the ID {{t|id}} active.
 
|-
 
|-
| <samp>PLAYER_HAS_CRAFTING_RECIPE {{t|player}} {{t|recipe name}}</samp><br /><samp>PLAYER_HAS_COOKING_RECIPE {{t|player}} {{t|recipe name}}</samp>
+
| <samp>PLAYER_HAS_COOKING_RECIPE {{t|player}} {{t|recipe name}}</samp><br /><samp>PLAYER_HAS_CRAFTING_RECIPE {{t|player}} {{t|recipe name}}</samp>
 
| Whether the [[#Target player|specified player(s)]] know the crafting/cooking recipe identified by its internal name (spaces allowed). For example, <code>PLAYER_HAS_CRAFTING_RECIPE Current Field Snack</code>.
 
| Whether the [[#Target player|specified player(s)]] know the crafting/cooking recipe identified by its internal name (spaces allowed). For example, <code>PLAYER_HAS_CRAFTING_RECIPE Current Field Snack</code>.
 
|-
 
|-
 
| <samp>PLAYER_HAS_DIALOGUE_ANSWER {{t|player}} {{t|id}}</samp>
 
| <samp>PLAYER_HAS_DIALOGUE_ANSWER {{t|player}} {{t|id}}</samp>
 
| Whether the [[#Target player|specified player(s)]] have chosen the given dialogue answer in a previous dialogue.
 
| Whether the [[#Target player|specified player(s)]] have chosen the given dialogue answer in a previous dialogue.
 +
|-
 +
| <samp>PLAYER_HAS_HEARD_SONG {{t|player}} {{t|id}}</samp>
 +
| Whether the [[#Target player|specified player(s)]] have heard a song track's cue name (e.g. for the [[jukebox]] track selection).
 +
|-
 +
| <samp>PLAYER_HAS_ITEM {{t|player}} {{t|item}} {{o|min}} {{o|max}}</samp>
 +
| Whether the [[#Target player|specified player(s)]] have between {{o|min}} and {{o|max}} (default unlimited) matching items in their inventory, inclusively. The {{t|item}} can be <samp>858</samp> or <samp>(O)858</samp> (Qi Gems), <samp>73</samp> or <samp>(O)73</samp> (Walnuts), or the [[Modding:Common data field types#Item ID|qualified or unqualified item ID]].
 
|-
 
|-
 
| <samp>PLAYER_HAS_MAIL {{t|player}} {{t|mail id}} {{o|type}}</samp>
 
| <samp>PLAYER_HAS_MAIL {{t|player}} {{t|mail id}} {{o|type}}</samp>
Line 325: Line 333:  
* or has no letter in <samp>Data/mail</samp>, so it was added to the received list directly.
 
* or has no letter in <samp>Data/mail</samp>, so it was added to the received list directly.
 
|}
 
|}
|-
  −
| <samp>PLAYER_HAS_ITEM {{t|player}} {{t|item}} {{o|min}} {{o|max}}</samp>
  −
| Whether the [[#Target player|specified player(s)]] have between {{o|min}} and {{o|max}} (default unlimited) matching items in their inventory, inclusively. The {{t|item}} can be <samp>858</samp> or <samp>(O)858</samp> (Qi Gems), <samp>73</samp> or <samp>(O)73</samp> (Walnuts), or the [[Modding:Migrate to Stardew Valley 1.6#Custom items|qualified or unqualified item ID]].
   
|-
 
|-
 
| <samp>PLAYER_HAS_PROFESSION {{t|player}} {{t|profession id}}</samp>
 
| <samp>PLAYER_HAS_PROFESSION {{t|player}} {{t|profession id}}</samp>
Line 350: Line 355:  
| Whether the [[#Target player|specified player(s)]] are in the given [[Modding:Migrate to Stardew Valley 1.6#Custom location contexts|location context]].
 
| Whether the [[#Target player|specified player(s)]] are in the given [[Modding:Migrate to Stardew Valley 1.6#Custom location contexts|location context]].
 
|-
 
|-
| <samp>PLAYER_LOCATION_NAME {{t|player}} {{t|location name}}</samp><br /><samp>PLAYER_LOCATION_UNIQUE_NAME {{t|player}} {{t|location name}}</samp>
+
| <samp>PLAYER_LOCATION_NAME {{t|player}} {{t|location name}}+</samp><br /><samp>PLAYER_LOCATION_UNIQUE_NAME {{t|player}} {{t|location name}}+</samp>
 
| Whether the [[#Target player|specified player(s)]] are in the given location, using the name or unique instanced name (you can see both names in-game using the {{nexus mod|679|Debug Mode}} mod). The {{t|location name}} value doesn't recognize [[#Target location|target location keywords]] like <samp>Here</samp>.
 
| Whether the [[#Target player|specified player(s)]] are in the given location, using the name or unique instanced name (you can see both names in-game using the {{nexus mod|679|Debug Mode}} mod). The {{t|location name}} value doesn't recognize [[#Target location|target location keywords]] like <samp>Here</samp>.
 
|-
 
|-
Line 443: Line 448:  
* <samp>weedsEliminated</samp>.
 
* <samp>weedsEliminated</samp>.
 
|-
 
|-
| <samp>PLAYER_VISITED_LOCATION {{t|player}} {{t|location name}}</samp>
+
| <samp>PLAYER_VISITED_LOCATION {{t|player}} {{t|location name}}+</samp>
| Whether the [[#Target player|specified player(s)]] have visited a given location name. For example, <code>PLAYER_VISITED_LOCATION Current IslandWest</code> checks whether the current player has ever visited [[Ginger Island#Island West|Ginger Island West]].
+
| Whether the [[#Target player|specified player(s)]] have visited one of the given location names. For example, <code>PLAYER_VISITED_LOCATION Current IslandWest</code> checks whether the current player has ever visited [[Ginger Island#Island West|Ginger Island West]].
    
Notes:
 
Notes:
Line 475: Line 480:  
<pre>PLAYER_HEARTS Current Abigail 3</pre>
 
<pre>PLAYER_HEARTS Current Abigail 3</pre>
 
|-
 
|-
| <samp>PLAYER_HAS_MET {{t|player}} {{t|npc}}</samp>
+
| <samp>PLAYER_HAS_MET {{t|player}} {{t|npc}}+</samp>
| Whether the [[#Target player|specified player(s)]] have talked to an NPC at least once. The {{t|npc}} is an NPC's internal name.
+
| Whether the [[#Target player|specified player(s)]] have talked to one of the given NPCs at least once. The {{t|npc}} is an NPC's internal name.
 
|-
 
|-
 
| <samp>PLAYER_NPC_RELATIONSHIP {{t|player}} {{t|npc}} {{t|type}}+</samp>
 
| <samp>PLAYER_NPC_RELATIONSHIP {{t|player}} {{t|npc}} {{t|type}}+</samp>
Line 525: Line 530:  
|}
 
|}
 
|-
 
|-
| <samp>PLAYER_PREFERRED_PET {{t|player}} {{t|pet}}</samp>
+
| <samp>PLAYER_PREFERRED_PET {{t|player}} {{t|pet type}}+</samp>
| Whether the preferred pet for the [[#Target player|specified player(s)]] is <samp>Cat</samp>, <samp>Dog</samp>, or a specified custom pet type.
+
| Whether the preferred pet for the [[#Target player|specified player(s)]] is one of the given types. The vanilla pet types are <samp>Cat</samp> and <samp>Dog</samp>.
 
|}
 
|}
   Line 579: Line 584:  
|-
 
|-
 
| <samp>ITEM_ID {{t|target}} {{t|item ID}}+</samp>
 
| <samp>ITEM_ID {{t|target}} {{t|item ID}}+</samp>
| Whether the item has one of the given [[Modding:Migrate to Stardew Valley 1.6#Custom items|qualified or unqualified item IDs]].
+
| Whether the item has one of the given [[Modding:Common data field types#Item ID|qualified or unqualified item IDs]].
 
|-
 
|-
 
| <samp>ITEM_ID_PREFIX {{t|target}} {{t|prefix}}</samp>
 
| <samp>ITEM_ID_PREFIX {{t|target}} {{t|prefix}}</samp>
| Whether the item's [[Modding:Migrate to Stardew Valley 1.6#Custom items|qualified or unqualified item ID]] starts with the given prefix.
+
| Whether the item's [[Modding:Common data field types#Item ID|qualified or unqualified item ID]] starts with the given prefix.
 
|-
 
|-
 
| <samp>ITEM_NUMERIC_ID {{t|target}} {{o|min}} {{o|max}}</samp>
 
| <samp>ITEM_NUMERIC_ID {{t|target}} {{o|min}} {{o|max}}</samp>
| Whether the item has a numeric [[Modding:Migrate to Stardew Valley 1.6#Custom items|unqualified item ID]] which is between {{o|min}} and {{o|max}} (both defaulting to the lowest and highest possible value).
+
| Whether the item has a numeric [[Modding:Common data field types#Item ID|unqualified item ID]] which is between {{o|min}} and {{o|max}} (both defaulting to the lowest and highest possible value).
 
|-
 
|-
 
| <samp>ITEM_OBJECT_TYPE {{t|target}} {{t|type}}+</samp>
 
| <samp>ITEM_OBJECT_TYPE {{t|target}} {{t|type}}+</samp>
Line 591: Line 596:  
|-
 
|-
 
| <samp>ITEM_PRICE {{t|target}} {{t|min}} {{o|max}}</samp>
 
| <samp>ITEM_PRICE {{t|target}} {{t|min}} {{o|max}}</samp>
| Whether the item has a sell-to-shop price between {{t|min}} and {{o|max}} (default highest possible value).
+
| Whether the item has a purchase-from-shop price between {{t|min}} and {{o|max}} (default highest possible value).
 
|-
 
|-
 
| <samp>ITEM_QUALITY {{t|target}} {{t|min}} {{o|max}}</samp>
 
| <samp>ITEM_QUALITY {{t|target}} {{t|min}} {{o|max}}</samp>
Line 600: Line 605:  
|-
 
|-
 
| <samp>ITEM_TYPE {{t|target}} {{t|type}}+</samp>
 
| <samp>ITEM_TYPE {{t|target}} {{t|type}}+</samp>
| Whether the [[Modding:Migrate to Stardew Valley 1.6#Custom items|item's type definition ID]] matches one of the given values. For example, <samp>ITEM_TYPE Target (BC)</samp> matches bigcraftables.
+
| Whether the [[Modding:Common data field types#Item ID|item's type definition ID]] matches one of the given values. For example, <samp>ITEM_TYPE Target (BC)</samp> matches bigcraftables.
 
|-
 
|-
 
| <samp>ITEM_HAS_EXPLICIT_OBJECT_CATEGORY {{t|target}}</samp>
 
| <samp>ITEM_HAS_EXPLICIT_OBJECT_CATEGORY {{t|target}}</samp>
Line 692: Line 697:     
===Extensibility===
 
===Extensibility===
C# mods can check if a query exists using <code>GameStateQuery.Exists("Example.ModId_ConditionName")</code>, and define custom conditions using <code>GameStateQuery.Register("Example.ModId_ConditionName", handleQueryMethod)</code>. To avoid conflicts, custom query names should apply the [[Modding:Common data field types#Unique string ID|unique string ID]] conventions.
+
C# mods can...
 +
* check if a query exists using <code>GameStateQuery.Exists("Example.ModId_ConditionName")</code>;
 +
* define custom queries using <code>GameStateQuery.Register("Example.ModId_ConditionName", handleQueryMethod)</code> (using a [[Modding:Common data field types#Unique string ID|unique string ID]] for the query name);
 +
* and add query aliases using <code>GameStateQuery.RegisterAlias("Example.ModId_AliasName", "Example.ModId_ConditionName")</code> (ideally using a [[Modding:Common data field types#Unique string ID|unique string ID]] for the alias).
    
[[Category:Modding]]
 
[[Category:Modding]]
29

edits