mathem99 Posted December 2, 2023 Share Posted December 2, 2023 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? 1 Link to comment https://forums.kleientertainment.com/forums/topic/152845-removing-event-callback-on-player_commonlua/ Share on other sites More sharing options...
Rickzzs Posted December 13, 2023 Share Posted December 13, 2023 something like for k,v in pairs(inst.event_listener.gotnewitem) do local info=debug.getinfo(v) if info.source:find("player_common") then table.remove(inst.event_listener.gotnewitem,k) break end end 1 Link to comment https://forums.kleientertainment.com/forums/topic/152845-removing-event-callback-on-player_commonlua/#findComment-1688157 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now