Fading an interface while an action is playing

  • #1, by tall-story-gamesFriday, 19. June 2020, 20:14 4 years 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

    42 Posts


  • #2, by afrlmeSaturday, 20. June 2020, 01:39 4 years 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

    7278 Posts

  • #3, by tall-story-gamesTuesday, 23. June 2020, 00:40 4 years ago
    That's a shame, thanks for getting back to me anyway smile

    Newbie

    42 Posts

  • #4, by SimonSTuesday, 23. June 2020, 11:47 4 years 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")

    Thread Captain

    1581 Posts

  • #5, by afrlmeTuesday, 23. June 2020, 12:40 4 years 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

    7278 Posts