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

BirdEvents

Started by Gumball, 22 October 2015 - 07:23 AM
Gumball #1
Posted 22 October 2015 - 09:23 AM
So, I made a tool where you can have an event listener thats easy to use (and inspired by JavaScript), you just do the following.


addEventListener(function(param1,param2,param3,param4,param5) --[[Do Stuff with the passed arguments]] end,"an event")

You don't need to follow it exactly, its just so you know how to use it without having to read the code. Its mainly for use so you don't have to have a ton of if's and elseif's in say like, an OS. You just need one function with a sub function. It runs with coroutines so you just have to make another coroutine with your main code in it, or since this is event driven have it just run off of the event listeners. So yeah. Credit would be nice, if you use it, but it's free use. Without further adieu, pastebin get s5VHjhkz [name]
Edited on 22 October 2015 - 07:55 AM
Creator #2
Posted 22 October 2015 - 04:36 PM
Are the params the things returned by the event? If yes do this: function(…) end instead.
Lignum #3
Posted 22 October 2015 - 04:41 PM
Are the params the things returned by the event? If yes do this: function(…) end instead.

No need, since Lua is dynamically typed, it doesn't matter what the parameter list looks like, as long as the parameters are there and in the correct order.