mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Updated LUA Events (markdown)
parent
b8e9fbbcf8
commit
285350c83a
@ -1,10 +1,37 @@
|
|||||||
Within the LUA environment you can use events to react to certain things, such as the profile being updated or key being pressed.
|
Within the LUA environment you can use events to react to certain things, such as the profile being updated or a 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.
|
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.
|
The examples below show how subscribing works.
|
||||||
|
|
||||||
|
---
|
||||||
|
### ProfileUpdating
|
||||||
|
Triggers whenever the profile is being updated. Use this event to process your own changes **before** every frame.
|
||||||
|
If you want to change the way a layer is drawn, this is a good place to do so.
|
||||||
|
#### Parameters
|
||||||
|
```lua
|
||||||
|
profile profile, profileUpdatingEventArgs 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).
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- This function will be called after every profile update, before every profile draw.
|
||||||
|
function updateHandler(profile, eventArgs)
|
||||||
|
-- Put your code here
|
||||||
|
-- The Event Arguments are inside the eventArgs parameter, in a Windows Profile, you could do this:
|
||||||
|
local currentSong = eventArgs.DataModel.Spotify.SongName;
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
||||||
|
Events.ProfileDrawing.add(updateHandler);
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
### ProfileDrawing
|
### ProfileDrawing
|
||||||
Triggers whenever the profile is being drawn
|
Triggers whenever the profile is being drawn. Use this event to draw your own shapes **after** every frame.
|
||||||
|
For more info on drawing, see the [Drawing](https://github.com/SpoinkyNL/Artemis/wiki/Drawing) page.
|
||||||
#### Parameters
|
#### Parameters
|
||||||
```lua
|
```lua
|
||||||
profile profile, profileDrawingEventArgs eventArgs
|
profile profile, profileDrawingEventArgs eventArgs
|
||||||
@ -26,3 +53,27 @@ end
|
|||||||
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
||||||
Events.ProfileDrawing.add(drawHandler);
|
Events.ProfileDrawing.add(drawHandler);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
### KeyboardKeyPressed
|
||||||
|
Triggers whenever the user presses a key.
|
||||||
|
#### Parameters
|
||||||
|
```lua
|
||||||
|
profile profile, keyboard keyboard, keyPressEventArgs eventArgs
|
||||||
|
```
|
||||||
|
#### Event Arguments
|
||||||
|
- **Key:** The key that was pressed, for a list of possible keys, see [MSDN](https://msdn.microsoft.com/en-us/library/system.windows.forms.keys(v=vs.110).aspx).
|
||||||
|
- **X:** The X-position of the key on the current keyboard
|
||||||
|
- **Y:** The Y-position of the key on the current keyboard
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
```lua
|
||||||
|
-- This function will be called after every key press.
|
||||||
|
function keyHandler(profile, eventArgs)
|
||||||
|
-- Put your code here
|
||||||
|
print("You pressed: " .. eventArgs.Key .. " - X: " .. eventArgs.X .. ", Y: " .. eventArgs.Y);
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Subscribe to the event AFTER defining the function which must be subscribed.
|
||||||
|
Events.KeyboardKeyPressed.add(keyHandler);
|
||||||
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user