2-timer trouble

I’m working on a board game. I have successfully enabled a timer to move computer player’s token on a mousedown event on a canvas. What I want to do is to have it move the token and THEN go to the subroutine that is determined by the x/y final position of the token. I have tried to have it go after the moves reach a maximum count. I have tried a separate timer for the subroutine. I have read all the timer info on the forum. I’m still not getting it right. It goes to the selected subroutine immediately (in the test case, a new window), without visually moving the token.

Here’s the mousedown event:

if gplayer<>0 then token=true count=0 tempToken=gThePlayers(gPlayer).position tToken.Mode=2 token=false tGame.mode=1 end

Here’s the first timer action:

count=count+1 if count=groll then me.Mode=0 end MoveToken

Here’s the second timer action:

count=count+1 if count=groll then me.Mode=0 end MoveToken

Will threads solve this?

Whoops, it pasted the wrong info for tGame timer. Here is the correct code:

ComputerPlay me.Mode=0

I think you want to set tGame.mode=1 in the action of the first timer, where you set me.mode=0 … as it’s written you’re telling them both to go at almost the same time (from the same method)

Jim is correct. Since the Timer Action fires during idle time, you can’t adequately control when each will fire even if you set the Period. But you can have one Timer start another.

However, I wonder why you need two Timers at all? Can’t you write the code of the first Timer like this?

  count=count+1
  if count=groll then
    ComputerPlay
    me.Mode=0
  else
    MoveToken
  end

And, does there really need to be a delay after MoveToken and before Computerplay?

count=count+1 MoveToken if count=groll then me.Mode=0 ComputerPlay end

Thank you your help. I have a better grasp on how timers work, now. Jim, your last suggestion worked the best. Thanks again.

when I saw the title “Two Timer”… I thought she was talking about a cheating boyfriend :slight_smile:

I thought it was a thread about my ex-wife.