diff --git a/LUA-Events.md b/LUA-Events.md new file mode 100644 index 0000000..a432a1d --- /dev/null +++ b/LUA-Events.md @@ -0,0 +1,26 @@ +Within the LUA environment you can use events to react to certain things, such as the profile being updated or key being pressed. + +To use events you need to subscribe to them. You can subscribe to the same event more than once if you want. +The examples below show how subscribing works. + +### ProfileDrawing +Triggers whenever the profile is being drawn +#### Parameters +```lua +profile profile, profileDrawingEventArgs eventArgs +``` +#### Event Arguments +- **DataModel:** An object containing the current DataModel. *(TODO: DataModel explaination)* +- **Preview:** A boolean indicating whether the draw was done as a preview (for the editor). +- **Drawing:** The [Drawing](https://github.com/SpoinkyNL/Artemis/wiki/Drawing) object for this frame. Use this to draw your own shapes. + +#### Example +```lua +-- This function will be called after every profile draw. +function drawHandler(profile, eventArgs) + -- Put your code here +end + +-- Subscribe to the event AFTER defining the function which must be subscribed. +Events.ProfileDrawing.add(drawHandler); +``` \ No newline at end of file