This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Maximus230x's profile picture

Help with new program

Started by Maximus230x, 29 May 2013 - 01:20 PM
Maximus230x #1
Posted 29 May 2013 - 03:20 PM
Topic: Program reset? I have a program I've been working on that isn't quite complete, but I've run into a problem where, after line 17, where it asks "yes/no", the program resets itself and the "CraftOS 1.5" message appears back at the top of the screen. It's an advanced computer with an advanced monitor on the right of it.
l
local a = ""
local m = peripheral.wrap("right")
local p = ""
while p ~= "Maximus" do
--change Maximus to your password
   term.write("Enter password: ")
   p = read()
   sleep(2)
   print("Verifying, please wait...")
   if p ~= "Maximus" then
	  sleep(3)
	  print("Incorrect, please retry")
   end
end
sleep(3)
print("Correct, hello Maximus230x")
term.write("Initiate access sequence?(yes/no)")
a = read()
if a == yes then
   print("please look at monitor")
   m.setTextScale(5)
   m.setBackgroundColor(colors.red)
   m.setTextColor(colors.black)
   m.write("Warning")
   m.write("Nuclear testing ahead")
   m.write("enter activation code")
elseif a == no then
   print("Very well, accessing files...")
   sleep(2)
   print("You may now access terminal")
else
   print("Invalid response, rebooting")
   os.reboot()
end
LBPHacker #2
Posted 29 May 2013 - 04:41 PM
At line 19,
a == yes
yes is nil. I believe you meant "yes". By the way, if you had put a sleep before reboot, you would have spot that mistake a long ago.
Maximus230x #3
Posted 29 May 2013 - 05:57 PM
Thank you, forgot you needed quotes around a string