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

[LUA]cant figure it out

Started by josechibi, 20 August 2012 - 02:58 PM
josechibi #1
Posted 20 August 2012 - 04:58 PM
Im trying to make a code for my reactor but i dosent seem to work i can figure out why so i ask for some help.
every thing above the if works

nuke = "1712"
print ("Nuke Reactor Enter Code to Launch")
write "Launch Code: "
input = read()
print ("Reactor Running")
redstone.setOutput ("left", true)
sleep(5)
if
input == off then
print ("shutdown")
sleep(2)
os.shutdown()
else
print ("Not valid Code/Command")
sleep(2)
end
end
please help
sjele #2
Posted 20 August 2012 - 05:03 PM

nuke = "1712"
print ("Nuke Reactor Enter Code to Launch")
write("Launch Code: ")  --You need ( and ) here.
input = read()
if input == nuke  --Added this so it will work
  print ("Reactor Running")
  redstone.setOutput ("left", true)
  sleep(5)
elseif input == "off" then
  print ("shutdown")
  sleep(2)
  os.shutdown()
else
  print ("Not valid Code/Command")
  sleep(2)
end

This should work
Cranium #3
Posted 20 August 2012 - 05:07 PM

nuke = "1712"
print ("Nuke Reactor Enter Code to Launch")
write("Launch Code: ")  --You need ( and ) here.
input = read()
if input == nuke  --Added this so it will work
  print ("Reactor Running")
  redstone.setOutput ("left", true)
  sleep(5)
elseif input == "off" then
  print ("shutdown")
  sleep(2)
  os.shutdown()
else
  print ("Not valid Code/Command")
  sleep(2)
end

This should work
Actually, for commands that only accept strings, the "()" is not necessary.

print("Correct")
and

print "correct"
Should do the same thing.
sjele #4
Posted 20 August 2012 - 05:08 PM

nuke = "1712"
print ("Nuke Reactor Enter Code to Launch")
write("Launch Code: ")  --You need ( and ) here.
input = read()
if input == nuke  --Added this so it will work
  print ("Reactor Running")
  redstone.setOutput ("left", true)
  sleep(5)
elseif input == "off" then
  print ("shutdown")
  sleep(2)
  os.shutdown()
else
  print ("Not valid Code/Command")
  sleep(2)
end

This should work
Actually, for commands that only accept strings, the "()" is not necessary.

print("Correct")
and

print "correct"
Should do the same thing.


Hmm. i did not know that. Thank you :D/>/>
I guess i "corrected", a working line then :P/>/>
josechibi #5
Posted 20 August 2012 - 06:05 PM

nuke = "1712"
print ("Nuke Reactor Enter Code to Launch")
write("Launch Code: ")  --You need ( and ) here.
input = read()
if input == nuke  --Added this so it will work
  print ("Reactor Running")
  redstone.setOutput ("left", true)
  sleep(5)
elseif input == "off" then
  print ("shutdown")
  sleep(2)
  os.shutdown()
else
  print ("Not valid Code/Command")
  sleep(2)
end

This should work
Actually, for commands that only accept strings, the "()" is not necessary.

print("Correct")
and

print "correct"
Should do the same thing.
wow that's gonna help me a lot
and thank you for your help