Rework the event system to make it script-based #6

Open
opened 2025-04-11 15:29:25 +02:00 by kazhnuz · 2 comments
Owner

Several possibilities :

  • The script return a function that take a eventHandler as a argument, and stuff like "eventHandler:move()" only add an action to a list
  • The script is loaded while the eventHandler add a context which make it the target of something like $
  • The script is loaded in another thread or context that communicate with the main thread and give it orders, and wait after all functions that the main thread have finished the actions.
Several possibilities : - The script return a function that take a eventHandler as a argument, and stuff like "eventHandler:move()" only add an action to a list - The script is loaded while the eventHandler add a context which make it the target of something like `$` - The script is loaded in another thread or context that communicate with the main thread and give it orders, and wait after all functions that the main thread have finished the actions.
kazhnuz added the
Type
Enhancement
Domaine
Engine
Compat
Breaking
Priority
Critical
labels 2025-04-11 15:29:25 +02:00
kazhnuz added this to the Init project project 2025-04-11 15:29:25 +02:00
Author
Owner
https://love2d.org/forums/viewtopic.php?t=12351
Author
Owner

Definition d'un event

local WaitEvent = event {
  category = "time",
  need = {},
  args = {
    {name = "duration", nullable = false, type = number}
  }
}

WaitEvent:start(duration)
  self.duration = duration
  self.isBlocking = true
end

WaitEvent:update(dt)
  self.duration = self.duration - dt

  if (duration <= 0) then
    self.isBlocking = false
  end
end
Definition d'un event ```lua local WaitEvent = event { category = "time", need = {}, args = { {name = "duration", nullable = false, type = number} } } WaitEvent:start(duration) self.duration = duration self.isBlocking = true end WaitEvent:update(dt) self.duration = self.duration - dt if (duration <= 0) then self.isBlocking = false end end ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: game-projects/serum#6
No description provided.