Skip to content
GAMINGNOOBdev edited this page Jun 14, 2025 · 4 revisions

Syntax

The syntax of baranium is pretty similar to a mix of the syntax of languages like python or C. The fine details and each keyword will be further described on this page.

Variables, fields and variable types

There are currently 14(16 if counting duplicates) builtin variable types.
Here's a list of all of the current available types:

Type Description
void A type that is reserved for function return types only, void means no data
object A 64-bit data object that can holy anything arbitratily (most used as a passthrough type for function binding in libraries for unknown datatypes)
string A normal string object
bool A boolean type that can represent either true or false
float A 32-bit floating point number aka a number with decimal places
double A 64-bit floating point number, works the same as a float
int8 An 8-bit signed integer number
uint8 An 8-bit unsigned integer number
int16 A 16-bit signed integer number
uint16 A 16-bit unsigned integer number
int32 A 32-bit signed integer number
uint32 A 32-bit unsigned integer number
int64 A 64-bit signed integer number
uint64 A 64-bit unsigned integer number
int Alias for int32 useful for abbreviation
uint Alias for uint32 useful for abbreviation

Variables are declared by giving them a type, name and optionally an initial value. If the variable is not defined in the global space, the value can be set using anything. If however you want to define a global variable, you can only set constant values that don't depend on any execution (i.e. function calls, mathemetical operations, etc.). A variable definition would look like this:

int variablename = 10;
float sin_of_pi = sinf(3.1415);

Note

global space means that a variable/field is defined outside of a function.

Fields behave pretty much the same as variables. The only difference is that fields are accessible by the user outside of the runtime, menaing that while the runtime runs, the value of fields can be changed and accessed by the user and can only be defined in the global space.

To define a field, add the field keyword before defining a global variable.

field int variable = 10;

Since fields are defined in the global scope, there is no way of setting their default values on any sort of initial execution, so it is recommended to create an initialization function to set initial values to fields on program startup.

Functions

Functions can be either fully declared or just pre-defined. Pre-defined functions will have to be added from within the runtime as callbacks or loader from a library. The general syntax for a function works like this:

define function_name(type1 parameter1, type2 parameter2)
{
    <function contents> ....
}

The define keyword tells the compiler that there will be a function declaration coming.

Note

Functions can only be declared in the global space. The type1 and type2 are placeholders for actual typenames.

Specifying function parameters is of course optional, if there are no parameters for the function, the parenthesis can just be left empty inbetween. If you wish to only declare the function, you can end the declaration with a semicolon (;).

define function_name();

You can also immediately specify the return type of the function while defining the function like this:

define function_name() = object;

define function2() = void
{
    .....
}

If-Else statements

If-else statements work almost exactly like they work in C. That means the syntax for a if statements looks like the following:

if (condition)
    ... one line of code
else if (other condition)
{
    ... code
}
else
{
    .... whatever
}

Loops

Similar to if-else statements, loops work exactly the same as in C. This is how each loop would look like:

for loop

for (int i = 0; i < 10; i++)
{
    ... code
}

int j = 100;
for (; j != 1; --j)
{
    ... code
}

while loop

while (condition)
{
    .... code
}

do-while loop

do
{
    ... code
}
while(condition);

Miscellaneous features

Some currently unused features include:

Feature Description
attach Originally for attaching to a gameobject, scrapped but kept in place for later repurposing
detach Originally for detaching from a gameobject, scrapped but kept in place for later repurposing
instantiate Originally for creating gameobjects from a template, scrapped but kept in place for later repurposing
delete Originally for deleting gameobjects, scrapped but kept in place for later repurposing

Clone this wiki locally