Module:SoulUnlock: Difference between revisions

Sur (talk | contribs)
m localization support
Sur (talk | contribs)
m get_max example and parameters now support invoke options
Line 28: Line 28:
num = value  
num = value  
else
else
return "Module:SoulUnlockaccumulate() error, invalid value type"
return "Module:SoulUnlock.accumulate() error, invalid value type"
end
end
Line 53: Line 53:


function p.localize(soul_unlock_key)
function p.localize(soul_unlock_key)
-- If called internally (direct Lua call), args will be passed directly.
    -- If called from wikitext, `soul_unlock_key` will be the `frame` object, and we get args from `frame.args`.
    -- Handle the case where it's called via #invoke (i.e., from wikitext)
    if type(soul_unlock_key) == "table" and soul_unlock_key.args then
        local frame = soul_unlock_key
        soul_unlock_key = frame.args[1]
    end
localization_key = localization_map[soul_unlock_key]
localization_key = localization_map[soul_unlock_key]
if localization_key == nil then  
if localization_key == nil then  
Line 62: Line 71:
end
end


function p.write_accumulated(frame)
function p.write_accumulated()
ret = ""
ret = ""
for i, data in pairs(accumulated_data) do
for i, data in pairs(accumulated_data) do
Line 73: Line 82:
return ret
return ret
--return accumulated_data['0']['AbilityUnlocks']
--return accumulated_data['0']['AbilityUnlocks']
end
-- Retrieve a certain stat's value at max souls
function p.get_max(soul_unlock_key)
-- If called internally (direct Lua call), args will be passed directly.
    -- If called from wikitext, `soul_unlock_key` will be the `frame` object, and we get args from `frame.args`.
    -- Handle the case where it's called via #invoke (i.e., from wikitext)
    if type(soul_unlock_key) == "table" and soul_unlock_key.args then
        local frame = soul_unlock_key
        soul_unlock_key = frame.args[1]
    end
last_index = #accumulated_data
last_value = accumulated_data[last_index][soul_unlock_key]
return last_value
end
end


return p
return p