17,097
edits
mNo edit summary |
mNo edit summary Tag: Undo |
||
Line 68: | Line 68: | ||
function p.getItemByID(ID) | function p.getItemByID(ID) | ||
local result = Shared.clone(ItemData.Items[ID + 1]) | |||
if result ~= nil then | |||
result.id = ID | |||
end | |||
return result | |||
end | end | ||
function p.getItem(name) | function p.getItem(name) | ||
local result = nil | |||
name = string.gsub(name, "%%27", "'") | name = string.gsub(name, "%%27", "'") | ||
name = string.gsub(name, "'", "'") | name = string.gsub(name, "'", "'") | ||
Line 83: | Line 82: | ||
local itemName = string.gsub(item.name, '#', '') | local itemName = string.gsub(item.name, '#', '') | ||
if name == itemName then | if name == itemName then | ||
result = Shared.clone(item) | |||
--Make sure every item has an id, and account for Lua being 1-index | --Make sure every item has an id, and account for Lua being 1-index | ||
result.id = i - 1 | |||
break | |||
end | end | ||
end | end | ||
return result | |||
end | end | ||
Line 98: | Line 96: | ||
for i, item in ipairs(ItemData.Items) do | for i, item in ipairs(ItemData.Items) do | ||
if checkFunc(item) then | if checkFunc(item) then | ||
local newItem = Shared.clone(item) | |||
newItem.id = i - 1 | |||
itemCount = itemCount + 1 | itemCount = itemCount + 1 | ||
result[itemCount] = | result[itemCount] = newItem | ||
end | end | ||
end | end |