Loner-StrikeReference

Reference

Events and flow

What starts a graph running, and Branch, Sequence, loops and timers.

A Game Mode Studio graph sits still until something happens in the game. Then it runs from that event along the white flow wires, one node after another. This guide covers what starts a graph, how the flow moves, and the nodes that steer it: branches, sequences, loops, gates, custom events and timers.

What starts a graph

Every flow starts at an event: a red node with no flow pin going in. Some you'll use in almost every mode:

A graph with no event never runs. The Problems tab says so ("Nothing happens yet").

The same event can sit in more than one event graph (My mode › Graphs). They all run, in tab order, then top to bottom. That's handy for keeping a big mode tidy: one graph for the shop, one for scoring.

Events, actions and values

Nodes come in three kinds, and the reference marks each one:

  • Events start a flow and hand you what happened: Player Killed gives Victim, Attacker, Weapon and more.
  • Actions have a white flow pin in and out. They do something when the flow reaches them: Give Weapon, Chat Message, Spawn Prop.
  • Values (pure nodes) have no flow pins. They work out an answer when an action needs it: Health Of, Math, Distance. A value is worked out again each time it's used, so Random Number wired into two actions can give two numbers.

Flow and loop nodes such as Branch and For Each are actions that pick which flow pin runs next.

Following the flow

White pentagon pins carry the flow; round pins carry values. A flow pin out can go to one place. To do several things, chain them, or use a Sequence. Several flow wires can come into the same pin.

Most actions run and carry on at once. A few wait: Delay carries on later, and Say and Choose runs a reply's output when the player picks it. Other flows keep running while one waits.

Double-click a wire to add a Reroute point and bend it out of the way. It changes nothing.

Branch and other choices

Branch goes to True or False. Feed it a yes/no: Compare, Is Team, And / Or, Not.

To pay a bounty only for real kills (a fall has no attacker):

Player Killed → Is Valid? (Attacker) → Is Valid → Give Money (Attacker, 300)

For more than two ways:

Sequence

Sequence runs its outputs in turn, top to bottom, each one to its end before the next. It keeps a long chain readable. Press + Add pin for more outputs (up to 32).

Round Started → Sequence → Then 0: Show Message ("Fight!") → Then 1: Bots: Phase (Fight)

Loops

A loop runs its Loop Body (or Each) output again and again, then its Completed (or Then) output once.

NodeGoes through
For Each PlayerEvery player who fits (alive, dead, a team…), or the players in Only these. At most 32, so it's cheap.
For EachEvery item of an array, with Item and Index.
For Loop / For Loop with BreakEach number from First to Last (at most 10000 steps).
While LoopWhile a condition is true, stopped at Limit (1000 to start) so it can never freeze the server.
For Each Row, For Each Creature, For Each Marker, For Each Entity, Top PlayersA data table's rows, living creatures, map markers, entities, saved leaders.

Flow into Break stops a loop early; Completed still runs.

To give everyone on the Terrorist team a grenade at the start of a round:

Round Started → For Each Player (Who: Terrorists) → Each → Give Weapon (Player, hegrenade)

To go through your own list, build an array (Players Array, Players In Radius, Find Entities, Split Text) and use For Each:

Players In Radius → For Each → Loop Body → Slap (Item)

A loop can't freeze the server. In an event graph, a loop that runs past the mode's Loop steps a frame (20000 to start) stops where it is and goes on next frame from the same place; Completed still runs at the real end, and what follows waits for it. A Function can't wait, so its loops stop at Loop steps in a Function and it returns what it has. Both are Limits settings. For work that should happen bit by bit on purpose, use a timer.

Do Once, gates and counters

  • Do Once lets the flow through the first time only, until Reset.
  • Do Once Per Player: once for each player, until Reset (everyone) or Reset Player.
  • Do N: N times, until Reset.
  • Gate: Enter goes through only while it's open. Open, Close and Toggle change it.
  • Multi Gate: each time, the next output (in order or random); Loop starts over after the last.

To announce first blood once a round:

Player Killed → Do Once → Big HUD Text ("First blood!")
Round Started → Do Once's Reset

Custom events, functions and macros

A custom event is your own event, with inputs you choose (My mode › Custom events). Call Custom Event runs every Custom Event node for it, from anywhere in the mode. Use one when several places need the same reaction ("give the round's reward").

A map can fire one too: tick The map can fire it, and point a button or trigger at an ls_event entity with the event's name. On Map Entity Fired hears any named map entity without an ls_event.

To talk to other plugins and other Studio modes, use Fire Custom Event and On Custom Event.

A function is a reusable graph with inputs and outputs: Function Entry starts it, Call runs it, Call Pure uses a pure one as a value. Functions run straight through, so nodes that wait (Delay, Repeat) don't go in them. Put those in a macro (Macro), which is copied in where you use it and can have several flows in and out.

Timers

  • Delay: waits, then carries on. Running it again starts another wait.
  • Retriggerable Delay: like Delay, but coming in again starts the wait over, so it carries on once things go quiet.
  • Repeat: runs Each every few seconds, a number of times (0: until the round ends).
  • Countdown: counts down on everyone's screen, then runs Done.
  • Set Timer by Event and Set Timer by Function: run a custom event or a function later, or again and again.
  • Stop Timer, Clear Timer, Is Timer Active and Stop Timers: stop or check them. Each timer node gives a Timer value you can keep in a variable.
  • Timeline: values that change over time and events at set moments (a lifting platform, a pulsing glow).

For abilities, cooldowns are simpler than timers: Start Cooldown when it's used, Is Ready before letting it run again.

On Tick and what it costs

On Tick runs again and again all through the map, every Interval seconds, with Delta (the seconds since last time). 0.1 means ten times a second, which looks smooth for almost anything. 0 means as often as the mode's On Tick runs a second at most setting lets it (100 to start; see Limits).

Everything after On Tick runs every time, for the whole server. A loop over every player or entity, a search round a point, or a line-of-sight check in a fast On Tick adds up quickly. The Problems tab warns when an On Tick faster than 0.05 s has one of those in it.

  • Use the slowest interval that looks right. A Repeat every half second is usually plenty for checks.
  • Prefer an event when there is one: Player Landed instead of checking feet every tick, Begin Overlap instead of measuring distances.
  • Keep long lists in a variable instead of finding them every tick.

Worked examples

A double jump

The quick way: one node.

Player Spawned → Jump Rules (Player, Extra air jumps: 1)

By hand, so you can add a sound or a cooldown:

Player Pressed Button (Jump) → Branch (Player Movement State: On ground) → False → Do Once Per Player → Push (Straight up, 300)
Player Landed (Only falls faster than: 0) → Do Once Per Player's Reset Player

The starter library's Double Jump (My library) is this, ready to wire in.

Last one standing wins

Player Killed → Branch (Count Alive ≤ 1) → True → End Round

Pick who's "it" after a countdown

Round Started → Countdown (10, "Picking in") → Done → Pick Random Player (Everyone alive) → Found → Set Glow (Player, Red) → Show Message (Player, "You're it!")

See also

A hand-written guide. Every node it names links to the node reference, which is made from the app's own catalog.