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

having trouble creating a menu! help!

Started by mrcrocodile123, 03 September 2012 - 08:13 AM
mrcrocodile123 #1
Posted 03 September 2012 - 10:13 AM
i have started attempting to create a menu however i am experiencing problems with variouse erors, i am now getting the error :

bios:206" [string "go"]:8: 'then' expected.

the code is posted below any help would be greatly appreciated! thanks


while x ~= "exit" do
print("——————————")
print("MAIN MENU")
print('To access the lighting menu interface enter "lights"')
print('to access the generator menu interface enter "generators"')
print("——————————")
x=io.read()
if x = "lights" then
while y ~= "exit" do
print("——————————")
print("LIGHTING MENU")
print('To turn on the lighting system enter "on"')
print('To turn off the lighting system enter "off"')
print('To return to the Main Menu enter "exit"')
print("——————————")
y=io.read()
if y = "on" then
rednet.open("left")
rednet.send(13, "lights on")
rednet.close("left")
end
end
end
Kazimir #2
Posted 03 September 2012 - 10:28 AM
operator comparison "=="
while x ~= "exit" do
  print("------------------------------")
  print("MAIN MENU")
  print('To access the lighting menu interface enter "lights"')
  print('to access the generator menu interface enter "generators"')
  print("------------------------------")
  x=io.read()
  if x == "lights" then
      while y ~= "exit" do
        print("------------------------------")
        print("LIGHTING MENU")
        print('To turn on the lighting system enter "on"')
        print('To turn off the lighting system enter "off"')
        print('To return to the Main Menu enter "exit"')
        print("------------------------------")
        y=io.read()
         if y == "on" then
           rednet.open("left")
           rednet.send(13, "lights on")
           rednet.close("left")
         end
      end
  end
end
mrcrocodile123 #3
Posted 03 September 2012 - 10:32 AM
thanks!