Module:Item recipe
From Space Station 14 Wiki
Module documentation
|
---|
View or edit this documentation • (about module documentation) |
Implements {{item recipe}}.
JSON files
JSON files that are updated automatically, syncing with the upstream:
- Module:Item recipe/recipes by recipe IDs.json - contains 1 to 1 mapping of recipe IDs to recipes.
- Module:Item recipe/recipe IDs by product IDs.json - contains mapping of recipe products to recipe IDs that produce these...products. Can be 1 to 1, or 1 to many.
- Module:Item recipe/recipe IDs by method and availability.json - contains a mapping of recipe production methods (e.g. Autolathe) to → availability (condition under which a recipe is available for this production method) to → recipe IDs.
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:
- Module:Item recipe/order of materials.json - a 1 to 1 mapping of recipe materials to order at which they appear in recipes. Less number = higher order. Materials that do not have an order defined here, will appear after those that do.
- Module:Item recipe/product overrides.json - a 1 to 1 mapping of recipe products to item IDs. Not all products are the same as item IDs they "represent", so sometimes a connection needs to be established explicitly.
-- Contains utilities for working with in-game items.
local p = {} --p stands for package
local getArgs = require('Module:Arguments').getArgs
-- A table containing item recipes, identified by recipe IDs.
local recipes_by_recipe_id = mw.loadJsonData("Module:Item recipe/recipes by recipe id.json")
-- A table containing item recipe categories, identified by recipe category IDs.
local recipy_categories_by_recipe_category_id = mw.loadJsonData("Module:Item recipe/recipy categories by recipe category id.json")
function assert_value_not_nil(value, error_message)
if value == nil then
if error_message == nil then
error("value is nil")
else
error(error_message)
end
end
end
-- Generates a list of items needed for a recipe, along with exact amounts.
-- Needs a recipe ID passed as a single frame argument.
-- Uses {{Item}} to produce the items. Returns a div containing them.
function p.generate_recipe_items(frame)
local recipe_id = args[1]
assert_value_not_nil(recipe_id, "recipe ID was not provided")
end
return p