Module:Recipes: Difference between revisions
From Guinea Isles Wiki
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
-------------------------- | -------------------------- | ||
-- Module for crafting | -- Module for crafting recipe data | ||
------------------------ | ------------------------ | ||
local data = mw.loadJsonData('Module:Recipes/data.json') | local data = mw.loadJsonData('Module:Recipes/data.json') | ||
| Line 6: | Line 6: | ||
local p = {} | local p = {} | ||
function p. | function p.get_recipe(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
return data[ | local id = nil | ||
if args["id"] ~= nil then | |||
id = args["id"] | |||
else | |||
id = mw.title.getCurrentTitle() | |||
end | |||
if data[id] ~= nil then | |||
return data[id] | |||
end | |||
return nil | |||
end | end | ||
return p | return p | ||
Revision as of 14:39, 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 id = nil
if args["id"] ~= nil then
id = args["id"]
else
id = mw.title.getCurrentTitle()
end
if data[id] ~= nil then
return data[id]
end
return nil
end
return p