Module:Item/doc: Difference between revisions

From Space Station 14 Wiki
(intro, faq)
(adding icons)
Line 32: Line 32:


=== How to add icon to item? ===
=== How to add icon to item? ===
If you want to add multiple textures per single item, see [[#Adding multiple icons to item]]
1. Upload new icon to the wiki.
1. Upload new icon to the wiki.


2. Go to [[Module:Item/item_image_files_by_item_id.json]].
2. Go to [[Module:Item/item_image_files_by_item_id.json]].


3. Add a new line before the first entry. Follow the format: {{c|"<item ID>": "<file name>",}}  
3. Add a new line. Follow the format: {{c|"<item ID>": "<file name>"}}  
{{Callout|Example|
{{Callout|Example|
{{c|"WeaponLaserCarbine": "laser rifle-East-35325.png",}}
{{c|"WeaponLaserCarbine": "laser rifle-East-35325.png"}}
}}
 
4. Save the file. The icon should now appear when using {{t|item}}.
 
==== Adding multiple icons to item ====
Currently, the only supported use case if for items that have a different icon based on the amount of item.
 
1. Upload new icons to the wiki.
 
2. Go to [[Module:Item/item_image_files_by_item_id.json]].
 
3. Add a new line. Follow the format:
{{Callout|Info|h=Format|
{{sthl|lang=json|
"<item ID>": {
"default": "<default file name>",
"byCondition": [
{
"type": "amount",
"conditions": [
{
"file": "<file name 1>",
"min": <minimum amount 1>
},
{
"file": "<file name 2>",
"min": <minimum amount 2>
},
{
"file": "<file name 3>",
}
]
}
]
}
}}
}}
}}


4. Save the file. It should now appear when using {{t|item}}.
* {{c|item ID}} - item ID to add icons for.
* {{c|default file name}} - icon to use when amount is not specified.
* {{c|file name 1/2/N}} - icons to use with specified amounts.
* {{c|"min": <amount 1/2/N>}} - icon to use when there's at least this much of item.
 
Last condition entry (objects that have {{c|"file"}} and {{c|"min"}} fields) shouldn't have any condition in it (i.e. no {{c|"min"}} specified), because it will be used in cases where other conditions do not satisfy.
 
Conditions are evaluated top to bottom, meaning the file from the first one that satisfies will be used.
 
4. Save the file. The icons should now appear when using {{t|item}} and differ based on the amount.


== TODO ==
== TODO ==

Revision as of 12:14, 17 September 2024

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

Implements {{Item}}.

Known items are synced regularly from the upstream, but things like icons and links must be defined manually. See #JSON files to see what data files there are, and see #FAQ on specific instructions.

JSON files

JSON files that are updated automatically, syncing with the upstream:

Warning
Do not make changes to the above JSON files - any changes made will be erased on next update.

JSON files that are filled manually:

FAQ

How to add new item?

New items are added automatically. This doesn't include icons - for that, see #How to add icon to item?.

Where to get item ID?

From Module:Item/item_names_by_item_ids.json.

How to add icon to item?

If you want to add multiple textures per single item, see #Adding multiple icons to item

1. Upload new icon to the wiki.

2. Go to Module:Item/item_image_files_by_item_id.json.

3. Add a new line. Follow the format: "<item ID>": "<file name>"

Example
"WeaponLaserCarbine": "laser rifle-East-35325.png"

4. Save the file. The icon should now appear when using {{item}}.

Adding multiple icons to item

Currently, the only supported use case if for items that have a different icon based on the amount of item.

1. Upload new icons to the wiki.

2. Go to Module:Item/item_image_files_by_item_id.json.

3. Add a new line. Follow the format:

Format
"<item ID>": {
	"default": "<default file name>",
	"byCondition": [
		{
			"type": "amount",
			"conditions": [
				{
					"file": "<file name 1>",
					"min": <minimum amount 1>
				},
				{
					"file": "<file name 2>",
					"min": <minimum amount 2>
				},
				{
					"file": "<file name 3>",
				}
			]
		}
	]
}
  • item ID - item ID to add icons for.
  • default file name - icon to use when amount is not specified.
  • file name 1/2/N - icons to use with specified amounts.
  • "min": <amount 1/2/N> - icon to use when there's at least this much of item.

Last condition entry (objects that have "file" and "min" fields) shouldn't have any condition in it (i.e. no "min" specified), because it will be used in cases where other conditions do not satisfy.

Conditions are evaluated top to bottom, meaning the file from the first one that satisfies will be used.

4. Save the file. The icons should now appear when using {{item}} and differ based on the amount.

TODO

  • Ores are currently hardcoded into names overrides. Figure out a way to pull them from game resources. This is for Module:Item recipe.