mainLoop and character switching

  • #1, by daniel-lowesThursday, 05. May 2022, 11:49 2 years ago
    Is it possible to be notified of when a character is changed by listening to the mainLoop events?

    Newbie

    9 Posts


  • #2, by afrlmeThursday, 05. May 2022, 14:53 2 years ago
    Defintion type script:
    
    
    local char = nil -- used to store & check current character
    
    local CHANGE_CHARACTER = 12 -- change character action part ID
    
    system.registerActionPartHook(CHANGE_CHARACTER, "changeCharacter")
    
    
    
    function changeCharacter(actionPart)
    
      if char ~= actionPart.Link:getName() then
    
        char = actionPart.Link:getName() -- update current char name
    
        -- insert code here that you want to execute or call a called by other action block like so: startAction( Actions["example"] )
    
      end
    
      -- return true -- don't execute (prevents action part from executing)
    
      return false -- still execute
    
    end


    Imperator

    7278 Posts