Make Interface clickable ANYTIME | Interface, das jederzeit clickbar ist

  • #1, by irinahuw_Friday, 08. June 2018, 12:02 6 years ago
    Hello!

    I actually asked this question in a 5 year old thread, but it did not appear in the newest threads feed. That's why I am asking it here separately:

    Is it somehow possible to create an interface button that is clickable anytime, especially during dialogs?

    I want to do this because my game exhibited and people try it out. So it happens that people start the game and play it a bit and leave it, so that a dialog layer is open. The next player, who usually wants to restart the game, would have to finish the dialog first. But of course they try to click the restart button, which does not work because the dialog is still open. That is why I want to create an all-time-clickable-button for the restart.

    thank you and regards

    irina


    GERMAN

    Hallo!
    Ich würde gerne einen interface button haben, der IMMER klickbar ist, auch während dialogen. damit das spiel von jeder person, die es ausprobieren möchte, zu jederzeit neu gestartet werden kann, ohne dass die person sich zuerst durch einen dialog klicken muss.
    weil zurzeit ist es so, dass wenn jemand einen dialog angefangen hat und dann wegläuft, der nächste spieler sich theoretisch beim dialog durchclicken müsste, bevoer er den restart button drücken kann. das will ich natürlich nicht, da es nicht userfreundlich ist smile

    gruss und danke

    irina


    Newbie

    49 Posts


  • #2, by afrlmeFriday, 08. June 2018, 12:09 6 years ago
    Hmm, there's an option in the properties section of an interface to set the interface to display permanently.

    Alternatively if that doesn't work then you could assign it to a keyboard button like "R (released). You would also need to tick the "execute actions during a dialog" option on the main game settings page for that to work.

    Imperator

    7278 Posts

  • #3, by irinahuw_Friday, 08. June 2018, 12:19 6 years ago
    Hmm, there's an option in the properties section of an interface to set the interface to display permanently.

    Alternatively if that doesn't work then you could assign it to a keyboard button like "R (released). You would also need to tick the "execute actions during a dialog" option on the main game settings page for that to work.
    Hello AFRLme,

    thanks a lot, that thing with the key is a great idea for now!
    will try it out immediately smile

    Newbie

    49 Posts

  • #4, by irinahuw_Friday, 08. June 2018, 12:38 6 years ago
    unfortunately, the key action did not solve the problem. the problem seems
    that the action part "display text" is not skippable at all. also the answers from dialogues are not skippable with a keyaction.
    it is not a matter of the pauses i set for the displayed text, tested it.
    also checked the box to skip active text in the main menu...

    the interface is displayed permanently btw, but it doesn't help bc its not clickable during displayed text :/

    what else could i do?

    Newbie

    49 Posts

  • #5, by afrlmeFriday, 08. June 2018, 13:31 6 years ago
    Um, yeah... that's default behaviour for when a text is displayed as it is waiting for a left click response to skip.

    You could use the Lua event handler for key input instead as that will work regardless of what's going on with the engine.

    local i = 0
    
    function keyboardHandler(eventType, character, keycode, modifiers)
     if eventType == eEvtKeyDown then
      if character == 'R' and i == 0 then replaceGame("data.vis"); i = 1 end
     elseif eventType == eEvtKeyUp then
      i = 0   
     end
     return false -- key event will also be handled by engine
    end
     
    registerEventHandler("keyEvent", "keyboardHandler")

    add that to the script section. leave it as a definition script type. replace "data.vis" with whatever you called the vis file. delete the other key action you created.

    Quick note: eEvtKeyDown works like turbo on a gamepad, which means that it continuously loops whilever it is pressed down which is why I added the if i == 0 if query to it & set i to 1 if i was 0. Key released is technically better, but it means that the actions you tell it to do won't executed until the key is released instead of when you press the key down.

    Imperator

    7278 Posts

  • #6, by irinahuw_Friday, 08. June 2018, 14:12 6 years ago
    thank you so much AFRLme!

    i think it does the trick for now.
    when not being in the first scene, the command works perfectly fine in every situation.
    when pressed in the first scene, it executes the command but does not entirely restart with the intro scene and has to be pressed again. but  that's a detail and i hope the people who play it just press R another time.

    Newbie

    49 Posts

  • #7, by afrlmeFriday, 08. June 2018, 15:29 6 years ago
    Strange. I'm not sure why it wouldn't work in the first scene. Ah wait, it's because Lua variable carry over across the same play session regardless of whether or not you reload the game. Sorry, I forgot.

    Yeah, we don't actually need the i query part seeing as you are instantly restarting the game, though you could pop up an interface that asks people if they want to restart instead - might make more sense.

    If you do just want it to restart automatically then use this script instead...

    function keyboardHandler(eventType, character, keycode, modifiers)
     if eventType == eEvtKeyDown then
      if character == 'R' then replaceGame("data.vis") end
     end
     return false
    end
     
    registerEventHandler("keyEvent", "keyboardHandler")

    Imperator

    7278 Posts