VirtueRS3 is a RS3 emulation framework originally developed for the 823 protocol, then progressively updated to 865. It aims to ease the development, testing, and integration of content by using the Java 8 Nashorn engine for content scripts, interacting with the engine via a series of APIs.
To run the framework, place an 865 cache in the folder repostiory/cache_865/
then run ./gradlew run
in the root folder (or gradlew.bat run
in Windows). This will download Gradle and all the libraries needed to run the server (if you don't already have them) before starting.
To contribute to the project, fork it to your own repository using the link at the top of the screen, commit your changes, then create a pull request to have it merged back into the main branch. Anyone is free to contribute, whether they're changing one line of one file or contributing an entire skill system.
All content scripts are located under scr/main/javascripts/. The CommonJS module structure is used to organise scripts into modules which declare dependencies on other modules using require(<relative path to module>)
.
NOTE: you must use the relative path to the module when requiring modules, which usually involves stepping up one or more levels first. For example, if your module was in the folder /skill/mining
and you wanted to import the /core/var/bit
module, you would need to use var varbit = require('../../core/var/bit');
Scripts are built and loaded automatically when you start the server.
To avoid restarting the server every time you change a script, you can run ./gradlew watchScripts
in a separate terminal window/tab to automatically rebuild the bundle any time a file.
You must also use the ::scripts
command in-game (while logged into an Admin account) to cause the server to load the updated module.
Note: The ::reload <module>
command has not yet been updated to work with the new build script. For now, you must use ::scripts
to reload all modules instead.
Each module must contain an index.js
file which exports at least an init()
function. When the module is loaded, the global-bootstrap.js
file will call it's init()
function with the scriptManager
argument, which can be used to bind events as outlined in the next section.
To register a module, it's relative path from the root script directory must be declared in the getAllModules()
function in global-bootstrap.js
. This allows the module to be loaded both when the server is launched and when the ::reload <module>
command is used (<module>
is the name provided in the getAllModules()
function).
Registering event requires the following line to be used within the init
function: scriptManager.bind(eventType, binding, listener);
, where:
eventType
is the type of event which triggers the function (eg EventType.OPHELD1
for the first inventory option on an item). For a list of possibile event types, see the Script Event Bindings wiki page;binding
is the specific item which triggers the command (eg 1962 for EventType.OPLOC1
would be the first option on a location with the ID 1962). Note: You can also provide an array of ids to bind to (eg [ 20, 822, 400 ] would bind the same listener to items with IDs of either 20, 822, or 400).listener
is the function to call when the event is triggered. The function is provided with a ctx
argument, providing the event context object which can be used to gather useful event parameters (eg ctx.player
)There are a handful of core modules you can require in your module to perform useful functions. Doing so is preferable to interacting directly with the game engine. For a list of core modules, see the Core Modules wiki page
VirtueRS3 generally uses the actual names for variables, where known. Some of the most common ones are listed below:
One of the most common requests in any RSPS is granting an account administrative rights. There are two ways of doing this in VirtueRS3: the manual method, and the command method.
This method is required for the first account you set as administrator (and to revoke admin rights).
This method should be used for all other accounts, beyond the first admin, since it's a lot easier to do.