I thought of checking constantly the location of the player and if it changes, but it would be very laggy I guess.
Forum




Player is moving?
6 replies



I thought of checking constantly the location of the player and if it changes, but it would be very laggy I guess.


And this is the only way to check this. Don't worry, it won't be laggy if you use one of these hooks. Good luck

Thanks anyway
Edit:
I found a way:
1
2
3
4
5
6
7
2
3
4
5
6
7
addhook("second","check") function check() 	for id = 1, 32 do 			chX[id]=player(id,"tilex") 			chY[id]=player(id,"tiley") 	end end
Is not really accurate but it works.
I tried with "ms100" but it's too quick, so when comparing they will always be equal.
Maybe the "ms100" could work when comparing with pixels position
edited 3×, last 29.12.13 10:06:21 pm
1
2
3
4
5
6
7
2
3
4
5
6
7
addhook("move","check") function check() for id = 1, 32 do chX[id]=player(id,"x") chY[id]=player(id,"y") end end

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
chX, chY = {}, {} addhook("move","OnMove") function OnMove(id) 	--// your remaining code here 	chX[id] = player(id,"x") 	chY[id] = player(id,"y") end --// simple true/false function checking if player is moving or not IsMoving = function(id) 	chX[id] = chX[id] or -100 	chY[id] = chY[id] or -100 	if chX[id] ~= player(id,"x") or chY[id] ~= player(id,"y") then 		return true 	end 	return false end

But I need to check if a player is moving to use it as a condition 

Are you sure of it? You could move the action that you need performed on player movement into a separate function, say, onMoveAction(id), and then you can just call it from a move hook, if not simply attach a move hook to it. To me, that seems to be the most effective way that doesn't involve any workarounds.


Instead of the pixel's position, I'll use the tile's position.
Thank you all who answered




