Loner-StrikeReference

Reference

Types and casting

Numbers, text, players, entities, vectors and lists, and turning one into another.

Every pin and variable in Game Mode Studio has a type, and a wire only connects pins whose types fit. Most of the time you don't think about it: drag from a pin and the node list shows only nodes that fit. This guide covers the types worth knowing, how a value goes from one type to another, and what an app update can leave behind.

The types

A variable's type menu (and a function's inputs, outputs and struct fields) groups them like this. A struct field is always one value of these types (an Array or Map is for variables; for a list of structs, make an Array of the struct):

GroupTypesFor
BasicNumber, Yes/No, Text, Vector, Color, TransformAmounts, switches, words, positions and directions, colors, where something is
GamePlayer, Team, Weapon, Hit Zone, Damage Kind, Entity, NPC, Creature, Projectile, Trigger Volume, Objective Marker, ComponentThe things in a round
Files (loaded with the map)Model, Sprite, Sound, DecalFiles your mode uses
HandlesTimer, Sound LoopSomething running that you may want to stop
MineYour mode's own enums and structsChoices and groups of values you define

Under the list, Array of and Map from make a list or a lookup of any of these (see Variables and saving).

One Number type, and whole numbers

There's a single Number type for every amount. Pins and settings the game takes as whole numbers (counts, ammo, money, slots, rounds, lives, waves) show a small #, and their fields step by 1. A typed-in fraction there is rounded, and Problems says so: "Ammo is a whole number: 2.5 becomes 3." Whole numbers are exact up to about 16 million.

Weapon, Hit Zone and Damage Kind

Three enums come built in:

  • Weapon: ak47, m4a1, awp, deagle, knife, c4 and every other weapon by name.
  • Hit Zone: generic, head, chest, stomach, left arm, right arm, left leg, right leg.
  • Damage Kind: other, shot, slash, blast, burn, fall, shock, drown, poison.

They come out of Weapon Held and Player Killed (Weapon kind), Player Hurt and Projectile Hit (Hit zone), and Player About To Be Hurt (Hit zone and Damage kind). The old text outputs are still there beside them.

Wire one into Switch on Enum and it grows one output per value. Double damage on headshots:

Player About To Be Hurt → Switch on Enum (Hit zone) → head → Scale Damage (2)

A Weapon goes into a text pin as its name, so Give Weapon's Weapon pin takes it. Your own enums work the same way (see Structs and enums).

Color

A Color is one value: red, green, blue and alpha. Make one with Color (picked with a swatch, an Alpha slider and presets such as Terrorist red and Counter-Terrorist blue), Make Color, Color From Hue or Blend Colors; split one with Break Color.

Set Glow, Screen Fade, Beam, Trail, Effect Burst, Status Icon and Objective Marker have a pin Color (wins over the setting). Left empty, they use their own color settings. A glow that goes from green to red as health drops:

Player Hurt → Set Glow (Victim, Color: Blend Colors (Red, Green, Amount: Health left ÷ 100))

Color variables are fine; data table columns and mode settings can't be colors.

Transform

A Transform is a built-in struct with Position, Rotation, Scale and Velocity. Get Transform and Get Entity Transform give one; Set Transform (Transform (separate pins win)) and Set Entity Transform take one. Search the node list for Make Transform or Break Transform. If a Transform and a separate pin are both wired, Problems warns: "Both Transform and Position are wired: Position wins." Players can't be resized: Scale is for props and sprites.

A shared checkpoint: whoever reaches it saves the spot, and everyone respawns there.

Begin Overlap ("checkpoint") → As Player (Who) → Success → Set Variable (Checkpoint, Get Transform's Transform)
Player Spawned → Set Transform (Player, Transform: Get Variable Checkpoint)

Like every struct, a Transform variable is one for the whole mode.

Files: Model, Sprite, Sound and Decal

File pins are drawn as hollow squares. A Model is a models/….mdl, a Sprite a sprites/….spr, a Sound a .wav named from inside sound/ (ambience/thunder_clap.wav). A Decal is one of Decal's kinds (Bullet hole, Scorch mark, Blood…). The pin Model or Sprite on Spawn Projectile takes either.

Files are picked, never made from text. The game loads every file a mode can use before the map starts, so there's no Text-to-Model conversion. The files a mode can hold are the ones you picked: in Model, Sprite, Sound or Decal, a variable's start value, a Set Variable value or a data table cell. A file that isn't on the server is skipped and logged. File Name Of gives a file's name as text to show or log.

A random death sound from a list:

Player Killed → Play Sound at Location (At entity: Victim, Sound: Random Item (Death Sounds))

Handles, and the way up

Some outputs aren't just any Entity; they're known to be one kind. Their pins carry a letter: N (NPC), C (Creature), P (Projectile), V (Trigger Volume), M (Objective Marker), K (Component).

Going up always works: a handle, or a Player, goes into any Entity pin as it is (Remove Entity, Bots: Goal's At, Attach To). Lists don't widen, though: an Array of Creatures can't go where an Array of Entities is written to.

Casts: the way down

Going from Entity to a kind needs a cast, because the thing might be something else. As Player, As Creature, As NPC, As Projectile, As Trigger Volume, As Objective Marker and As Component each have a Success output (with the typed value) and Failed.

Talk to whoever walks into a volume, if it's an NPC:

Begin Overlap → As NPC (Who) → Success → Say (NPC: NPC, "Stay close.")

Heal a player who steps on a pad, and ignore creatures:

Begin Overlap ("pad") → As Player (Who) → Success → Set Health (Player, 100)

When several kinds are possible, ask first: Kind Of gives an Entity Kind (Player, Bot, Creature, NPC, Interactable, Component, Prop, Map entity, None) for Switch on Enum.

Entity Touched → Switch on Enum (Kind Of Other) → Creature → As Creature → Success → Set Creature Health (0)

You rarely have to find the cast yourself: drop an Entity wire on a Creature (or NPC, Player…) pin and the Studio says "Check what it is with As Creature first (casting)", with an Insert As Creature button. One Undo takes it back.

After an update: orphaned pins

Modes saved with 1.0 open as they are and make the same plugin. A file from a newer app says "That graph was made by a newer Loner-Strike (graph version N). Update the app to open it."

If an update ever removes a pin you had wired, the wire stays on a red pin labeled Orphaned: its id, and Problems says "This pin was removed in an update. Re-wire or delete it." Compile, Test and Publish wait until it's fixed; deleting the wire removes the orphan. A removed setting shows grayed in Details as "Orphaned: name = value", with Clear. View › Refresh nodes lists what an update left behind ("Nodes refreshed: 1 orphaned wire, …"). Saving keeps orphans as they are, so nothing is lost by opening a mode.

See also

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