• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

How I search

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
How I can search all item unamed on my map in startUp?

tfs 12
 
Last edited by a moderator:
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?
 
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?

Example: You see an item type 28282 ....

I want to search for items that I have not registered in items.xml that are scattered across all the map
 
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:
Code:
/scan 2048, 2048, 7
scans floor 7 within a 2048x2048 range for unknown ids
Code:
/scan 2048, 2048, 7, 8, 9, 10
does the same as above but scans floors 7, 8, 9 and 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:
Code:
/scan 2048, 2048, 7
scans floor 7 within a 2048x2048 range for unknown ids
Code:
/scan 2048, 2048, 7, 8, 9, 10
does the same as above but scans floors 7, 8, 9 and 10

my map size is:

Map size: 33760x33023

so I need use:

/scan 33760, 33023, 7 ? thanks

I got 100% CPU
Screenshot
 
Edit:
I used little dimensions and dont freeze the tfs

but dont appear the prints... one item in my sqm dont appear too

09:28 You see an item of type 29834.
 
Back
Top