Menu
Login
Language
DE EN FR ES IT CZ
Back

mainLoop and character switching

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

    Newbie

    9 Posts

  • #2, by afrlme Thursday, 05. May 2022, 14:53 3 years ago Quote
    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

    7290 Posts