Razor Scripting: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
The Razor assistant distributed with the Outlands client is a fork of Razor Community Edition. Outlands has additionally extended that scripting engine with the following features. | The Razor assistant distributed with the Outlands client is a fork of Razor Community Edition. Outlands has additionally extended that scripting engine with the following features. | ||
==Expressions== | ==Modified Commands and Expressions== | ||
Several commands and expressions that search by type have been greatly expanded: | |||
dclicktype ('name') OR ('graphic') [hue] [source] [quantity] [range] | |||
findtype ('name') OR ('graphic') [hue] [source] [quantity] [range] | |||
targettype ('name') OR ('graphic') [hue] [source] [quantity] [range] | |||
The hue allows limiting by hue. The source may be the serial of a specific container or 'ground'. The quantity is the minimum quantity, and the range is the maximum range from the player. | |||
==New Aliases== | |||
The 'ground' alias is now available. This is useful in the expanded targeting commands as the "source" parameter. | |||
==New Expressions== | |||
An expression to count your current followers: | |||
if followers < 5 | if followers < 5 | ||
Line 9: | Line 23: | ||
endif | endif | ||
An expression to get the hue of an item: | |||
if hue ('serial') = 0x1809 | if hue ('serial') = 0x1809 | ||
Line 15: | Line 29: | ||
endif | endif | ||
==Commands== | An expression to get your current character's name: | ||
if name = 'MyName' | |||
overhead "It's me!" | |||
endif | |||
An expression to test if your character is paralyzed: | |||
if paralyzed | |||
overhead "Can't move!" | |||
endif | |||
An expression to test if your character is blessed (yellow health bar): | |||
if blessed | |||
overhead "I'm gonna live forever!" | |||
endif | |||
An expression to test if your character is in warmode: | |||
if warmode | |||
overhead "Ready to attack!" | |||
endif | |||
An expression to check any mobile's notoriety: | |||
if noto some_Mobile = hostile | |||
overhead "Safe to attack!" | |||
endif | |||
The valid notorieties are `innocent` (blue), `friend` (green), `hostile` (gray), `criminal` (gray), `enemy` (orange), `murderer` (red), `invulnerable` (yellow). | |||
==New Commands== | |||
The setvar command has been modified on Outlands to support a wider set of use cases. The optional second parameter is now the serial of the variable. If provided, you won't be prompted with a target cursor. | The setvar command has been modified on Outlands to support a wider set of use cases. The optional second parameter is now the serial of the variable. If provided, you won't be prompted with a target cursor. | ||
Line 50: | Line 96: | ||
overhead my_label | overhead my_label | ||
==Operators== | A command to rename followers has been added: | ||
rename myFollower Bob | |||
A command to set skill gain locks has been added: | |||
setskill Blacksmithing up | |||
The valid choices are up, down, or locked. | |||
==New Operators== | |||
There is now an 'as' operator to capture the result of expressions as an alias. This is particularly useful for the `findtype` expression as follows | There is now an 'as' operator to capture the result of expressions as an alias. This is particularly useful for the `findtype` expression as follows |
Revision as of 06:02, 2 July 2021
The Razor assistant distributed with the Outlands client is a fork of Razor Community Edition. Outlands has additionally extended that scripting engine with the following features.
Modified Commands and Expressions
Several commands and expressions that search by type have been greatly expanded:
dclicktype ('name') OR ('graphic') [hue] [source] [quantity] [range] findtype ('name') OR ('graphic') [hue] [source] [quantity] [range] targettype ('name') OR ('graphic') [hue] [source] [quantity] [range]
The hue allows limiting by hue. The source may be the serial of a specific container or 'ground'. The quantity is the minimum quantity, and the range is the maximum range from the player.
New Aliases
The 'ground' alias is now available. This is useful in the expanded targeting commands as the "source" parameter.
New Expressions
An expression to count your current followers:
if followers < 5 overhead "Can still tame stuff!" endif
An expression to get the hue of an item:
if hue ('serial') = 0x1809 overhead "Found hue of my item!" endif
An expression to get your current character's name:
if name = 'MyName' overhead "It's me!" endif
An expression to test if your character is paralyzed:
if paralyzed overhead "Can't move!" endif
An expression to test if your character is blessed (yellow health bar):
if blessed overhead "I'm gonna live forever!" endif
An expression to test if your character is in warmode:
if warmode overhead "Ready to attack!" endif
An expression to check any mobile's notoriety:
if noto some_Mobile = hostile overhead "Safe to attack!" endif
The valid notorieties are `innocent` (blue), `friend` (green), `hostile` (gray), `criminal` (gray), `enemy` (orange), `murderer` (red), `invulnerable` (yellow).
New Commands
The setvar command has been modified on Outlands to support a wider set of use cases. The optional second parameter is now the serial of the variable. If provided, you won't be prompted with a target cursor.
setvar my_name 0x123
This can be used for graphic IDs, hues, serials, names, and more. By default, this creates a persistent variable that will remain even across restarts of the application. To make the variable only live for as long as the current program run, append the '!' operator. The variable will not appear in the Razor variables list, but will still be global and usable from any script while Razor is running.
setvar! my_name 0x123
Further, to define a purely local variable only for the current scope, use the @ operator in conjunction with the ! operator:
@setvar! my_name 0x123
The variable `my_name` will only exist in this script.
Additionally, a command to unset variables has been added. It supports the same modifiers as setvar:
unsetvar my_name
A command to explicitly set warmode state has been added:
warmode ('on' / 'off')
- Note that this will need a server patch to function correctly.
A command to get an item's label - the text you see when single clicking it - has been added.
getlabel (serial) (name)
This will fetch the label for the item identified by the serial and create a new variable with your choice of name that holds the text.
getlabel backpack my_label overhead my_label
A command to rename followers has been added:
rename myFollower Bob
A command to set skill gain locks has been added:
setskill Blacksmithing up
The valid choices are up, down, or locked.
New Operators
There is now an 'as' operator to capture the result of expressions as an alias. This is particularly useful for the `findtype` expression as follows
if findtype dagger as mydagger dclick mydagger endif
There is additionally an 'in' operator that can be used to check whether one string is a substring of another:
if this in thisthatandtheother overhead yes endif
These are particularly powerful when combined to sort through items:
if findtype dagger as mydagger getlabel mydagger daggerlabel if blessed in daggerlabel overhead "Found newbie dagger" endif endif
Lists
List support includes the following commands:
createlist ('list name')
Create a new list
clearlist ('list name')
Clear an existing list
removelist ('list name')
Delete a list
pushlist ('list name') ('element value') ['front'/'back']
Add an item to the front or back of the list
poplist ('list name') ('element value'/'front'/'back')
Remove an item from the front of back of the list
Additionally, the following list-related expressions have been added. These may be used within if
and while
statements.
listexists ('list name')
True if the list exists
list (list name) (operator) (value)
Compare the length of the list to an integer
inlist (list name) (element)
Test if an element is in a list.
Finally, for
and foreach
loops can be used for iteration as follows:
for 10 say 'hello' endfor
This will iterate exactly 10 times.
foreach x in my_list say x endfor
This will iterate the elements in my_list, assigning the variable 'x' to the next element on each iteration.
Timers
Timers represent background timers that run while the rest of your script executes. All units are in milliseconds. They can be queried to check how much time has elapsed since they were started, or reset back to an earlier count.
The following commands for working with timers have been added:
createtimer (timer name)
Create a new timer, starting at 0.
removetimer (timer name)
Destroy an existing timer.
settimer (timer name) (value)
Set a timer to the given value. It will begin counting up from the given value immediately.
Additionally, two expressions have been added for timers:
timer ('timer name') (operator) (value)
Compare the current value of the timer (the time elapsed since it was started in milliseconds) to a given value
timerexists ('timer name')
Check if a timer exists
Example:
// Create a new timer if not timerexists 'sample' createtimer 'sample' endif // Reset every 10 seconds if timer 'sample' > 10000 settimer 'sample' 0 endif