Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Join the Playtest on Steam Now: SpiritVale

Module:Definitions: Difference between revisions

From SpiritVale Wiki
No edit summary
Tags: Reverted Mobile edit Mobile web edit
No edit summary
Tags: Reverted Mobile edit Mobile web edit
Line 67: Line 67:
if DB ~= nil then return DB end
if DB ~= nil then return DB end


-- Preferred: Scribunto JSON loader (reliable for Module:*.json pages)
local ok, obj = pcall(mw.loadJsonData, DATA_TITLE)
if ok and type(obj) == "table" then
DB = obj
return DB
end
-- Fallback: raw content + jsonDecode (kept for safety)
local title = mw.title.new(DATA_TITLE)
local title = mw.title.new(DATA_TITLE)
if not title then
if not title then
Line 79: Line 87:
end
end


local ok, obj = pcall(mw.text.jsonDecode, raw)
local ok2, obj2 = pcall(mw.text.jsonDecode, raw)
if not ok or type(obj) ~= "table" then
if not ok2 or type(obj2) ~= "table" then
DB = {}
DB = {}
return DB
return DB
end
end


DB = obj
DB = obj2
return DB
return DB
end
end