Variables in Event?

Hot

New Member
Reaction score
9
Is there a way to use Variables in Events?

Example:
Code:
- Event Every Intger seconds
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
You can't, not directly. There are other ways to accomplish that goal:

For a constant period, use another trigger that runs on Map Initialization that starts a repeating countdown timer, and give the periodic trigger the event that the countdown timer expires.

For a varying period, use two events on the periodic trigger - Map Initialization and when a particular timer expires, and as the last action in that trigger, start the timer as a one-shot with some variable as the duration (it will keep getting restarted every time the trigger runs).
 

Advice D.

New Member
Reaction score
11
Is there a way to use Variables in Events?

Example:
Code:
- Event Every Integer seconds
Trigger:
  • Integer Event
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IntegerEventCounter Greater than or equal to (>=) VariableInteger
        • Then - Actions
          • -------- Put Actions here --------
          • Set IntegerEventCounter = 0
        • Else - Actions
          • Set IntegerEventCounter = (IntegerEventCounter + 1)

Both Variables are integers, VariableInteger is the one that controls the period (in seconds) in this case.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
how about this:
Trigger:
  • Untitled Trigger 001
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Execution count of (This trigger)) mod PeriodicTimeEvent) Equal to 0
        • Then - Actions
          • Trigger - Run MyTrigger <gen> (checking conditions)
        • Else - Actions


PeriodicTimeEvent is an integer variable.
if you set it to 100 the trigger MyTrigger will run every 1.00 seconds.
if you set it to 300 it will run every 3.00 seconds.
if you set it to 50 it will run every 0.50 seconds.

pretty simple.
 

Advice D.

New Member
Reaction score
11
how about this:
Trigger:
  • Untitled Trigger 001
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Execution count of (This trigger)) mod PeriodicTimeEvent) Equal to 0
        • Then - Actions
          • Trigger - Run MyTrigger <gen> (checking conditions)
        • Else - Actions
That will behave strangely when PeriodicTimeEvent is on the fly, for example if it switches from 60 seconds to 40 seconds after one execution, the next will occur on 80 seconds instead of 100.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
if that kind of accuracy is needed he can still use another integer variable instead of the trigger execution. if its not this saves a variable.
 

Tru_Power22

You can change this now in User CP.
Reaction score
144
Trigger:
  • Trigger - Add to Your Trigger <gen> the event (Game - The in-game time of day becomes Equal to Your Var)



Run a trigger like this at map initialization.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top