Modding:Item queries

From Stardew Valley Wiki
Revision as of 17:54, 21 January 2024 by Pathoschild (talk | contribs) (copy content from Modding:Migrate to Stardew Valley 1.6 (main author Pathoschild, with a RANDOM_ITEMS example code typo fix by Lumisteria))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The following describes the upcoming Stardew Valley 1.6, and may change before release.

Index

This page documents item queries, a built-in way to create one or more items based on a string command.

Copied from Modding:Migrate to Stardew Valley 1.6

Item queries choose one or more items dynamically, instead of specifying a single item ID. These are used in various places like machine data and shop data.

Available queries

The supported item queries are:

query effect
ALL_ITEMS [type ID] [flags] Every item provided by the item data definitions. If [type ID] is set to an item type identifier (like (O) for object), only returns items from the matching item data definition.

The [flags] specify options to apply. If specified, they must be at the end of the argument list (with or without [type ID]). The flags can be any combination of:

flag effect
@isRandomSale Don't return items marked 'exclude from random sale' in Data/Furniture or Data/Objects.
@requirePrice Don't return items with a sell-to-player price below data-sort-value="1">Gold.png1g.

For example:

  • ALL_ITEMS will return every item in the game.
  • ALL_ITEMS @isRandomSale will return every item in the game that's not excluded from random sale.
  • ALL_ITEMS (F) @isRandomSale will return every furniture item in the game that's not excluded from random sale.
DISH_OF_THE_DAY The Saloon's dish of the day.
FLAVORED_ITEM <type> <ingredient ID> [ingredient flavor ID] A flavored item like Apple Wine. The <type> can be one of AgedRoe, Honey, Jelly, Juice, Pickle, Roe, or Wine. The <ingredient ID> is the qualified or unqualified item ID which provides the flavor (like Apple in Apple Wine). For Honey, you can set the <flavor ID> to -1 for Wild Honey.

For aged roe only, the [ingredient flavor ID] is the flavor of the <ingredient ID>. For example, FLAVORED_ITEM AgedRoe (O)812 128 creates Aged Pufferfish Roe (812 is roe and 128 is pufferfish).

ITEMS_SOLD_BY_PLAYER <shop location> Random items the player has recently sold to the <shop location>, which can be one of SeedShop (Pierre's store) or FishShop (Willy's fish shop).
LOCATION_FISH <location> <bobber tile> <depth> A random item that can be found by fishing in the given location. The <location> should be the internal name of the location, <bobber tile> is the position of the fishing rod's bobber in the water (in the form <x> <y>), and <depth> is the bobber's distance from the nearest shore measured in tiles (where 0 is directly adjacent to the shore).

Careful: since the target location might use LOCATION_FISH queries in its list, it's easy to cause a circular reference by mistake (e.g. location A gets fish from B, which gets fish from A). If this happens, the game will log an error and return no item.

LOST_BOOK_OR_ITEM [alternate query] Returns a lost book if the player hasn't found them all yet, else the result of the [alternate query] if specified, else nothing.

For example, LOST_BOOK_OR_ITEM (O)770 returns mixed seeds if the player found every book already.

RANDOM_ARTIFACT_FOR_DIG_SPOT A random item which is defined in Data/Objects with the Arch (artifact) type, and whose spawn rules in the Miscellaneous field match the current location and whose random probability passes. This is mainly used by artifact spots.
RANDOM_BASE_SEASON_ITEM A random seasonal vanilla item which can be found by searching garbage cans, breaking containers in the mines, etc.
RANDOM_ITEMS <type definition ID> [min ID] [max ID] [flags] All items from the given type definition ID in randomized order, optionally filtered to those with a numeric ID in the given [min ID] and [max ID] range (inclusive).

The [flags] specify options to apply. If specified, they must be at the end of the argument list (with or without [min ID] and/or [max ID]). The flags can be any combination of:

The flags can be any combination of:

flag effect
@isRandomSale Don't return items marked 'exclude from random sale' in Data/Furniture or Data/Objects.
@requirePrice Don't return items with a sell-to-player price below data-sort-value="1">Gold.png1g.

For example, you can sell a random wallpaper for data-sort-value="200">Gold.png200g in Data/Shops:

{
    "ItemId": "RANDOM_ITEMS (WP)",
    "MaxItems": 1,
    "Price": 200
}

Or a random house plant:

{
    "ItemId": "RANDOM_ITEMS (F) 1376 1390",
    "MaxItems": 1
}

Or a random custom item added by a mod by its item ID prefix:

{
    "ItemId": "RANDOM_ITEMS (O)",
    "MaxItems": 1,
    "PerItemCondition": "ITEM_ID_PREFIX Target AuthorName_ModName_"
}

Or 10 random objects with any category except -13 or -14:

{
    "ItemId": "RANDOM_ITEMS (O)",
    "MaxItems": 10,
    "PerItemCondition": "ITEM_CATEGORY, !ITEM_CATEGORY Target -13 -14"
}
SECRET_NOTE_OR_ITEM [alternate query] Returns a secret note (or journal scrap on the island) if the player hasn't found them all yet, else the result of the [alternate query] if specified, else nothing.

For example, SECRET_NOTE_OR_ITEM (O)390 returns clay if the player found every secret note already.

SHOP_TOWN_KEY The special town key item. This is only valid in shops.
TOOL_UPGRADES [tool ID] The tool upgrades listed in Data/Shops whose conditions match the player's inventory (i.e. the same rules as Clint's tool upgrade shop). If [tool ID] is specified, only upgrades which consume that tool ID are shown.