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:GameInfo/Skills: Difference between revisions

From SpiritVale Wiki
Created page with "-- Module:GameInfo/Skills -- Phase 4.1: Skills renderer (components live here; CSS/JS shared globally). local p = {} local GI = require("Module:GameInfo") local _file_exists_cache = {} local function _trim(s) if s == nil then return "" end s = tostring(s) s = s:gsub("^%s+", ""):gsub("%s+$", "") return s end local function _safe_tbl(t) return type(t) == "table" and t or {} end local function _safe_str(s, fallback) s = _trim(s) if s == "" then return fallback..."
 
No edit summary
Line 37: Line 37:
if s == "" then s = "item" end
if s == "" then s = "item" end
return s
return s
end
-- -----------------------------------------------------------------------------
-- COMPAT / ARG + JSON HELPERS
-- -----------------------------------------------------------------------------
local function _get_arg(frame, key)
-- Prefer direct args, but allow parent args (compat with routers/wrappers).
local args = frame and frame.args or {}
local v = _trim(args[key])
if v ~= "" then return v end
local parent = frame and frame.getParent and frame:getParent() or nil
local pargs = parent and parent.args or {}
v = _trim(pargs[key])
if v ~= "" then return v end
return ""
end
local function _strip_wrappers(raw)
raw = _trim(raw)
if raw == "" then return "" end
-- Common wrappers when people paste big blobs.
raw = raw:gsub("^<nowiki>%s*", ""):gsub("%s*</nowiki>%s*$", "")
raw = raw:gsub("^<pre>%s*", ""):gsub("%s*</pre>%s*$", "")
raw = raw:gsub("^<syntaxhighlight[^>]*>%s*", ""):gsub("%s*</syntaxhighlight>%s*$", "")
return _trim(raw)
end
end


local function _decode_json(raw)
local function _decode_json(raw)
raw = _trim(raw)
raw = _strip_wrappers(raw)
if raw == "" then return nil, "missing data" end
if raw == "" then return nil, "missing data" end
local ok, decoded = pcall(mw.text.jsonDecode, raw)
local ok, decoded = pcall(mw.text.jsonDecode, raw)
if not ok then
if not ok then