Jump to content

timer.scheduleFunction broken as of 2.8.0.32235


Go to solution Solved by jross194,

Recommended Posts

Posted (edited)

Code in my script that was working perfectly this afternoon prior to the latest 'hot fix' now no longer runs.

function TRMS:StartCountdownForMinutesWithCompletionFlag(minutes, completionFlag)

  if (type(minutes) ~= "number")
  or (minutes < 0)
  or (type(completionFlag) ~= "string")
  or (completionFlag == "") then
  
    self:LogWrite("TRMS", "INFO", "Invalid parameters in function: StartCountdownForMinutesWithCompletionFlag")

    return

  end

  local endTime = timer.getTime() + ( minutes * 60 )

  self.countDownParams = {}

  table.insert(self.countDownParams, endTime)
  table.insert(self.countDownParams, completionFlag)

  timer.scheduleFunction(TRMS.DisplayCountdown, TRMS, timer.getTime())

end



function TRMS:DisplayCountdown(time)
  
  self:LogWrite("TRMS", "INFO", "DisplayCountdown")
  
  local endTime          = self.countDownParams[1]
  local flag             = self.countDownParams[2]
  local duration         = endTime - time

  local durationAsString = ""

  if self.stopCountdown == false then

     if duration > 0 then

      if duration > 60 then

        local minutes = math.floor( ( (duration %3600 ) / 60 ) )
        duration = duration % 3600
        local seconds = duration

        durationAsString = string.format("Countdown: %02dm %02ds", minutes, seconds)

      else

        durationAsString = string.format("Countdown: %02ds", duration)

      end

      trigger.action.outText(durationAsString, 1, true)

      return time + 1

    else

      trigger.action.setUserFlag(flag, true)

      return nil

    end

  else

    self.stopCountdown = false

    return nil

  end

end

That line now no longer does anything. The function named (DisplayCountdown) doesn't get called. (the log line: self:LogWrite("TRMS", "INFO", "DisplayCountdown")) doesn't write out. There is nothing wrong with the logging as all other log lines work fine. 

Edited by Elphaba
  • Solution
Posted

FWIW, I've had issues with scheduleFunction() working UNLESS I added some amount of time to it, never 0 seconds. Was intermittent enough that I just started adding it by habit. Not sure this is correct procedure though.

My take on it was, by the time DCS did "Other Things" and got back to your fxn call that time has come and gone and that call was 'purged'. Basically it must be some amount of time > timer.getTime(), even if only, say, 0.01 - I have routines that splice multiple calls to this fxn, one right after the other in essence, and I have to have _some_ amount of time here or they get 'skipped'.

This is going back to DCS 2.5, so try this:

timer.scheduleFunction(TRMS.DisplayCountdown, TRMS, timer.getTime() + 1)
  • Thanks 1

i6700k 4.4mhz, 32Gb, nVidia 1080, Odyssey+, CH Products, Derek Speare Designs button box, Bass shaker w/SimShaker For Aviators

Posted (edited)
27 minutes ago, jross194 said:

FWIW, I've had issues with scheduleFunction() working UNLESS I added some amount of time to it, never 0 seconds. Was intermittent enough that I just started adding it by habit. Not sure this is correct procedure though.

My take on it was, by the time DCS did "Other Things" and got back to your fxn call that time has come and gone and that call was 'purged'. Basically it must be some amount of time > timer.getTime(), even if only, say, 0.01 - I have routines that splice multiple calls to this fxn, one right after the other in essence, and I have to have _some_ amount of time here or they get 'skipped'.

This is going back to DCS 2.5, so try this:

timer.scheduleFunction(TRMS.DisplayCountdown, TRMS, timer.getTime() + 1)

Okay, I'll try that now. Thanks! I'll report back.

 

That fixed it!  Thank you! 

Edited by Elphaba
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...