8,756
edits
(error handling) |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 25: | Line 25: | ||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
local gzdecode = zlib.gzdecode(zlib.base64_decode(code)) | local gzdecode = zlib.gzdecode(zlib.base64_decode(code)) | ||
if gzdecode == false then -- error handling | if gzdecode == false or gzdecode == nil then -- error handling | ||
error("This code isn't in base64. Please double check your input!") | error("This code isn't in base64. Please double check your input!") | ||
end | end | ||
local decoded = mw.text.jsonDecode() | local decoded = mw.text.jsonDecode(gzdecode) | ||
local version = decoded["gameversion"] | local version = decoded["gameversion"] | ||
Line 68: | Line 68: | ||
extNoun='Mutation' | extNoun='Mutation' | ||
end | end | ||
stats = decoded["modules"][statPos]["data"]["PointsPurchased"] | stats = decoded["modules"][statPos]["data"]["PointsPurchased"] | ||
-- No cybernetics means extra toughness | -- No cybernetics means extra toughness | ||
Line 145: | Line 144: | ||
end | end | ||
return p | return p |