The "Behavior Sandbox"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search

The scripting engine is built in such a way that every single behavior operates in its own Lua environment. That means it does not have the ability to call functions or access Lua variables on other objects. This is to ensure that the basic simulation rules are followed and the engine can take care of maintaining the persistent state of the world with no effort on the part of the scripter.

Behaviors on objects find out about and manipulate the world around them through the defined interface fully documented in the “Shards Online Lua Interface” reference included with the server build. (docs/lua-reference/index.html) There are hundreds of functions and events that allow objects to become aware of and interact with the world around it.

Since you cannot call functions on other behaviors, you must send messages to communicate between them using the SendMessage function. This function can take just about any Lua data as a parameter including Lua tables.

Additionally, by providing you with all of the gameplay scripts for the default rules, you have tons of examples to work from. The best way to understand how a function works is to search for uses of it in the pre-existing Lua scripts. If you are using the suggested text editor (Sublime Text), the hotkey CTRL+SHIFT+F will allow you to search the entire scripts folder (Build/base/scripts) for examples.