User Tools

Site Tools


addons

Addons

What are addons?

Addons are Lua scripts that get loaded into the game via the Addons.dll plugin. These scripts have access to the Ashita core interfaces that plugins can make use of, allowing scripts to essentially be, non-compiled plugins. (With limitations of course.)

Addons let you extend the game through means of Lua scripting.


What is Lua?

Lua is a powerful, fast, lightweight, embedded scripting language.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

You can read and learn more about Lua at their homepage here: http://www.lua.org/about.html


New To Lua / Lua Beginners Guide

Using The Addons Plugin

The addons plugin can be loaded via the typical plugin load command:

  • /load addons

By default, Addons.dll will be automatically loaded via the Default.txt script.

You can use the following commands to interact with the plugin:

  • /addon load [name] - Loads the given addon by its name.
  • /addon unload [name] - Unloads the given addon by its name.
  • /addon reload [name] - Reloads the given addon by its name.
  • /addon unloadall - Unloads all currently loaded addons.
  • /addon list - Lists all running addons.
  • /addon exec [name] [cmd] - Executes a Lua command inside of the given addons state.

Basic Addon Information

Lua creates an object called a state when you begin using it. However, this state is fragile and does not offer much protection against errors and problems. Because of this, every single addon that you load is run inside of its own Lua state. By doing this, it helps prevent addons from conflicting and causing others to crash. If 1 addon has a problem, it simply is set to an error state and no longer receives events. Rather than causing all addons to mess up, only one is removed.

However, this does come with a drawback. Addons cannot directly communicate with each other.

This is where the libs folder comes in handy. Commonly used functions and such can be placed inside of the libs folder allowing all plugins to access them. This does not mean that plugins can talk to each other using this folder, it is simply a location where commonly used things can be put to allow all addons to access them.

If you land up needing to have addons communicate, you can make use of the command system. Have one addon invoke a command to be processed, and in another addon, handle that command.

addons.txt · Last modified: 2017/04/21 15:14 by atom0s