Page 1 of 1

Need help getting a timer to work

Posted: Tue Jun 28, 2011 10:31 pm
by Mushroomstamp
I'm trying to get a timer to work as referenced here;
http://www.solarstrike.net/phpBB3/viewt ... r&start=20
But character never runs backward.

Code: Select all

<!-- #  1 --><waypoint x="2226" z="2489" y="401">	
	targetObj = player:findNearestNameOrId("Okander \"Mad Man\" Mallen")
	player:target(targetObj)
	player:update()	
	player:cast("WARRIOR_SURPRISE_ATTACK")
	_t = os.time()
</waypoint>

Code: Select all

<onSkillCast>
	if _t ~= nil then
		leaptime = os.difftime(os.time(), _t)
		if ( leaptime > 24000 and 28000 > leaptime ) then
			keyboardHold( settings.hotkeys.MOVE_BACKWARD.key )
			yrest(4000)
			keyboardPress(key.VK_SPACE)
			yrest(500)
			keyboardRelease( settings.hotkeys.MOVE_BACKWARD.key )
		else
			print(_t)
		end
	end
</onSkillCast>
Shouldn't the value from print(_t) change during the fight?

Re: Need help getting a timer to work

Posted: Tue Jun 28, 2011 11:24 pm
by rock5
No, _t is the start time so it doesn't change. What should have been printed was the "leaptime". If you did you would have seen that the printed value was in seconds, not miliseconds, and yes I'm aware that I wrote it like that. I'm not infalible. :D

Try,

Code: Select all

      if ( leaptime > 24 and 28 > leaptime ) then