Fading an interface while an action is playing

  • #1, by tom-hardwidgeFriday, 19. June, 20:14 3 months ago
    Hi, I am building a game with a verb interface which is visible all of the time.
    I would like to be able to set the opacity of the interface when a verb action is started (e.g. "Look at Lamp").

    I would then like it to set it back to full opacity when the action has been completed.

    Is there any way to create a function/event listener which will do this for me?

    I've got the snippet which will change the opacity of my Interface:  Interfaces["Verbs"].Visibility = 30

    And I've tried adding a listener on the Main Loop and on a textStarted event, but I just don't seem to be able to get the syntax right, or I'm approaching it the wrong way.

    Sorry, I'm very new to this!

    Thanks
    Tom

    Newbie

    19 Posts


  • #2, by afrlmeSaturday, 20. June, 01:39 3 months ago
    I'm not sure that a global solution is available for that. The only valid method I can think of is setting the opacity at the beginning of each of your action blocks & restoring it at the end of each action block, but I'm sure you already knew that, which is why you are asking for a global solution.

    Yeah, no. I can't think of any solution that wouldn't require a load of work, sorry.

    Imperator

    6842 Posts

  • #3, by tom-hardwidgeTuesday, 23. June, 00:40 3 months ago
    That's a shame, thanks for getting back to me anyway smile

    Newbie

    19 Posts

  • #4, by SimonSTuesday, 23. June, 11:47 3 months ago
    If you always have Begin of cutscene in your actions, you can listen for VGameCutsceneAction. Also there VGameCurrentText. So e.g.:

    local cutscenerunning = false
    function onMainLoop()
      if game.CutsceneAction.empty and game.CurrentText.empty and cutscenerunning then
         cutscenerunning  = false
         Interfaces["Verbs"].Visibility = 100
      elseif not cutscenerunning and (not game.CutsceneAction.empty or not game.CurrentText.empty) then
         cutscenerunning  = true
         Interfaces["Verbs"].Visibility = 20
      end
    end

    registerEventHandler("mainLoop", "onMainLoop")
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    Thread Captain

    1368 Posts

  • #5, by afrlmeTuesday, 23. June, 12:40 3 months ago
    What, no tweening?  tsk! tsk! :shakeshark:

    grin

    Don't forget: or game.HideCursor, in case they use that instead of begin/end cutscene.

    Imperator

    6842 Posts

Write post