Rockschwein Posted March 25, 2016 Share Posted March 25, 2016 i am working on my mod character and i add a keyuphandler at lv 10: "TheInput:AddKeyUpHandler(KEY_R, function())" does someone know how to delete the keyuphandler, for example at lv 20? is it "TheInput:RemoveKeyuphander(KEY_R, function())"? Link to comment https://forums.kleientertainment.com/forums/topic/65741-how-to-remove-a-keyuphandler/ Share on other sites More sharing options...
CarlZalph Posted March 25, 2016 Share Posted March 25, 2016 The easier way to handle this is to have an always-on handler that checks some internal variable to see if it does anything, such as in your case having a level check that is >= 10 and < 20. The harder way from what you are doing but should be possible from the code here by removing the handler... From scripts/input.lua:112-114: function Input:AddKeyUpHandler( key, fn ) return self.onkeyup:AddEventHandler(key, fn) end From scripts/events.lua:17-36: function EventProcessor:AddEventHandler(event, fn) local handler = EventHandler(event, fn, self) if self.events[event] == nil then self.events[event] = {} end self.events[event][handler] = true return handler end function EventProcessor:RemoveHandler(handler) if handler then local ev = self.events[handler.event] if ev then ev[handler] = nil end end end TheInput:AddKeyUpHandler(KEY_R, function()) This should return the EventHandler created in AddEventHandler. So you'd store this handle in your mod's global space. SomeVar = TheInput:AddKeyUpHandler(KEY_R, function()) Then kill it later with: TheInput.onkeyup:RemoveHandler(SomeVar) Link to comment https://forums.kleientertainment.com/forums/topic/65741-how-to-remove-a-keyuphandler/#findComment-738393 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