RCode documentation

Environment

RCode sets a custom environment for every script that you compile and run, so some scripts might not work!

console

console

The console object allows you to access functions that interact with the console

console.log (...string message) -> void

Print message to the console in white text

console.warn (...string message) -> void

Print message to the console in yellow text

console.error (...string? message) -> void

Same as the regular error, but it ouputs to the console.

console.assert (bool condition, ...string message) -> void

Same as the regular assert, but it ouputs to the console.

console.input (string? message) -> string

Requests input from the player with message if provided’

console.stack (array<string> stack) -> void

Prints every item in stack to the console

console.table (table<any> table) -> void

Prints table to the console as you would write it in Lua

getfenv + setfenv

setfenv (function func, table<any> environment) -> void

Same as the regular setfenv

getfenv -> nil

getfenv is restricted

next + ipairs + pairs

next (table<any> t, any lastKey = nil) -> any, any

Same as the regular next

pairs (table<any> t) -> function, table<any>

Same as the regular pairs

ipairs (array<any> t) -> function, array<any>, int

Same as the regular ipairs

LoadLibrary

LoadLibrary (string libraryName) -> any

Same as require, but it can only load modules that have been registered. See the list on the right for a list of registered modules.

wait

wait (number duration) -> number

Same as the regular wait

pcall + xpcall

pcall (function func, Tuple<any>? params) -> bool, any

Same as regular pcall

xpcall (function func, function error, Tuple<any>? params) -> bool, any

Same as regular xpcall

String methods

Instead of using the global string, use the string methods.

- string.gsub("Hello, world!", "world", "space")
+ ("Hello, world!"):gsub("world", "space")

Services

Right now, you can’t use the services that you can find in the DataModel. Service support is planned, but you can use LoadLibrary to load libraries that replicate services.