Posted 01 September 2014 - 03:48 PM
Hi,
I'm relatively new to computercraft and I couldn't work out how to get my startup program to run another program if it already hasn't been run.
Here's my startup:
And here's the "firsttimecomplete" program it runs:
Can you spot any errors or possibly help me to finish this?
Thanks,
- Sam
I'm relatively new to computercraft and I couldn't work out how to get my startup program to run another program if it already hasn't been run.
Here's my startup:
--[CLIENT]--
term.clear()
term.setCursorPos(1,1)
rednet.open("right")
print("Login ID required.")
local user = read()
rednet.send(0, user..".1")
start = 1
while start == 1 do
event, id, text = os.pullEvent()
if event == "rednet_message" then
if text == "succ01.2" then
print("Passcode required.")
pass = read("*")
rednet.send(0, pass..".3")
while true do
local event, id, text = os.pullEvent()
if event == "rednet_message" then
if text == "succ01.4" then
print("Logged in successfully!")
start = 2
shell.run("firsttime")
break
elseif text == "fail01.4" then
print("Incorrect password.")
sleep(2)
os.reboot()
end
end
end
end
end
end
And here's the "firsttime" program it runs:
local Table = {complete = "firsttimedone"}
if complete == true then
term.clear()
print("Logged in successfully.")
else
print("First time setup running.")
print("Please enter a username to use with services.")
local userservices = read()
print("Your username has been set to "..userservices)
print("First time setup complete.")
shell.run("firsttimecomplete")
end
And here's the "firsttimecomplete" program it runs:
local firsttimecomplete = true
Can you spot any errors or possibly help me to finish this?
Thanks,
- Sam