Module:Sandbox/BotAntony/GameText
Jump to navigation
Jump to search
Documentation
No documentation subpage exists yet for this module. Create one now.
local gameText = require('Module:GameText').getText
local keysData = mw.loadData('Module:GameText/loaddata-en').info
local function pairsByKeys(t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
local p = {}
function p.printTable(frame)
local firstLang = frame.args[1]
local secondLang = frame.args[2]
local result = { '{| class="terraria lined"', '! Key !! First language !! Second language' }
for mainKey, messages in pairsByKeys(keysData) do
result[#result + 1] = '|-\n! colspan="3" | <code>' .. mainKey .. '</code>'
for secondaryKey, _ in pairsByKeys(messages) do
result[#result + 1] = '|-'
local key = mainKey .. '.' .. secondaryKey
result[#result + 1] = '| <code>' .. key .. '</code>'
result[#result + 1] = '| ' .. (gameText(key, firstLang) or '')
result[#result + 1] = '| ' .. (gameText(key, secondLang) or '')
end
end
result[#result + 1] = '|}'
return table.concat(result, '\n')
end
return p