Firetron’s TrueOnInterval

1 131 Views 1 Comment 2 months ago
  • Returns true every interval and false in between intervals.

    HaasScript Code
    --  ==========================================================================================================
    --    Firetron's TrueOnInterval
    --
    --    Returns true every interval and false in between intervals.
    --
    --    Discord:  @FiretronP75
    --    BTC Tips: 14WLDZsrhshcP6qvBarKW8ABACv3iUXEro
    --    ETH Tips: 0xfaaac99fbf11f8f4abc4b3bf079cb2c7a43b5f87
    --  ==========================================================================================================
    
    --  ========================================================
    --    Definition
    --  ========================================================
    
    DefineCommand('TrueOnInterval', 'Returns true every interval and false in between intervals.')
    
    --  ========================================================
    --    Parameters
    --  ========================================================
    
    local interval = DefineParameter(NumberType, 'interval', 'The interval at which true should be returned instead of false.', true, 1, 'InputInterval')
    
    --  ========================================================
    --    Functions
    --  ========================================================
    
    local GetTrigger = function()
    
      local trigger = Load('trigger', true)
    
      Save('trigger', not trigger)
    
      return trigger
    
    end
    
    --  ========================================================
    --    Output
    --  ========================================================
    
    local trigger = Load('trigger', true)
    
    local output = trigger == OptimizedForInterval(interval, GetTrigger)
    
    DefineOutput(BooleanType, output, 'true every interval and false in between intervals')
    • #1155
      Firetron
      Basic
      Up
      1
      Down

      How to use this:

      if CC_TrueOnInterval(60) then
        Log('An hour has passed')
      else
        Log('An hour has not passed yet')
      end
      
Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free