Module:Recipes: Difference between revisions

From Guinea Isles Wiki
No edit summary
No edit summary
Line 25: Line 25:
function p.get_item_recipes(frame)
function p.get_item_recipes(frame)
local args = frame:getParent().args
local args = frame:getParent().args
return p._get_recipe(args)
return p._get_item_recipes(args)
end
end


return p
return p

Revision as of 15:50, 20 September 2025

Module:Recipes is a module designed around managing the data of in-game recipes of all kinds. It allows users to query Module:Recipes/data.json, which contains this information in JSON format.

Functions


--------------------------
-- Module for crafting recipe data
------------------------
local data = mw.loadJsonData('Module:Recipes/data.json')

local p = {}

-- Returns the entry in data.json with the corresponding id as a key.
-- id is the name of a Page. If no id is specified, uses current page's name as id. 
function p._get_item_recipes(args)
	local output_id = nil
	if args["id"] ~= nil then
		output_id = args["id"]
	else
		output_id = mw.title.getCurrentTitle().text
	end
	
	if data[output_id] ~= nil then
		return tostring(data[output_id])
	end
	
	return "No recipe found with id " .. tostring(output_id) .. "!"
end

function p.get_item_recipes(frame)
	local args = frame:getParent().args
	return p._get_item_recipes(args)
end

return p