Module:Recipes: Difference between revisions

From Guinea Isles Wiki
No edit summary
No edit summary
Line 6: Line 6:
local p = {}
local p = {}


function p.get_recipe(frame)
function p._get_recipe(args)
local args = frame:getParent().args
local output_id = nil
local output_id = nil
if args["id"] ~= nil then
if args["id"] ~= nil then
Line 15: Line 13:
output_id = mw.title.getCurrentTitle()
output_id = mw.title.getCurrentTitle()
end
end
mw.log(data)
mw.log(output_id)
mw.log(data[output_id])
if data[output_id] ~= nil then
if data[output_id] ~= nil then
Line 20: Line 22:
end
end
mw.log(data)
mw.log(output_id)
mw.log(data[output_id])
return "No recipe found with id " .. tostring(output_id) .. "!"
return "No recipe found with id " .. tostring(output_id) .. "!"
end
function p.get_recipe(frame)
local args = frame:getParent().args
return p._get_recipe(args)
end
end


return p
return p

Revision as of 15:31, 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 = {}

function p._get_recipe(args)
	local output_id = nil
	if args["id"] ~= nil then
		output_id = args["id"]
	else
		output_id = mw.title.getCurrentTitle()
	end
	
	mw.log(data)
	mw.log(output_id)
	mw.log(data[output_id])
	
	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_recipe(frame)
	local args = frame:getParent().args
	return p._get_recipe(args)
end

return p