• 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 to print toPosition?

Fortera Global

Intermediate OT User
Joined
Nov 20, 2015
Messages
1,180
Solutions
2
Reaction score
117
Lua:
local positionVoc2 = toPosition
local descriptionVoc2 = string.format(
                '%d, %d, %d',
                positionVoc2.x, positionVoc2.y, positionVoc2.z
            )

no working when we move item inside our backpack (myself)
 
Just add a print(descriptionVoc2)??

I al tried this in a lua online and worked...
Code:
local positionVoc2 = {x = 12, y = 22, z = 7}
local format = "%d, %d, %d"
print(format:format(positionVoc2.x, positionVoc2.y, positionVoc2.z))
 
Lua:
local positionVoc2 = toPosition
local descriptionVoc2 = string.format(
                '%d, %d, %d',
                positionVoc2.x, positionVoc2.y, positionVoc2.z
            )

no working when we move item inside our backpack (myself)
string.format doesn't print, it just returns the formated string, you'll need a separate means to print the results such as print, io.write or one of the TFS functions/metamethods depending on the need.
Lua:
print(string.format("%d, %d, %d",1,2,3))
-- 1, 2, 3
 
string.format doesn't print, it just returns the formated string, you'll need a separate means to print the results such as print, io.write or one of the TFS functions/metamethods depending on the need.
Lua:
print(string.format("%d, %d, %d",1,2,3))

srry, its not for print, is for write:

Lua:
file:write(" .. descriptionVoc2 .. ")

I need something like, if its our backpack equiped then write:
Lua:
file:write("moved to his own backpack")
 
Just add a print(descriptionVoc2)??

I al tried this in a lua online and worked...
Code:
local positionVoc2 = {x = 12, y = 22, z = 7}
local format = "%d, %d, %d"
print(format:format(positionVoc2.x, positionVoc2.y, positionVoc2.z))
in your case it worked because you already set the specific position
 
This is incorrect, it should be:
Code:
file:write( descriptionVoc2 )
But that is only if you opened a file for writing.

I'm using more texts there, thats why

file:write("some text, " " .. descriptionVoc2 .. " ".")

the current script is writing something like toPos: 65535, 64, 2
 
I'm using more texts there, thats why

file:write("some text, " " .. descriptionVoc2 .. " ".")

the current script is writing something like toPos: 65535, 64, 2
To make the concat you have to do it outside the "" :

Code:
file:write("some text, " .. varToConcat .. ".")
 
omg guys, I only need to know how to print the position when the position is ourself (our backpack)
I see here its like something toPosition.y- 64 (our backpack equiped)
 
Think of it this way for every string that connects to something else such a variable 2 dots should link them.
So this
Lua:
ile:write("some text, " " .. descriptionVoc2 .. " ".")
becomes this
Lua:
file:write("some text, " .. descriptionVoc2 .. ".")
 
omg guys, I only need to know how to print the position when the position is ourself (our backpack)
I see here its like something toPosition.y- 64 (our backpack equiped)
We are trying to teach you something.. rather I am trying to teach you something but if you feel my efforts are a waste of your time I can find better things to do with mine.
 
Think of it this way for every string that connects to something else such a variable 2 dots should link them.
So this
Lua:
ile:write("some text, " " .. descriptionVoc2 .. " ".")
becomes this
Lua:
file:write("some text, " .. descriptionVoc2 .. ".")
this will print:

bdXkEDd.png
 
thanks guys, I solved

Lua:
local descriptionVoc2 = string.format(
                '%d, %d',
                positionVoc2.x-65535, positionVoc2.y-64
            )

this will write 0, 0 and I'll know it was moved to the backpack itself
 
position.x 65535 is the number for a container position (either inventory or inside of a container), you can also compare with the constant CONTAINER_POSITION which is defined as 65535
so you shouldn't be subtracting 65535 because it's a constant number and won't change as long as it isn't in the game world and is inside a player's inventory or a container item
position.y 64+ is for container id, the base number 64 + the id = position.y
position.z in a container is usually either
a. the inventory slot (if it's in your inventory)
b. the slot position in the container (3rd item in a backpack would be position.z = 2 since slots start from 0)
 
Back
Top