Skip to content

Declarations

OutCraft edited this page Jun 22, 2023 · 2 revisions

Variables

Variable Declaration

To declare a variable, use the var keyword followed by a name.

var myVariable;

RoboScript is a dynamically typed language, with all variables being able to be all types. All variables are null, meaning undefined, by default. To initialize the variable with a value other than null, you can follow the name of the variable with = and the value.

var myNumberVariable = 3;
var myTextVariable = "Hello World";
var myBoolVariable = true;

Getting and Setting Variables

To get a variable, simply write the name of the variable.

var myVariable = "Hello World";
print(myVariable) // Hello World

To edit an already existing variable write the name of the variable and set it with = and the new value.

var myVariable = "Hello World";
myVariable = "Another Hello World";
print(myVariable) // Another Hello World

Clone this wiki locally