Cutscene Hook

  • #1, z darren-beckettThursday, 10. March 2022, 17:55 hodinky 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.

    Čestný člen

    384 Posts


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

    Imperátor

    7285 Posts

  • #3, z darren-beckettThursday, 10. March 2022, 23:28 hodinky 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.

    Čestný člen

    384 Posts

  • #4, z afrlmeFriday, 11. March 2022, 00:32 hodinky 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.

    Imperátor

    7285 Posts

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

    Čestný člen

    384 Posts

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

    Čestný člen

    384 Posts