r/ComputerCraft • • Sep 29 '21

I need help stopping a program.

Hello, I found this really cool Matrix Rain code for computercraft, pastebin here : https://pastebin.com/bXvr0vuN

When I make the program a startup the startup never ends, was wondering if someone could make it stop after a certain amount of seconds. Thanks!

5 Upvotes

7 comments sorted by

View all comments

5

u/JackMacWindowsLinux CraftOS-PC & Phoenix Developer Sep 29 '21

I'd recommend throwing the program inside a parallel.waitForAny call like this:

parallel.waitForAny(
    function() shell.run("rain.lua") end,
    function() sleep(30) end
)

This will run the program, stopping it when the 30-second timer finishes.

1

u/Icewing_Nix Oct 01 '21

Okay, this works great, but one problem. I want to run another shell program thing right after the matrix rain ends. Nothing seems to work, how would I do that?

Like, this is what I am doing:

parallel.waitForAny(

function() shell.run(".matrixrain") end,

function() sleep(10) end

)

shell.run("OS")

I want the matrix rain to be for the beginning to my OS

1

u/JackMacWindowsLinux CraftOS-PC & Phoenix Developer Oct 01 '21

That should work just fine; just make sure to clear the screen first.

1

u/Icewing_Nix Oct 01 '21

Gotcha, thanks!