• 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.X+ What does getPosition() returns?

gudan garam

Advanced OT User
Joined
Feb 13, 2011
Messages
353
Solutions
17
Reaction score
173
Location
São Paulo.
Hey guys,

My question is probably very simple but I can't figure it out.

What does the getPosition() method returns? I'm using it on a creaturescripts and I don't know how to "var_dump" or "pretty print" the return of it.

Is this documented somewhere or do I have to read the sources in order to figure it out?
 
It returns a table: {x, y, z, stackpos}

For the next time to get better idea what you are dealing with try using:
Lua:
print(var)
print(type(var))
print_r(var)

print_r function used for "pretty printing" content of a table:
Lua:
function print_r(arr, indentLevel)
    local str = ""
    local indentStr = "#"

    if(indentLevel == nil) then
        print(print_r(arr, 0))
        return
    end

    for i = 0, indentLevel do
        indentStr = indentStr.."\t"
    end

    for index,value in pairs(arr) do
        if type(value) == "table" then
            str = str..indentStr..index..": \n"..print_r(value, (indentLevel + 1))
        else
            str = str..indentStr..index..": "..value.."\n"
        end
    end
    return str
end
 
Back
Top