Do you really need to search them on startup? Maybe you can search them in the map editor?
And what do you mean by "unnamed" - do you mean items that doesn't have the "name" attribute in items.xml?
<talkaction words="/scan" separator=" " script="scanfloor.lua"/>
local function scan_floor(dimensions, floorid)
local position = Position(0, 0, floorid)
local ret = {}
for x = 1, dimensions.x do
for y = 1, dimensions.y do
position.x = x
position.y = y
local tile = Tile(position)
if tile then
local items = tile:getItems()
if items and #items > 0 then
for i = 1, #items do
local item = items[i]
if item:getDescription():match("an item of type %d+") then
local id = item:getId()
if not ret[id] then
ret[id] = string.format("Unregistered item id %d at position (%d, %d, %d)", id, x, y, floorid)
end
end
end
end
end
end
end
return ret
end
function onSay(player, words, param)
local params = param:split(",")
local dimensions = {x = tonumber(params[1]), y = tonumber(params[2])}
if not dimensions.x or not dimensions.y or #params < 3 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Usage: /scan <dimension x>, <dimension y>, <floor ids>\nExample: /scan 2048, 2048, 7, 8")
return false
end
for i = 3, #params do
local floorid = tonumber(params[i])
if not floorid then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Usage: /scan <dimension x>, <dimension y>, <floor ids>\nExample: /scan 2048, 2048, 7, 8")
return false
end
local items = scan_floor(dimensions, floorid)
for id, description in pairs(items) do
print(description)
end
end
return false
end
/scan 2048, 2048, 7
/scan 2048, 2048, 7, 8, 9, 10
XML:<talkaction words="/scan" separator=" " script="scanfloor.lua"/>LUA:local function scan_floor(dimensions, floorid) local position = Position(0, 0, floorid) local ret = {} for x = 1, dimensions.x do for y = 1, dimensions.y do position.x = x position.y = y local tile = Tile(position) if tile then local items = tile:getItems() if items and #items > 0 then for i = 1, #items do local item = items[i] if item:getDescription():match("an item of type %d+") then local id = item:getId() if not ret[id] then ret[id] = string.format("Unregistered item id %d at position (%d, %d, %d)", id, x, y, floorid) end end end end end end end return ret end function onSay(player, words, param) local params = param:split(",") local dimensions = {x = tonumber(params[1]), y = tonumber(params[2])} if not dimensions.x or not dimensions.y or #params < 3 then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Usage: /scan <dimension x>, <dimension y>, <floor ids>\nExample: /scan 2048, 2048, 7, 8") return false end for i = 3, #params do local floorid = tonumber(params[i]) if not floorid then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Usage: /scan <dimension x>, <dimension y>, <floor ids>\nExample: /scan 2048, 2048, 7, 8") return false end local items = scan_floor(dimensions, floorid) for id, description in pairs(items) do print(description) end end return false end
example:
scans floor 7 within a 2048x2048 range for unknown idsCode:/scan 2048, 2048, 7
does the same as above but scans floors 7, 8, 9 and 10Code:/scan 2048, 2048, 7, 8, 9, 10