Module:Recipes: Difference between revisions
From Guinea Isles Wiki
m Protected "Module:Recipes" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) |
No edit summary |
||
| Line 10: | Line 10: | ||
local output_id = nil | local output_id = nil | ||
if args[" | if args["id"] ~= nil then | ||
output_id = args[" | output_id = args["id"] | ||
else | else | ||
output_id = mw.title.getCurrentTitle() | output_id = mw.title.getCurrentTitle() | ||
| Line 17: | Line 17: | ||
if data[output_id] ~= nil then | if data[output_id] ~= nil then | ||
return data[output_id] | return tostring(data[output_id]) | ||
end | end | ||
Revision as of 14:51, 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(frame)
local args = frame:getParent().args
local output_id = nil
if args["id"] ~= nil then
output_id = args["id"]
else
output_id = mw.title.getCurrentTitle()
end
if data[output_id] ~= nil then
return tostring(data[output_id])
end
return "No recipe found with id " .. tostring(output_id)
end
return p