Module:Item/doc: Difference between revisions

From Space Station 14 Wiki
(fixed example)
(fixed examples)
Line 19: Line 19:
|For coils, the game has 3 item IDs: {{c|CableHVStack}} (hv), {{c|CableMVStack}} (mv), {{c|CableApcStack}} (lv).
|For coils, the game has 3 item IDs: {{c|CableHVStack}} (hv), {{c|CableMVStack}} (mv), {{c|CableApcStack}} (lv).


These three allow to configure a single icon for each coil variation, but the game has more variations per type of coil depending on how many coils are left in stack. For instance, for 20 HV coils the icon will change to {{item|hv20|l=}}, and when there are 10 or less - to {{item|hv10|l=}}.
These three allow to configure a single icon for each coil variation, but the game has more variations per type of coil depending on how many coils are left in stack. For instance, for less than 20 HV coils the icon will change to {{item|hv10|l=}}, and when there are less than 10 - to {{item|hv1|l=}}.


To support more icons per item, we can just add more "fake" item IDs, give them any name we want and then define icons for them. For the "20" variation of HV we can add:
To support more icons per item, we can just add more "fake" item IDs, give them any name we want and then define icons for them. For the "10" variation of HV we can add:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
"CableHV20": [
"CableHV10": [
         "CableHV20",
         "CableHV10",
"HV cable coil (20)",  
"HV cable coil",  
"HV20",
"HV10"
"HV (20)",
"HV coil (20)",
"HV cable (20)"
],
],
</syntaxhighlight>
</syntaxhighlight>


{{c|HV cable coil (20)}} would be the «main» name, and the rest below are aliases.
{{c|HV cable coil}} would be the «main» name, and the rest below are aliases.
}}
}}


Line 46: Line 43:


{{Callout|Example
{{Callout|Example
|To add an icon for a newly added {{c|CableHV20}} item from the previous example, we would have to add a new line to the JSON file. For instance, if the icon filename is {{c|Coilhv-20.png}}, the line would be:
|To add an icon for a newly added {{c|CableHV10}} item from the previous example, we would have to add a new line to the JSON file. For instance, if the icon filename is {{c|Coilhv-10.png}}, the line would be:
<syntaxhighlight lang="json>
<syntaxhighlight lang="json>
     "CableHV20": "Coilhv-20.png"
     "CableHV10": "Coilhv-10.png"
</syntaxhighlight>
</syntaxhighlight>
}}
}}


To see if icons do work, look at newly-added items in the list of items in {{t|item}}.
To see if icons do work, look at newly-added items in the list of items in {{t|item}}.

Revision as of 13:03, 17 August 2024

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.

Each item has a list of names. These are used for various lookups. An item can have as many names as you wish, but it must have at least two.

  • The first name listed must be the same as ID.
  • The second one must be the one used in-game. It will be used as a «main» name in various lookups.
  • The rest are aliases and can be anything. But be aware that duplicate names will screw up the lookups.
Example
For coils, the game has 3 item IDs: CableHVStack (hv), CableMVStack (mv), CableApcStack (lv).

These three allow to configure a single icon for each coil variation, but the game has more variations per type of coil depending on how many coils are left in stack. For instance, for less than 20 HV coils the icon will change to , and when there are less than 10 - to .

To support more icons per item, we can just add more "fake" item IDs, give them any name we want and then define icons for them. For the "10" variation of HV we can add:

	"CableHV10": [
        "CableHV10",
		"HV cable coil", 
		"HV10"
	],
HV cable coil would be the «main» name, and the rest below are aliases.

Adding images for items

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.

Warning
For items to show up, they must also be added as items.

The value of an item is its icon filename.

Example
To add an icon for a newly added CableHV10 item from the previous example, we would have to add a new line to the JSON file. For instance, if the icon filename is Coilhv-10.png, the line would be:
    "CableHV10": "Coilhv-10.png"

To see if icons do work, look at newly-added items in the list of items in {{item}}.