Module:Item/doc: Difference between revisions
m fixed a wrong link |
update data source links |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{module docs|bb= | {{module docs|bb= | ||
{{uses json data<!-- | {{uses json data<!-- | ||
-->|Module:Item/ | -->|Module:Item/data/auto/entity map of id to name.json<!-- | ||
-->|Module:Item/ | -->|Module:Item/data/auto/entity map of lc name to id.json<!-- | ||
-->|Module:Item/item ids by item lowercase names overrides.json<!-- | -->|Module:Item/item ids by item lowercase names overrides.json<!-- | ||
-->|Module:Item/item image files by item id.json<!-- | -->|Module:Item/item image files by item id.json<!-- | ||
-->|Module:Item/item page links by item ids.json}} | -->|Module:Item/item page links by item ids.json<!-- | ||
-->|Module:Item/sizes.json}} | |||
}} | }} | ||
Line 14: | Line 15: | ||
== JSON files == | == JSON files == | ||
'''JSON files that are updated automatically, syncing with the upstream:''' | '''JSON files that are updated automatically, syncing with the upstream:''' | ||
* [[Module:Item/ | * [[Module:Item/data/auto/entity map of id to name.json]] - contains 1 to 1 mapping of item IDs to their names. | ||
* [[Module:Item/ | * [[Module:Item/data/auto/entity map of lc name to id.json]] - contains 1 to 1 mapping of item names (lowercase) to their IDs. If a name repeats for multiple items, only a single item ID will be defined here. | ||
{{Callout|Warning|Do not make changes to the above JSON files - any changes made will be erased on next update.}} | {{Callout|Warning|Do not make changes to the above JSON files - any changes made will be erased on next update.}} | ||
Line 23: | Line 24: | ||
* [[Module:Item/item image files by item id.json]] - a mapping for item IDs to image files for these items. Can be a simple 1 to 1 mapping of item name to file name, or can have a whole config that allows to define multiple images per single ID (see sections below for more info). Used to add icons to items. | * [[Module:Item/item image files by item id.json]] - a mapping for item IDs to image files for these items. Can be a simple 1 to 1 mapping of item name to file name, or can have a whole config that allows to define multiple images per single ID (see sections below for more info). Used to add icons to items. | ||
* [[Module:Item/item page links by item ids.json]] - a 1 to 1 mapping of item IDs to page names. Used to turn items into links to their pages (or any other page on the wiki). | * [[Module:Item/item page links by item ids.json]] - a 1 to 1 mapping of item IDs to page names. Used to turn items into links to their pages (or any other page on the wiki). | ||
* [[Module:Item/sizes.json]] - a map of size lowercased size IDs to item sizes objects. | |||
== FAQ == | == FAQ == | ||
Line 29: | Line 31: | ||
=== Where to get item ID? === | === Where to get item ID? === | ||
From [[Module:Item/ | From [[Module:Item/data/auto/entity map of id to name.json]]. | ||
=== How to add icon to item? === | === How to add icon to item? === | ||
Line 91: | Line 93: | ||
=== How to add custom names to item? === | === How to add custom names to item? === | ||
When using {{t|item}}, you probably don't want to use item IDs because that's internal game info which is a pain in the ass to write. Gladly, there's an existing set of item names defined in [[Module:Item/ | When using {{t|item}}, you probably don't want to use item IDs because that's internal game info which is a pain in the ass to write. Gladly, there's an existing set of item names defined in [[Module:Item/data/auto/entity map of lc name to id.json]], which are human-readable. But not all existing items will have their names in there, because some names do repeat (for instance, various bottles named {{kbd|bottle}}). | ||
To add new cool names and have them not be erased on new update (which happens to the JSON file linked in previous paragraph), add them to [[Module:Item/item_ids_by_item_lowercase_names_overrides.json]]. These will have higher priority and will be used instead. You can define as much "aliases" for an item ID as you wish. | To add new cool names and have them not be erased on new update (which happens to the JSON file linked in previous paragraph), add them to [[Module:Item/item_ids_by_item_lowercase_names_overrides.json]]. These will have higher priority and will be used instead. You can define as much "aliases" for an item ID as you wish. | ||
Line 112: | Line 114: | ||
3. Save the file. | 3. Save the file. | ||
== Adding new sizes == | |||
{{Callout|Info|This section covers adding new size ''variations'', not sizes for ''specific items''.}} | |||
Sizes are defined the [[Module:Item/sizes.json]] file. | |||
Keys are lowercased size IDs, values are size objects. A key can also be an alias to another size ID, in which case its value must be another lowercased size ID defined elsewhere in the file. | |||
{| class="wikitable" | |||
|+ Size object | |||
|- | |||
! Key !! Type !! Description | |||
|- | |||
| {{c|weight}} || Integer || Weight that an item of that size would have. | |||
|- | |||
| {{c|size}} || Tuple (integer, integer) || The size (width, height). | |||
|- | |||
| {{c|display}} || String || The label that would be displayed when looking up this size. | |||
|} | |||
== TODO == | == TODO == |
Latest revision as of 07:14, 5 July 2025
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:
- Module:Item/data/auto/entity map of id to name.json - contains 1 to 1 mapping of item IDs to their names.
- Module:Item/data/auto/entity map of lc name to id.json - contains 1 to 1 mapping of item names (lowercase) to their IDs. If a name repeats for multiple items, only a single item ID will be defined here.
JSON files that are filled manually:
- Module:Item/item ids by item lowercase names overrides.json - a 1 to 1 mapping of item names (lowercase) to their IDs. This one has a higher priority than the other one, so it can be used to override existing name → ID mappings or create new ones.
- Module:Item/item image files by item id.json - a mapping for item IDs to image files for these items. Can be a simple 1 to 1 mapping of item name to file name, or can have a whole config that allows to define multiple images per single ID (see sections below for more info). Used to add icons to items.
- Module:Item/item page links by item ids.json - a 1 to 1 mapping of item IDs to page names. Used to turn items into links to their pages (or any other page on the wiki).
- Module:Item/sizes.json - a map of size lowercased size IDs to item sizes objects.
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/data/auto/entity map of id to name.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>"
"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:
"<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.
How to add custom names to item?
When using {{item}}, you probably don't want to use item IDs because that's internal game info which is a pain in the ass to write. Gladly, there's an existing set of item names defined in Module:Item/data/auto/entity map of lc name to id.json, which are human-readable. But not all existing items will have their names in there, because some names do repeat (for instance, various bottles named bottle).
To add new cool names and have them not be erased on new update (which happens to the JSON file linked in previous paragraph), add them to Module:Item/item_ids_by_item_lowercase_names_overrides.json. These will have higher priority and will be used instead. You can define as much "aliases" for an item ID as you wish.
Step-by-step: 1. Go to Module:Item/item_ids_by_item_lowercase_names_overrides.json.
2. Add a new line. Follow format: "<item lowercase name>": "<item ID>"
. Please note, that all items names defined here must be lowercase.
"emag": "EmagUnlimited"
3. Save the file.
How to add a link to item?
To make {{item}} behave like a link all the time, a page link needs to be established in Module:Item/item page links by item ids.json. Please note, if you need a one-time link, use the link parameter in the {{item}} template.
1. Go to Module:Item/item page links by item ids.json.
2. Add a new line. Follow format: "<item ID>": "<page name>"
.
"Protolathe": "Research_and_Development#Protolathe"
3. Save the file.
Adding new sizes
Sizes are defined the Module:Item/sizes.json file.
Keys are lowercased size IDs, values are size objects. A key can also be an alias to another size ID, in which case its value must be another lowercased size ID defined elsewhere in the file.
Key | Type | Description |
---|---|---|
weight |
Integer | Weight that an item of that size would have. |
size |
Tuple (integer, integer) | The size (width, height). |
display |
String | The label that would be displayed when looking up this size. |
TODO
- Ores are currently hardcoded into names overrides. Figure out a way to pull them from game resources. This is for Module:Item recipe.