Scene Actions API #86

Closed
opened 2022-10-18 14:00:48 +02:00 by kazhnuz · 4 comments
Owner

A SceneAction would be a very simple object, tied to the scene, that would just have the current scene as a . It will have a series of functions

-- Adding an action in the def
Scene.def = {
  actions = "scenes.scenename.actions"
}
-- The action call from a scene
function Scene:action(name, args)
  assert(self.actions[name] ~= nil, "Action " .. name .. " doesn't exists")
  self.actions[name](args)
end

Uses:

  • Handle the actions of a menu
  • Could be used to bind key events to an action ? (later, could be used as a base to bind a player to a function)

Notes:

  • Could also be part of both the gui screen and the scene ?
  • Maybe have a "source" that could be usefull for an action ?
A SceneAction would be a very simple object, tied to the scene, that would just have the current scene as a . It will have a series of functions ```lua -- Adding an action in the def Scene.def = { actions = "scenes.scenename.actions" } ``` ```lua -- The action call from a scene function Scene:action(name, args) assert(self.actions[name] ~= nil, "Action " .. name .. " doesn't exists") self.actions[name](args) end ``` Uses: - Handle the actions of a menu - Could be used to bind key events to an action ? (later, could be used as a base to bind a player to a function) Notes: - Could also be part of both the gui screen and the scene ? - Maybe have a "source" that could be usefull for an action ?
kazhnuz added the
3. Need investigation
1. Feature
2. Deliverable
4. Scenes
labels 2022-10-18 14:00:48 +02:00
Author
Owner

Maybe that instead of using another object to hold the action, the API should just be a callback system, to link an action to a function.

The "action" would be the caller of the function, for instance

callbackSource = {object = "scene", function = "pause", ""}
-- objectname can be "scene", "screen", "self"... default to the def ?
-- function is mandatory, it's the function name
-- args is a table of arguments, default to null
Maybe that instead of using another object to hold the action, the API should just be a callback system, to link an action to a function. The "action" would be the caller of the function, for instance ```lua callbackSource = {object = "scene", function = "pause", ""} -- objectname can be "scene", "screen", "self"... default to the def ? -- function is mandatory, it's the function name -- args is a table of arguments, default to null ```
kazhnuz reopened this issue 2022-11-07 11:21:58 +01:00
Author
Owner

The "action API" could also be handled by a special mixin that would contain the function to sanitize and call an action

The "action API" could also be handled by a special mixin that would contain the function to sanitize and call an action
kazhnuz added this to the epervier 0.8.0 (beta 1) milestone 2022-11-09 09:56:19 +01:00
Author
Owner

Same API than the one used for key events.

Same API than the one used for key events.
Author
Owner

Nope

Nope
Sign in to join this conversation.
No description provided.