Module:Item recipe

From Space Station 14 Wiki
Revision as of 14:09, 23 August 2024 by Aliser (talk | contribs) (Created page with "-- 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 cat...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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:

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