-
Notifications
You must be signed in to change notification settings - Fork 21
Character Variables
Both Players and NPCs have a Variables container for storing variables and information.
By default variables are only stored temporarily and will be lost/reset when the npc dies, player logs out or the game restarts.
Variable names should use lower camel case. e.g. "in_combat"
not "inCombat"
Characters have extension functions to simplify accessing Variables
val burrow: Boolean = giantMole["burrow"]
❗ Note that this is the unsafe version and will throw an exception is the value hasn't previously been set and doesn't have a default listed in the variables config file.
The following safe version will return false
if the value is unset.
val burrow = giantMole["burrow", false]
This is the recommended way of accessing values.
Setting a value is straight-forward, it's important to use descriptive names to make sure values don't conflict with other content.
giantMole["burrow"] = true
Variables which a player has often need to be sent to the client to change something or display the value. Client variables are split into one of 4 categories:
- varp - Player Variable
- varbit - Variable Bit (part of a varp)
- varc - Client Variable
- varcstr - Client String Variable
For more details read Runelites page on the subject
These variables will need specifiying in the relevant variables-
yaml file in ./data/definitions/. Along with their id and type.
cooks_assistant: # The string name of the variable
id: 29 # The variable id to send to the cleint
persist: true # Save the value on logout
format: map # The format the value is stored in (might differ from the format sent to the client)
default: unstarted # The default value if left unset
values: # Map for converting values before sending to client
unstarted: 0
started: 1
completed: 2
Any variables which need storing but don't have a known id should be stored in variables-custom.yml