Cutscene Hook

  • #1, by darren-beckettThursday, 10. March 2022, 17:55 2 years ago
    Is there a way I can Register a Hook for the Begin/End Cutscene?

    I wish to block keyboard input when cutscenes are in progress.

    Great Poster

    384 Posts


  • #2, by afrlmeThursday, 10. March 2022, 23:13 2 years ago
    You could use hide/show cursor action parts instead as they disable key inputs by default.

    Imperator

    7278 Posts

  • #3, by darren-beckettThursday, 10. March 2022, 23:28 2 years ago
    I want it to work globally, without the need to modify every action that's doing a begin/end cutscene.

    It also needs to work with the key handler that hooks up the Android Back button.

    Great Poster

    384 Posts

  • #4, by afrlmeFriday, 11. March 2022, 00:32 2 years ago
    Hmm, try this...

    defintion script:
    local BEGIN_END_CUTSCENE = 144
    
    system.registerActionPartHook(BEGIN_END_CUTSCENE, "checkCutscene")
    
    
    
    function checkCutscene(actionPart)
    
      if actionPart.Int == 0 then -- cutscene active
    
        Conditions["cutscene_active"].Value = true
    
      elseif actionPart.Int == 1 then -- cutscene inactive
    
        Conditions["cutscene_active"].Value = false
    
      end
      return false
    end
    
    
    -- * key event handler * --
    
    function keyboardHandler(eventType, character, keycode, modifiers)
    
      if Conditions["cutscene_active"].Value then
    
        return true -- key events disabled 
      else
    
        return false -- key events active
      end
    
    end
    
    
    
    registerEventHandler("keyEvent", "keyboardHandler")

    You also need to create a condition somewhere in your project - doesn't matter where - & call it "cutscene_active" & set it as false by default.

    The script above & that condition should prevent all key input while a begin/end cutscene is active.

    Imperator

    7278 Posts

  • #5, by darren-beckettFriday, 11. March 2022, 08:43 2 years ago
    Excellent, That looks like it will do the job.

    Great Poster

    384 Posts

  • #6, by darren-beckettFriday, 11. March 2022, 10:00 2 years ago
    This works great, thanks again.

    Great Poster

    384 Posts