Defining local key actions?

  • #1, by LebosteinThursday, 05. March 2015, 08:19 9 years ago
    It seems that key actions are only global. It would make easier much things if we could define key actions on scene level. At the moment only three different actions on scene level available:

    - Called by other action
    - At beginning of scene
    - At end of scene
    - If key 'keyname' is pressed <- that would be nice

    My problem is the ESC key for example. Pressing ESC changes in every menu scene to an other menu scene. So I have to create a variabale, that holds the number of the menu scene that I have to set with the 'beginn scene' and 'end scene' action and so on... If I could create a local 'Pressing ESC' action in every single menu scene, then all problems are solved.

    An other example to use local key actions could be an adventure game with many mini games. In every mini game scene you need other (or harder to handle: the same!) keys. So that is complex to handle if you have global key actions only. You need tons of variables and if-statements outside your scene definition that makes the game structure confused and difficult to maintain/extend.

    PS: Other helping thing would be an action part like 'If menu/scene is shown..'

    Key Killer

    621 Posts


  • #2, by afrlmeThursday, 05. March 2015, 12:16 9 years ago
    Nice idea. I believe I already requested on the dev tracker for some additional if query action parts... here's what I wrote on the tracker:


    I believe we could benefit from some more query action parts for the non-scripters such as...

    - if scene is [a scene, a menu, x scene]
    - if item held is [empty, any, x item]

    This is just 2 off the top of my head, but I'm sure you can probably think of some others that would be very beneficial to non-scripters.


    P.S: please feel free to mention any other queries you think might be useful as action parts & I'll add them to the feature request on the dev tracker, for the devs to take into consideration.

    Imperator

    7278 Posts

  • #3, by LebosteinThursday, 05. March 2015, 12:34 9 years ago
    My main request here is no action part. It is a "Execution type" of scene actions.

    Key Killer

    621 Posts

  • #4, by afrlmeThursday, 05. March 2015, 12:47 9 years ago
    Yes I know. At begin of scene, At end of scene & Called by other action are technically execution action parts because they are called. What you are suggesting would be an event handler, as it would require a loop.

    What is your issue exactly with using the ESC key? If it's only that you don't want it to show the menu when pressing esc on certain scenes then all you have to do is wrap the action in an if query linked to a condition or value. Then just set the value of said condition or value in an at begin & end action scene for the scenes you don't want to trigger it for.

    P.S: did you know that since 4.x we can now create key events using Lua script?

    You could actually create your actions inside of a table or inside of the main key handler function.

    P.P.S: I was talking about if queries in regards to the P.S bit you posted at the end of your message.

    Imperator

    7278 Posts

  • #5, by LebosteinThursday, 05. March 2015, 13:05 9 years ago
    OK, I understand. Is is not possible to mix unique begin/end scene actions with recurring key event handler actions. Then a new "key actions" panel on scene level (like the same as the global key panel) should the best way to implement this.

    This ESC thing was only an example...

    Key Killer

    621 Posts

  • #6, by afrlmeThursday, 05. March 2015, 13:23 9 years ago
    I agree that key events for scenes as well as global handler would be a nice feature. There's also the issue of would the key event added to a scene cancel out the global key event, or should it do both? That would be one of the issues of adding this feature.

    I've added it as a request on the dev tracker.

    Imperator

    7278 Posts

  • #7, by LebosteinThursday, 05. March 2015, 15:29 9 years ago
    What happens if I define two ESC events on global level in current version for example?

    I think the local key events should get a higher priority if there is an event for the same key on global and local level (that means: the global event is not triggered if a local event with the same key exist). I am not sure if this is possible to handle technically.

    Key Killer

    621 Posts

  • #8, by ke4Thursday, 05. March 2015, 15:37 9 years ago
    I have a few minigames where i'm using arrow keys, i need to have multiple conditions for that to define what the arrows should do. I know what you mean.

    Probably set higher priority to local events could work.

    Key Killer

    810 Posts

  • #9, by afrlmeThursday, 05. March 2015, 15:57 9 years ago
    Sure it would be possible. This would be where those boolean values (you hate so much) come in! grin

    I'm not sure what will happen to be honest, but it's not recommended.

    I guess an option could also be added to the action part to define if global key event should also be triggered or ignored...

    @ Ke4: I'm not sure if it's possible to access arrow keys with the Lua key event handler. If they were then you could probably create a table or simplified conditions for handling what each key is supposed to do. Either way condition or value queries is probably the best way to go.

    Imperator

    7278 Posts

  • #10, by LebosteinThursday, 05. March 2015, 15:58 9 years ago
    I think this gives a cleaner structure if all values, conditions and key events for a scene or a minigame could be defined within the scene. At the moment the global key events form a complex "outside point" in which you have to handle different scenes with different scene values and scene conditions. So it is hard to copy a key intensive scene or a minigame "as a package" from one game to an other without loss.

    Key Killer

    621 Posts