17,105
edits
Tag: Undo |
(getItemByID/getItem/getItems: Prevent cloning of items in an attempt to conserve memory; getSpecialAttackTable: Remove unused function) |
||
Line 68: | Line 68: | ||
function p.getItemByID(ID) | function p.getItemByID(ID) | ||
return ItemData.Items[ID + 1] | |||
end | end | ||
function p.getItem(name) | function p.getItem(name) | ||
name = string.gsub(name, "%%27", "'") | name = string.gsub(name, "%%27", "'") | ||
name = string.gsub(name, "'", "'") | name = string.gsub(name, "'", "'") | ||
for i, item in | for i, item in ipairs(ItemData.Items) do | ||
local itemName = string.gsub(item.name, '#', '') | local itemName = string.gsub(item.name, '#', '') | ||
if name == itemName then | if name == itemName then | ||
return item | |||
end | end | ||
end | end | ||
return | return nil | ||
end | end | ||
function p.getItems(checkFunc) | function p.getItems(checkFunc) | ||
local result = {} | local result = {} | ||
for i, item in | local itemCount = 0 | ||
for i, item in ipairs(ItemData.Items) do | |||
if checkFunc(item) then | if checkFunc(item) then | ||
itemCount = itemCount + 1 | |||
result[itemCount] = item | |||
end | end | ||
end | end | ||
Line 250: | Line 242: | ||
local item = p.getItem(itemName) | local item = p.getItem(itemName) | ||
if item == nil then | if item == nil then | ||
return "ERROR: No item named ".. | return "ERROR: No item named "..itemName.." exists in the data module[[Category:Pages with script errors]]" | ||
end | end | ||
return p._getWeaponAttackType(item) | return p._getWeaponAttackType(item) | ||
Line 425: | Line 417: | ||
end | end | ||
table.insert(resultPart, '\r\n|}') | table.insert(resultPart, '\r\n|}') | ||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | end |