Skip to content

Scripting Overview

Introduction

The Razor Scripting Engine is a "command based scripting language" designed to make it easier to read, create, edit and share Razor scripts.

To learn more about this version of Razor, please visit the home page.

Design

This scripting engine attempts to maintain and improve existing Razor functionality, offer quality of life improvements over the existing macro system, and provide an easily approachable syntax that is accessible regardless of skill level.

For example, instead of having to do the following with a Razor macro:

  1. Record macro
  2. Double click dagger
  3. Stop recording
  4. Right-click on dagger
  5. Select Double Click use by type

You can simply type:

1
dclicktype 'dagger'

Scripts vs. Macros

While updates to Razor have made it easier to edit and share macros, one of the core issues is that they weren't designed to be read and edited by users directly, instead the serialized format they're saved in expects you to use the macro editor in Razor.

For example, even a basic macro that casts blade spirit, waits for the target and casts a relative location based on your position can be difficult to read to the untrained eye.

1
2
3
Assistant.Macros.MacroCastSpellAction|33
Assistant.Macros.WaitForTargetAction|30
Assistant.Macros.TargetRelLocAction|3|1

With a Razor script, it becomes:

1
2
3
cast 'blade spirits'
waitfortarget
targetrelloc 3 1

Another example using a script that uses detect hidden, waits for target, targets self, waits .40 seconds, checks for a system message, says something and targets the closest mobile.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Assistant.Macros.UseSkillAction|14
Assistant.Macros.WaitForTargetAction|30
Assistant.Macros.HotKeyAction|1059|
Assistant.Macros.PauseAction|00:00:00.4000000
Assistant.Macros.IfAction|4|0|you can see nothing
Assistant.Macros.ElseAction
Assistant.Macros.SpeechAction|0|38|3|ENU|2|16|52|I Ban Thee
Assistant.Macros.WaitForTargetAction|30
Assistant.Macros.HotKeyAction|2003|
Assistant.Macros.EndIfAction

With a Razor script, it becomes:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
skill 'detecthidden'
waitfortarget
target 'self'

wait 400

if insysmsg 'you see nothing'
    overhead 'All clear'
else
    say 'I ban thee'
    waitfortarget
    target closest grey humanoid
endif

As you can see, while maintaining the same functionality of macros, a Razor script is much easier to read, edit and share.

Convert Macros to Scripts

Right-Click on any macro to convert it to a script.

Script Editor

Razor scripts can be written using any text editor. The script editor built into Razor offers syntax highlighting and auto-completion.

Window Size

You can resize the Razor window to make the script editor larger. You can also adjust the size of the script list to give you additional room.

Here are a list of some of keyboard shortcuts available in the editor:

General/Misc

Common text editor shortcuts (such as Ctrl-C and Ctrl-V for copy/paste are not listed):

  • Ctrl+G: Goto to a specific line dialog

  • Ctrl+F: Find/Search dialog

  • F3: Find next
  • Ctrl+H: Search & replace dialog
  • Ctrl+Shift+C: Comment / Uncomment selected code
  • Alt+Mouse Drag: Select multiple lines of text
  • Ctrl+Home: Go to the first line
  • Ctrl+End: Go to the last line
  • Alt+Up: Move selected lines up
  • Alt+Down: Move selected lines down

Bookmarks

  • Ctrl+B: Bookmark line
  • Ctrl+Shift+B: Remove bookmark
  • Ctrl+B: Move cursor to next bookmark
  • Ctrl+Shift+N: Move cursor to previous bookmark

Auto-Complete

  • Ctrl+Space: Open auto-complete menu

Zoom

  • Ctrl+Mouse Wheel Up: Zoom in
  • Ctrl+Mouse Wheel Down: Zoom out
  • Ctrl+0: Reset zoom

About

The Razor Scripting Engine was designed and implemented by Quick and is released under GPLv3.


Last update: December 13, 2022