Repository navigation
Advanced Usage
minerkid08 edited this page Aug 20, 2025
·
1 revision
Sometimes it can be usefull to have a class
To make a class just add the @OpmodeLoaderFunction annotation to all of the functions you want that object to have.
class ExampleClass
{
@OpmodeLoaderFunction
public void thing1() { ... }
@OpmodeLoaderFunction
public void thing2() { ... }
@OpmodeLoaderFunction
public void thing3() { ... }
@OpmodeLoaderFunction
public void thing4() { ... }
@OpmodeLoaderFunction
public void thing5() { ... }
}Then call addClassAsClass() on the function builder object to add it.
FunctionBuilder builder;
builder.addClassAsClass(ExampleClass.class);Note that you have to make a global function in order to get an instance of the class.
local object = getExampleClass(); -- get an instance of the object
object:thing1(); -- call a function on it
object:thing4(); -- call another function on itIf you want the class functions to return a refrence to self then you can use the @OpmodeLoaderBuilderFunction annotation instead of the @OpmodeLoaderFunctionAnnotation.
class ExampleClass
{
@OpmodeLoaderBuilderFunction
public void thing1() { ... }
@OpmodeLoaderFunction
public void thing2() { ... }
}local object = getExampleClass();
object:thing1() -- call the builder function
:thing2(); -- call another function