You still need the rest of the previous code (the runShell function and the parallel call):
local nTime = 1
local sSide = "right"
local function checkInput()
local timer = os.startTimer(nTime)
while true do
local evt, arg = os.pullEvent("timer")
if arg == timer then
if not rs.getInput(sSide) then
print("Goodbye")
sleep(1)
break
end
timer = os.startTimer(nTime)
end
end
end
local function runShell()
shell.run("/rom/programs/shell") -- added the full path (just in case)
end
term.clear()
term.setCursorPos(1, 1) -- clear the screen, so it doesn't show "CraftOS 1.3" twice
parallel.waitForAny(runShell, checkInput)
os.shutdown()
Just save this as startup and it should run when you turn on the computer (unless there's a disk with a startup program).
Edit:
Just realized that this can be done with a redstone event, so it doesn't check all the time:
local sSide = "right"
local function checkInput()
while true do
local evt = os.pullEvent("redstone")
if not rs.getInput(sSide) then
print("Goodbye")
sleep(1)
break
end
end
end
local function runShell()
shell.run("/rom/programs/shell") -- added the full path (just in case)
end
if not rs.getInput(sSide) then -- first check, so it doesn't turn on if there's no redstone input.
os.shutdown()
end
term.clear()
term.setCursorPos(1, 1) -- clear the screen, so it doesn't show "CraftOS 1.3" twice
parallel.waitForAny(runShell, checkInput)
os.shutdown()
And it's shorter this way :P/>/>