Personal tools

Lua/Tutorials/Cross-module communication

From JC2-MP Documentation

< Lua‎ | Tutorials
Jump to: navigation, search

There are two suggested ways to allow Lua modules to interact: firing events and SQL databases.

Using Events

Events:Subscribe and Events:Fire work between modules. Using them is simple: Module A uses Events:Subscribe as normal, but, instead of subscribing to one of the event names the API provides, use your own name. When Module B uses Events:Fire with the same event name, Module A receives it.

Module A
Events:Subscribe("Banana", MyFunction)
Module B