Skip to main content

Creating Addon Lua

To accommodate addons that necessitate only a minimal amount of code, we have introduced the option to utilize Lua in place of Java. The process of establishing a Lua addon is straightforward and user-friendly.

 

Setting up the addon

Addons require these fields or else it will fail to load

name = "Example-Addon"
version = "1.0.0"
author = "InsurgenceDev"
description = {
  "This is an example lua addon"
}

 

Printing text to console when addon is started

To print text to the console when the addon is started you need to create a function named "onAddonStart" really its the same as Java addons 

name = "Example-Addon"
version = "1.0.0"
author = "InsurgenceDev"
description = {
  "This is an example lua addon"
}

function onAddonStart()
    print("Lua addon started")
end

 

Importing classes from java

to import a class is very simple

import 'java.util.ArrayList'

Above will import the ArrayList java class example of how to use it

import 'java.util.ArrayList'


local arrayList = ArrayList()


function onAddonStart()
  arrayList:add('Example 1')
  arrayList:add('Example 2')
  arrayList:add('Example 3')
  arrayList:add('Example 4')
end