waqmaz
Member
- Joined
- Jun 17, 2015
- Messages
- 203
- Reaction score
- 11
What is the best way to check if player stand next to you? It doesn't need to be head to head, just one square to you. I need it, because I've done a new spell in lua and that spell works in every range, and it is for a knight, so it should be in 0 range.
There are some functions:
I am trying to check if cid x is +1 of target x using "getCreaturePosition(target)", but this way there is so much to do, lol.
There are some functions:
Code:
getCreaturePosition(target)
getClosestFreeTile(cid, targetpos[, extended = false[, ignoreHouse = true]])
Code:
local myPos = getCreaturePosition(cid)
local targetPos = getCreaturePosition(target)
if
myPos.x == targetPos.x+1 or
myPos.x == targetPos.x-1 or
myPos.y == targetPos.y+1 or
myPos.y == targetPos.y-1
then
print('player 1 square to you')
else
print('not 1 suare to you!')
end
Last edited: