I have a timer that controls an animation of dice and then yields the random dice number. This works fine when it is triggered from a mouse-down event and then waits for another mouse click. However, I want to have the timer activated from code when the computer is playing with me.
Here’s the problem. When the computer routine calls the timer, the animation works fine, but the dice number is returned before the animation is activated. When I put a msgbox into the code before it returns the dice value to the computer routine I get the correct number, but if I omit the msgbox then it returns O. Also the presence or absence of the msgbox affects where the timer mode is O (with msgbox) or 2 (without msgbox).
This is the function that activates the timer. It is called either from a mouse-down event in the same window or a method from a module. (The module contains the computer methods that imitate the mouse-down events)
if gDiceRoll=false then
'msgbox "Dice: "+str(groll)+" Mode: "+str(DiceTimer.mode) return gRoll
Here is the timer code:
[code] dim r as new random
dim n,i,w,h as integer
if count>10 then
Mac OS10.10.5 Xojo 2013 release 3.3 (I know, but I don’t program often enough to want to deal with all the redactions and deprecations for this old game of mine)