Module:Item/doc

From Space Station 14 Wiki
Revision as of 23:39, 17 August 2024 by Aliser (talk | contribs) (rewrite to fit the new reality)

This is the documentation page for Module:Item

Module documentation
View or edit this documentation (about module documentation)

Contains utilities for working with in-game items.

Adding items

To add more items, go to Module:Item/item names by item id.json.

It is a JSON file containing an object with keys being the item in-game IDs, but also allows custom IDs for displaying items such as coil variations.

Values are the names for these items - the first being the "display name" used in-game, and the rest are aliases.

Currently, there's no process for adding new items or keeping existing ones up to date automatically or, so it's all manual work.

Adding new item to the list of items

First, get the item ID. It can be found in the `Resources` directory. Second, get the item display name. It can be found in locale files in the same `Resources` directory.

After you got both, add a new entry to the end of the file.

Example
For instance, if you want to add omega soap with ID SoapOmega, the entry will look like this:
	"SoapOmega": [
		"omega soap"
	]
More names can be added - these will be aliases - you can add as many as you want, e.g. osoap.

Linking a texture to the item

To add images for items, go to Module:Item/item image files by item id.json.

It is a JSON file containing an object with keys being the item in-game IDs, but also allows custom IDs for displaying items such as coil variations.

Values are the texture file names, uploaded to the wiki.

Example
First, upload a texture to the wiki.

Following the previous example for omega soap, let's say that the texture uploaded is called OmegaSoapIcon.png. Now, add a new entry:

	"SoapOmega": "OmegaSoapIcon.png"

Adding multiple textures for an item

Let's say, we want to upload textures for a new shiny material called Brass. In-game, the material has the ID SheetBrass. But since we can only make a single item → texture connection, there's no way to add multiple textures for one element.

For such cases, the solution is to add more items to the list of items and link extra textures to them. These "fake" items can have any IDs you want.

After that is done, now it's time to make a link between item amount and its texture. This is done in https://wiki.spacestation14.com/wiki/Module:Item/item_lookup_conflicts_resolvers.json

Each entry in that file has the following schema:

	{
		"match": "An array of item IDs that match with this entry. If an item ID doesn't appear here, this entry will be skipped.",
		"fallbackItemId": "Item ID used when no amount is specified or when no condition from below matches",
		"resolvers": [
			{
				"itemId": "Item ID used when if the condition below satisfies.",
				"conditions": {
					"min": "At least what amount should be specified for this condition to be satisfied."
				}
			},
            ...
		]
	}
Example
For Brass, the schema will look like this:
	{
		"match": [
			"SheetBrass",
			"SheetBrass10",
			"SheetBrass1"
		],
		"fallbackItemId": "SheetBrass",
		"resolvers": [
			{
				"itemId": "SheetBrass",
				"conditions": {
					"min": 20
				}
			},
			{
				"itemId": "SheetBrass10",
				"conditions": {
					"min": 10
				}
			},
			{
				"itemId": "SheetBrass1"
			}
		]
	}
  1. We add all Brass item IDs to match, so that the whole entry doesn't get skipped.
  2. We pick a fallback item ID in fallbackItemId to use when no amount is specified in the template, or when no condition is satisfied.
  3. We set up "resolvers" - when satisfied, the specified ID will be used as a result. Each resolver must have an itemId. If a resolver doesn't have conditions, it automatically "wins". If it DOES have it, then the listed conditions are checked.
  4. For Brass, we set up 3 resolvers:
  • Use item with ID SheetBrass when there are at least 20 items in stack.
  • Use item with ID SheetBrass10 when there are at least 10 items in stack.
  • Use item with ID SheetBrass1 in other cases (i.e. when there are 9 or less items in stack).
The specified resolvers will be checked in sequence, until a resolver with proper conditions is found. If that doensn't happen, the fallback item ID is used.