• 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!

[TFS 1.3] Dump all items with specified features

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
2,629
Best answers
3
Reaction score
1,572
Location
Poland
what it does: dumps the items you search for in case of planning a system based on a specific group of items (creature products in this case, can be also set to weapons or basically any item property you can obtain through lua)

example output:


example text output(fragment):
Code:
	1294, -- small stone
	2111, -- snowball
	2127, -- emerald bangle
	2134, -- silver brooch
	2143, -- white pearl
	2144, -- black pearl
	2145, -- small diamond
	2146, -- small sapphire
	2147, -- small ruby
	2148, -- gold coin
	2149, -- small emerald
	2150, -- small amethyst
	2151, -- talon
	2152, -- platinum coin
	2157, -- gold nugget
	2159, -- scarab coin
	2160, -- crystal coin
	2177, -- life crystal
usage: execute it any way you like

example (data/lib/lib.lua):
Lua:
addEvent(mapTiles, 6000)
function to add:
Lua:
function mapTiles()
    local lineLength = 15
    local startpos = {x = 1024, y = 1024, z = 7} -- dump start pos
    local pos = {x = startpos.x, y = startpos.y, z = startpos.z}
    local k = 0
    for i = 100, 30000 do -- items to move through, set a higher number if tibia 11+
        local it = ItemType(i)
        if it then
            if it:isMovable() and it:isPickupable() and it:isStackable() then -- item properties you search for
                k = k + 1
                Game.createTile(pos)
                Game.createItem(407, 1, pos)
                Game.createItem(i, 1, pos)
                pos.x = pos.x + 1
                if pos.x == startpos.x + lineLength then
                    pos.x = startpos.x
                    pos.y = pos.y + 1
                end
            end
        end
    end
    print(k) -- number of items dumped, will be displayed in server console
end
or a version with file output:
Lua:
function mapTiles()
    local f = io.open("items_output.txt", "w+")
    local lineLength = 15
    local startpos = {x = 1024, y = 1024, z = 7}
    local pos = {x = startpos.x, y = startpos.y, z = startpos.z}
    local k = 0
    for i = 100, 30000 do
        local it = ItemType(i)
        if it then
            if it:isMovable() and it:isPickupable() and it:isStackable() then
                f:write("    ".. i ..", -- " .. it:getName() .. "\n")
                k = k + 1
                Game.createTile(pos)
                Game.createItem(407, 1, pos)
                Game.createItem(i, 1, pos)
                pos.x = pos.x + 1
                if pos.x == startpos.x + lineLength then
                    pos.x = startpos.x
                    pos.y = pos.y + 1
                end
            end
        end
    end
    print(k)
    f:close()
end
 
Top