• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua how check isladder?

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
586
Solutions
1
Reaction score
58
i want:

if getItemAttribute(itemEx.uid,'floorchange')== "north" then
doSendMagicEffect(toPosition,2)
doPlayerSendCancel(cid,"Sorry, not possible.")
return true
end

or:
if getItemAttribute(itemEx.uid,'floorchange')== true then
doSendMagicEffect(toPosition,2)
doPlayerSendCancel(cid,"Sorry, not possible.")
return true
end

but dont work :/

no error on console
 
Because north is a direction in the -y, but a ladder or staircase works in the + or - z

Why not print(getItemAttribute(itemEx.uid,'floorchange')) to see what value it returns?

You'll see the output in the server console.
 
is value null.

want check this:
<attribute key="floorchange" />

no way to read from items.xml ?
 
i try, only now, no work :/
attribute key

function getItemIsLadder(itemId)

local file = io.open("data/items/items.xml", "r")

for info in string.gmatch(file:read("*a"), "<items(.-)</items>") do
if info:match("item id=\"(.-)\"") == itemId then
local attribute key = info:match("attribute key=(.-)")
return tostring(attribute key)
end
end

file:close()
return nil
end
 
getItemAttribute doesn't exist in tfs 1.0 so i can't even check it for you :(

Wrong, item attributes are now supported in tfs 1.x, maybe not that exact function, but it could be easily written in lua for compat or global and made into a function, at any rate, the attribute key floorchange is not supported...
 
Item attributes have always been supported, even in 0.2.
The only thing that isn't supported is custom attributes, which you can still get around in 1.X by using the TEXT attribute.
 
Wrong, item attributes are now supported in tfs 1.x, maybe not that exact function, but it could be easily written in lua for compat or global and made into a function, at any rate, the attribute key floorchange is not supported...
"maybe not that exact function"
Didn't I just say that the function doesn't exist?
Meaning I can't test it, whether there is another way to get an items attributes is irrelevant and saying "Wrong" or "it could be easily written" without actually giving an example makes you sound like a conceited arrogant a-hole.
 
yes i try and no work bro.

need this function: how repair?

function getItemIsLadder(itemId)

local file = io.open("data/items/items.xml", "r")

for info in string.gmatch(file:read("*a"), "<items(.-)</items>") do
if info:match("item id=\"(.-)\"") == itemId then
local attribute key = info:match("attribute key=(.-)")
return tostring(attribute key)
end
end

file:close()
return nil
end
 
"maybe not that exact function"
Didn't I just say that the function doesn't exist?
Meaning I can't test it, whether there is another way to get an items attributes is irrelevant and saying "Wrong" or "it could be easily written" without actually giving an example makes you sound like a conceited arrogant a-hole.

No you are wrong, simply because we do not know if someone has written that function or not is irrelevant, by saying that function doesn't exist means you are mistaken, because before I even posted I could have sat there, and taken the time to write it myself and then have that function in less than two minutes. I wasn't trying to be an asshole, I was merely trying to inform anyone who thinks that server is still missing that functionality knows that it is now supported (since I know that was a major thing that kept people from wanting to switch).

@topic, did you try printing the value returned on a ladder when using the function that ninja posted? If so, I'm interested in what it returned?
 
It returns an array of floor changes.

Code:
local function getItemIsLadder(itemId)
    local floor = getItemInfo(itemId).floorChange
    for i = 1, #floor do
        if floor[i] then
            return true
        end
    end
    return false
end
 

Similar threads

Back
Top