This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
louitzie's profile picture

is there a way to manipulate incomming events?

Started by louitzie, 12 May 2012 - 02:26 PM
louitzie #1
Posted 12 May 2012 - 04:26 PM
Is there a way to manipulate incomming event?

so yes, how?
Lyqyd #2
Posted 12 May 2012 - 04:33 PM
That depends on what you mean by manipulate? You can replace the os.pullEvent() function with one with custom logic, but if you don't clean up that change afterward, it'll affect the whole system. What are you trying to do?
louitzie #3
Posted 12 May 2012 - 04:38 PM
i am making remote controll software

i want to edit some rednet messages to key and char event before the rest of the system gets it
Lyqyd #4
Posted 12 May 2012 - 04:54 PM
So, you'd want to do something like:


function customEvent(filter)
while true do
e, p1, p2, p3 = os.pullEvent()
if e = "rednet_message" then
--manipulate, change e to key/char, etc.
end
if filter then
	if e == filter then --should probably actually be a table or some such, I cannot remember how the filters work because I never use them!
		return e, p1, p2, p3
	end
else
	return e, p1, p2, p3
end
end
end

os.pullEvent = customEvent
louitzie #5
Posted 12 May 2012 - 07:08 PM
thanks it worked