[Fixed] Basic Tutorial 3: UI, Timer does not stop

Following the tutorial, I am unable to make the Timer stop counting down. Looking at the script it looks like there is a return in an ‘if’ statement that is commented out. Making it actually return does not change the behavior, the timer still does not end. I am not really sure why, I have added debug printfs and do see that the stop function is being called and setting the value of the flag correctly, but in the tick handling code the flag is still true. Not sure if this is a script bug, or Crayta bug, or just pilot error, but I am fairly sure I followed the tutorial directions, so at the very least those directions should be clarified.

i have the same issue.

if the autostart box is checked or unchecked, the timer still starts to count down.

in advanced mode.

TimerScript
line 30
-- return

should read

return

I did do that, but even so, after calling StopTimer(), the timer continues to count down.

it fixed the autostart problem i had. i’m looking deeper into it. i’m no lua guy btw.

I basically gave up :slight_smile: This seems like a hacky way to do the scripting, mainly just for Basic mode. I am guessing the problem has something to do with creating an in game entity to attach the script to - I expect the properties are somehow getting confused. I think the more correct way to do this is use world based scripts in advanced mode (not sure what they are called), so I decided to move on.

Hey guys, reporting a possible fix from the discord from a user: Mad_Jackpot. Mind checking it out and seeing if if works for you all?

  1. Change ClientInit to Init. This will make it start up on the client side.
  2. Change ClientOnTick to OnTick.
  3. Update the function UpdateTimer to take in a parameter ‘duration’. Replace all instances of self.duration with this new duration parameter.
  4. Replace all calls to self:UpdateTimer with self:SendToAllClients(“UpdateTimer”, self.duration)

Yup, that works! I was curious about the ClientInit vs Init.

1 Like

I’ve just bugged this up, we’ll update the tutorial with a working script.

Or, alternatively, fix it like this:

function TimerScript::StopTimer ()
    self:GetEntity():SendToAllClients("onSetTimerRunning", false)
end

function TimerScript::onSetTimerRunning(value)
    self.timerRunning = value
end

Just spent an hour banging my head against this trying to get the timer to stop.
Please either remove this tutorial or fix the package as it’s really really annoying!

The Danger Dash package has now been updated and this issue has been fixed.