Results 1 to 4 of 4

Thread: Why does this script require adding an extra second to work as intended?

  1. #1

    Question Why does this script require adding an extra second to work as intended?

    Code:
    function onLoad()
        self.setValue(120)
    end
    
    function onPlayerTurnStart()
        self.setValue(120)
        self.Clock.paused = false
    end
    So I have this script inside of a timer, though whenever it switches to someone's turn it starts counting down from 1:59 instead of 2:00.
    In order to make it work as intended, I'm needing to add a second to the setValue value from 120 to 121.

    So the second function becomes this:

    Code:
    function onPlayerTurnStart()
        self.setValue(121)
        self.Clock.paused = false
    end
    Why is this? Is this a bug or something I'm doing wrong here?

  2. #2
    Join Date
    Feb 2016
    Location
    Sweden
    Posts
    77
    Probably because the seconds are floored and not rounded, making it so the clock interprets 119.999 seconds as 119 seconds, i.e. 1:59.
    It could also be that the clock deducts 1 from it the same frame it's resumed.

    There are differing opinions on which way it's supposed to work, so I'm unsure if this is intended or not.

  3. #3
    Though if it were math.floored, it would display "0" for a second and then beep. In this case, immediately on "0" it beeps.

  4. #4
    Join Date
    Feb 2016
    Location
    Sweden
    Posts
    77
    It's probably the latter then.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •