Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a builtin for event management #124

Open
Deewarz opened this issue Jan 12, 2025 · 3 comments
Open

Create a builtin for event management #124

Deewarz opened this issue Jan 12, 2025 · 3 comments
Labels
enhancement New feature or request priority:medium question Further information is requested research This one only requires research

Comments

@Deewarz
Copy link
Contributor

Deewarz commented Jan 12, 2025

Description

Instead of listenEvent, could we set up a builtin Event?

It could have an on method (Event.on(eventName, eventListener)) and in the future an emit method to emit events (Event.emit(eventName [, ...args]))

What do you think about it?

Examples

Event.on("onPlayerConnected", function (player)
  Console.log("[GAMEMODE] Player " .. player.nickname .. " connected!")
end)

Event.on("myCustomEvent", function (myProp)
  Console.log("[GAMEMODE] myProp " .. myProp)
end)

local myProp = "hello world"
Event.emit("myCustomEvent", myProp)
@Deewarz Deewarz changed the title [Discussion] [Scripting] Create an builtin for event management [Discussion] [Scripting] Create a builtin for event management Jan 12, 2025
@zpl-zak
Copy link
Member

zpl-zak commented Jan 12, 2025

Sounds good to me, Event module could also harbor any additional features that are relevant to event handling.

@Deewarz
Copy link
Contributor Author

Deewarz commented Jan 13, 2025

I can do it :)

@Segfaultd do you agree?

@Segfaultd
Copy link
Member

Yes sounds good. But the emit function shouldn't allow to call builtin events as a security matter. Only user-defined ones.

@Segfaultd Segfaultd changed the title [Discussion] [Scripting] Create a builtin for event management Create a builtin for event management Jan 14, 2025
@Segfaultd Segfaultd added enhancement New feature or request question Further information is requested research This one only requires research priority:medium labels Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:medium question Further information is requested research This one only requires research
Projects
Status: No status
Development

No branches or pull requests

3 participants