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

Lua getCreaturePos x|y|z + 1

Sherice

Sky&Wind
Joined
Jan 20, 2012
Messages
183
Reaction score
7
Location
Sweden
Hello!

I want to know if you can... Like:

Code:
getCreaturePosition(cid) x+1 <--- this
Well, what I want is to get a creatures position and add it by one, for example teleport a creature to "getCreaturePosition", and add the position by one x, y or z.


Thanks in advance, Sherice =)
 
Hmm, how do I do this in an "if"?
just for example:

Code:
if getCreaturePosition(cid) == newPos then ...

I tried writing "newPos.x = newPos.x + 1" behind and in front of it, but it looks like it doesn't read it.
Do I need a local or what?



Thanks again, Sherice.
 
Lua stores tables seperately, if you run
Code:
print(newPos)
etc, it'll return some random table hash which will identify it. You can not compare two tables like that.

Alternatively you can compare x, y and z (eventually the stackpos).
Code:
local cpos = getCreaturePosition(cid);
if (cpos.x == newPos.x and cpos.y == newPos.y .........) then
 
So I can't do for example(again lol):

Code:
(if getTileThingByPos(cpos.x + 1) == newPos.x)
?

Not sure I understand everything you said, what is "print(newPos)"?

I'm still new to lua :p
 
In many languages 'print' is used to show yourself debug information. It also works for TFS.
Running "local a = "hi"; print(a);" will put "hi" in the console.
For tables it'll just return their unique identifier, which are compared while using the == operator and as so not the same.

You CAN do if (getCreaturePosition(cid).x == newPos.x) then .. but NOT if (getCreaturePosition(cid) == newPos) since that'll compare their unique identifiers which are unlikely the same. (You can try the 2nd one, but it won't give the result you want..)
 
Back
Top