Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Timer Toggle

KresslackKresslack Florida, United StatesMember Posts: 6,301 @@ - Legendary Achaean
edited May 2013 in Tech Support
How would one go about making a toggable tigger, which is turned on and off using an alias, such as TN | TF? Any help would be greatly appreciated. 




Misspelled titles make me cry.


Post edited by Gaia on

Comments

  • DaeirDaeir AustraliaMember Posts: 6,288 @@ - Legendary Achaean
    Have a state checking var (timerOn or something) tied into a function that runs continuously within a timer, and have an alias which toggles this value like so:

    Timer

    if timerOn then
    --do shit
    end

    ---

    (tn) Toggles timer function
    ^tn$

    if timerOn then
    timerOn = false
    echo("Not doing timer shit anymore yo")
    else
    timerOn = true
    echo("Doing timer shit now yo")
    end

    Or if I'm completely off the mark and you simply want an alias to disable a trigger, then enableTrigger and disableTrigger are what you are after, assuming you use mudlet.
  • JonathinJonathin Grand Rapids, MIMember Posts: 3,323 @@ - Legendary Achaean
    edited May 2013
    Instead of having the timer run indefinitely, you could always use enable/disableTimer()

    Alternatively, if you don't want to use a variable you can use isActive().

    Example:

    if isActive("timerName","timer") == 1 then  --1 because isActive returns as 0 or 1
      disableTimer("timerName")
      echo("timerName disabled!")
    else
     enableTimer("timerName")
     echo("timerName enabled!")
    end

    My site will remain up, but will not be maintained. The repository will continue to have scripts added to it if I decide to play another game. Maybe I'll see you around in Starmourn!
    Tutorials and scripts  The Repository

  • DaeirDaeir AustraliaMember Posts: 6,288 @@ - Legendary Achaean
    Does lua evaluate 0/1 as true/false like other C languages? A bit unrelated, but you should just be able to use isActive without the equals evaluation.
  • EldEld Member Posts: 3,946 @@ - Legendary Achaean
    Daeir said:
    Does lua evaluate 0/1 as true/false like other C languages? A bit unrelated, but you should just be able to use isActive without the equals evaluation.
    Lua evaluates false and nil as false and anything else (including 0) as true.
    Daeir
  • IocunIocun Member Posts: 3,506 @@ - Legendary Achaean
    Yeah. isActive() actually returns a count of active aliases/triggers/timers by that name, not a boolean value. It would return 2 if you had two timers by that name.
    VadimusesJonathin
  • JonathinJonathin Grand Rapids, MIMember Posts: 3,323 @@ - Legendary Achaean
    My bad. I don't have more than 1 of anything with a particular name, so it's always returned 0 or 1 for me. Good to know though.

    My site will remain up, but will not be maintained. The repository will continue to have scripts added to it if I decide to play another game. Maybe I'll see you around in Starmourn!
    Tutorials and scripts  The Repository

  • KresslackKresslack Florida, United StatesMember Posts: 6,301 @@ - Legendary Achaean
    Completely forgot about this, but thanks for all the advice. About to try it out.


Sign In to Comment.