Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Scriptref Triggers

From Lost City Wiki
Revision as of 16:38, 22 August 2025 by Branon (talk | contribs)

Previous Page || Browse all Scriptref pages

Triggers

RuneScript operates primarily via triggers, which describe how and when to execute functions. Triggers consist of two parts: the trigger itself, and a subject.

Triggers will fire when a player interacts with the game world (typically by clicking) and the functions executed by the trigger are responsible for what actions the game engine will take after the player clicks.

Nearly everything a player does in-game will fire some sort of trigger. Likewise almost all RuneScript is written to execute in response to a fired trigger.

Triggers can be placed in any RuneScript file and the order of triggers does not matter, however it still pays to stay organized!

Types of Triggers

There are several dozen different triggers but they can be divided up into three main types:

  • Specific triggers fire when the player interacts with a single subject, and use the syntax [trigger,subject]
  • Category triggers fire when the player interacts with any subjects in a particular category. Categories are prefixed with an underscore so the syntax looks like [trigger,_category]
  • The global trigger acts as a fallback and fires if no other triggers exist for that subject ("Nothing interesting happens"). The global trigger actually uses a category so the syntax is [trigger,_]

Triggers: op versus ap

Most triggers you will encounter in everyday use are prefixed with either op or ap:

  • op: Operable within one tile, requires line of walk, restricted to cardinal directions  
  • ap: Approachable within 10 tiles, requires line of sight

Remember that op triggers are used for interactions within melee distance (one tile away) and ap triggers are used for interactions at range (between two and ten tiles away).

Trigger Naming Convention

Breaking down a bit further, triggers can be categorized by subject type. Different triggers are intended to fire upon interaction with different types of subjects:

  • Player subjects: opplayer1-5 / applayer1-5
  • NPC subjects: opnpc1-5 / apnpc1-5
  • Loc subjects: oploc1-5 / aploc1-5
    • "Loc" (or location) is the Jagex term which refers to any interactable (clickable) scenery found in the game.
  • Objects on the ground: opobj / apobj
    • "Object" refers to items, either on the ground or held in the inventory
  • Objects held in the inventory: opheld1-5 / opheldu (held objects cannot be approached)

There are more triggers but this gives you an idea of how the naming convention works.

Examples of Common Triggers

Here are some real-world examples of common triggers you will encounter:

  • [opnpc1,border_guard_lumby]
    • This is the trigger that fires when a player clicks on a Lumbridge border guard within melee distance. It is a specific trigger because its subject is not prefixed by an underscore.
  • The trigger being used here is opnpc1 which is shorthand for performing operation 1 on an npc.
    • Operation 1 for the border guard is Talk-to.
  • [oploc1,_door_closed]
    • This trigger fires when the player clicks any door in the door_closed category within melee distance. This is a category trigger because its subject is prefixed with _.
  • This is a loc trigger because a door is clickable/interactable scenery and is therefore referred to as a loc.
  • The trigger used is oploc1, and operation 1 on closed doors of this category is Open.
  • [applayeru,rotten_tomato]
    • This trigger fires when the player uses a rotten tomato on another player from aproachable distance (at a range of between 2 and 10 tiles).
  • This is a specific trigger because it will only fire when the used item is a rotten tomato.
  • This trigger only applies to players, so it will not fire if the rotten tomato is used on an NPC (that would be apnpcu).

Now you understand how to set triggers in RuneScript. The syntax is fairly simple: your desired trigger and its subject, separated by a comma, and enclosed in brackets.