Anonymous

Module:Sandbox/Items: Difference between revisions

From Melvor Idle
m
no edit summary
(Repoint to sandbox modules)
mNo edit summary
Line 68: Line 68:


function p.getItemByID(ID)
function p.getItemByID(ID)
local result = Shared.clone(ItemData.Items[ID + 1])
--local result = Shared.clone(ItemData.Items[ID + 1])
if result ~= nil then
--if result ~= nil then
result.id = ID
-- result.id = ID
end
--end
return result
--return result
return ItemData.Items[ID + 1]
end
end


function p.getItem(name)
function p.getItem(name)
local result = nil
--local result = nil
name = string.gsub(name, "%%27", "'")
name = string.gsub(name, "%%27", "'")
name = string.gsub(name, "'", "'")
name = string.gsub(name, "'", "'")
Line 82: Line 83:
local itemName = string.gsub(item.name, '#', '')
local itemName = string.gsub(item.name, '#', '')
if name == itemName then
if name == itemName then
result = Shared.clone(item)
return item
--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
--result.id = i - 1
break
--break
end
end
end
end
return result
--return result
end
end


Line 96: Line 98:
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)
--local newItem = Shared.clone(item)
newItem.id = i - 1
--newItem.id = i - 1
itemCount = itemCount + 1
itemCount = itemCount + 1
result[itemCount] = newItem
result[itemCount] = item
end
end
end
end