It extends the "redstone" event that os.pullEvent() returns with the sides that have changed.
The API keeps track of the redstone input states on all 6 sides of the computer.
If any of the redstone input states change, the event "redstone" will return a string denoting the type of redstone-input, as well as a table of all the sides that have changed.
If vanilla redstone was changed, type will be "vanilla".
If bundled cable was changed, type will be "bundled_cable".
http://en.wikipedia.org/wiki/WTFPL
Exposed Function
pullEvent( event, side )
- event is an optional event filter. ( Just like the native event filter, so nothing new. )
- side is a table of strings and acts as a side filter, i.e. you can choose to listen to only specific sides and ignore all others.
- Returns: event, type, changes
event == "redstone"
type == "vanilla" (for vanilla redstone) or "bundled_cable" (for redpower bundled cable)
changes = table of strings denoting the changed sides, e.g. { "back", "bottom }
String
Table
How to use?
- Save the API Code and make note of the filename, e.g. 're'
- Load the API within the program where you want to make use of it via os.loadAPI, e.g. os.loadAPI( "re" )
- Then call the API's pullEvent by accessing it via the API name, e.g. re.pullEvent()
API - Code
Pastebin: http://pastebin.com/egdXMS6X
Direct-View:
Spoiler
Example Program to try out the API
Save the API as "re".
Then run the program below, change some redstone inputs and see the results on screen.
Pressing "e" will exit the program.
Pastebin: http://pastebin.com/SpSbfa0h
Direct-View:
Spoiler