Módulo:Sandbox/BotAntony
Ir a la navegación
Ir a la búsqueda
La documentación para este módulo puede ser creada en Módulo:Sandbox/BotAntony/doc
local p = {}
local getData = require('Module:Iteminfo').getItemInfo
local gameText = require('Module:GameText').getText
local replace = {
["Shadow Orb"] = "Shadow Orb (item)",
["Fish"] = "Fish (item)",
["Enchanted Sword"] = "Enchanted Sword (item)",
["The Destroyer"] = "The Destroyer (item)",
["Darkness"] = "Darkness (Painting)",
["Crimson Heart"] = "Crimson Heart (item)",
["Oasis"] = "Oasis (Painting)",
["Graveyard"] = "Graveyard (Painting)",
}
local suffixes = {
-- add more if it's needed
["Shadow Orb (item)"] = "(objecto)",
["Fish (item)"] = "(objecto)",
["Enchanted Sword (item)"] = "(objecto)",
["Crimson Heart (item)"] = "(objecto)",
}
function spairs(t, order)
-- collect the keys
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
-- if order function given, sort by it by passing the table and keys a, b,
-- otherwise just sort the keys
if order then
table.sort(keys, function(a,b) return order(t, a, b) end)
else
table.sort(keys)
end
-- return the iterator function
local i = 0
return function()
i = i + 1
if keys[i] then
return keys[i], t[keys[i]]
end
end
end
function p.genItems()
local result = {}
local output = { '<pre>', '-- Items data' }
for i = 1, 5455 do
local itemInfo = getData(i)
local name = itemInfo['name']
local iName = itemInfo['internalName']
if name and name ~= '' then
result[#result + 1] = { name = (replace[name] or name), id = i, iName = iName }
end
end
for _,v in spairs(result, function(t, a, b) return t[b]["name"] > t[a]["name"] end) do
local lname = gameText('ItemName.' .. (v['iName'] or 'None'), 'es')
if suffixes[v["name"]] then
lname = lname .. ' ' .. suffixes[v["name"]]
end
output[#output + 1] = '["' .. v["name"] .. '"] = "' .. lname .. '",'
end
output[#output + 1] = '</pre>'
return table.concat(output, '\n')
end
return p