ComputerCraft Forums

ComputerCraft => Programs => Turtle Programs => Topic started by: Kaikaku on Apr 17, 2021, 10:19 PM

Title: Wait for event (easy event access)
Post by: Kaikaku on Apr 17, 2021, 10:19 PM
tWaitFor & tSend

This program(s) makes using 5 events from the ComputerCraft event system easy to use.
So it's less scary to try out those events. After knowing what you can do with it,
maybe you tackle os.pullEvent() on your own, for tailor made solutions for your program ideas?

The program uses these event to wait for:

You can specify multiple events to stop waiting for events. Each event is specified with exactly 3 arguments.
If you provide one additional argument, then this will be executed in shell.run().
The program returns the number of the event that triggered, so you can build quite complex stuff with it.
When you add as last argument silenced, then tWaitFor will not mess with the screen (i.e. no print no term.clear()).
If you are using the last argument to execute a program, then add silenced right in front of the program call w/o spaces etc.
e.g., tWaitFor redstone front change "silenceddance" (I know, that's a bit wonky)
You get also ingame infos, when you call it w/o any arguments: tWaitFor

The program can be called:

To make sending rednet messages easier (to trigger events), you can use tSend. However, you can only specify the channel and the message, e.g., tSend 1 "my password"

Pastebin:
tWaitFor https://pastebin.com/9vzPCd4T (https://pastebin.com/9vzPCd4T)
tSend https://pastebin.com/h3xcC9S1 (https://pastebin.com/h3xcC9S1)

Video:
In the video I do showcase some applications and also do some code walkthroughs, to show how to use tWaitFor in a startup program.