Jump to content

Removing Event Callback on player_common.lua


mathem99
 Share

Recommended Posts

Does anyone know how I can remove a specific event that is a local function from player_common?

Specifically I want to remove the "gotnewitem" function:

inst:ListenForEvent( "gotnewitem", function(it, data)
    if data.slot ~= nil or data.toactiveitem ~= nil then
      Print(VERBOSITY.DEBUG, "gotnewitem: ["..data.item.prefab.."]")
      if inst.components.driver and inst.components.driver:GetIsDriving() then
        inst.SoundEmitter:PlaySound("dontstarve_DLC002/common/HUD_water_collect_resource")
      else
        inst.SoundEmitter:PlaySound("dontstarve/HUD/collect_resource")
      end
    end
  end)

I can't use RemoveEventCallback from entityscript because it requires you link the fn on it (RemoveEventCallback(event, fn, source)), but the specific function for gotnewitem is local, so I can't do that. Does anyone know a solution to this?

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...