disable key pressing when talking

  • #1, by sebastianMonday, 20. July 2015, 19:47 5 years ago
    In general i have one problem:
    When displaying text i am still allowed to open interfaces via a key-pressing (ESC) By that the text of a talking character (usually the current character) is displayed on top of the interface and that looks stupid.

    What i have to do now is to set a condition which disables the pressing of the ESC-Key and enable it afterwards.
    Usually i have to set it manually but maybe there is a hook or some kind of lua-script which can help me out here to change the conditions automatically if the display text action part is fired.

    any ideas, mates?

    kind regards
    Sebastian

    Thread Captain

    2337 Posts


  • #2, by afrlmeMonday, 20. July 2015, 20:08 5 years ago
    1. create a condition somewhere & name it: disable_esc.

    2. Add the script below to the script section.
    -- * function used to disable the escape key (prevents skipping of cut-scenes etc) * --
    function keyboardHandler(eventType, character, keycode, modifiers)
    if Conditions["disable_esc"].ConditionValue == true and keycode == eKeyEscape then return true end
    return false
    end

    registerEventHandler("keyEvent", "keyboardHandler")
    1
    2
    3
    4
    5
    6
    7
    8

    3. Before executing a display text action, add a change condition action part, link it to disable_esc & set to true. Alternatively you could create some textStarted & textStopped event listeners to automatically disable esc each time a text is displayed & enable it when a text stops.
    function txtStart(text)
    Conditions["disable_esc"].ConditionValue = true
    end

    function txtStop(text)
    Conditions["disable_esc"].ConditionValue = false
    end

    registerEventHandler("textStarted", "txtStart")
    registerEventHandler("textStopped", "txtStop")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11

    ... should work.

    P.S: there is actually an option in the game tab for determining if key actions are allowed to be executed when text is displayed. I think esc will still work either way as it defaults as a cancel key during cutscenes, videos & texts, if I remember correctly.

    Imperator

    6842 Posts

  • #3, by sebastianMonday, 20. July 2015, 20:56 5 years ago
    so i have to set it manually before / after each dislpayed text...i'll test it out with the lua-hook

    regarding the game options tab: there is only a point to disable it while in a dialog, which also doesnt work confuse

    EDIT: regarding your txtStart(text) / txtStop(text). Is it possible to determine if the text came from the current character? Now it disables itself when displaying object-texts inside the menu itself cry

    EDIT2:
    made it like that. it only disables the esc-function if it appears only outside of the menu:
    function txtStart(text)
    if Conditions["inside_esc_menu"].ConditionValue == false then
    Conditions["esc_menu_allowed"].ConditionValue = false
    end
    end

    function txtStop(text)
    Conditions["esc_menu_allowed"].ConditionValue = true
    end

    registerEventHandler("textStarted", "txtStart")
    registerEventHandler("textStopped", "txtStop")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

    Nevertheless i have to consider that some other background texts could mess up my menu again. but here i think i can build up on the "kill background texts - script " from the wiki

    Thread Captain

    2337 Posts

  • #4, by afrlmeMonday, 20. July 2015, 21:25 5 years ago
    Yes you can query the text owner & table it belongs to.

    Try this...
    function txtStart(text)
    if text.Owner:getId().tableId == eCharacters then
    Conditions["disable_esc"].ConditionValue = true
    end
    end
    1
    2
    3
    4
    5
    6

    ... it might be TextOwner instead of just Owner - I'm still trying to figure out all the new shorthand scripting methods.

    Anyway, the new query should only set the condition if text belongs to a character. You could also add an additional query if you want to limit it to a specific character instead of texts spoken by any character.

    Imperator

    6842 Posts

  • #5, by sebastianMonday, 20. July 2015, 22:32 5 years ago
    i used
    text:getLink(VTextOwner):getName() == game:getLink(VGameCurrentCharacter):getName() 
    1
    2

    in the if query.

    Thread Captain

    2337 Posts

  • #6, by afrlmeMonday, 20. July 2015, 23:15 5 years ago
    Sure that works too. You've used the old getObject (longhand) method, but it's not a problem. I prefer shorthand because I get to be lazy by not having to type as many characters! grin

    Imperator

    6842 Posts

  • #7, by sebastianMonday, 20. July 2015, 23:58 5 years ago
    hmm.... i have to check it then again and test yours to be "up to date". On the first try it didn't worked.

    Thread Captain

    2337 Posts

  • #8, by afrlmeTuesday, 21. July 2015, 01:15 5 years ago
    I quickly wrote most of it off the top of my head, which means it's a bit hit & miss in regards to whether I got it 100% right or not. I did say it might be TextOwner instead of just owner. It is actually possible to mix & match shorthand with the getObject method too.

    P.S: quick note: technically you could block all key input & not just the esc key by removing this bit "and keycode == eKeyEscape" from the key event function.

    Imperator

    6842 Posts

Write post