Jump to content

Big reactor

1 reply to this topic

#1 Blade2277

  • New Members
  • 2 posts

Posted 26 February 2019 - 04:53 AM

I am writing a program to control my big reactor but i am stuck on making the UI. I cant get it to enter the computer to enter the if statement, it just ignores it.
print("Press 1 to edit control rod settings")
a = io.read()
if a==1 then
   print("Enter Control Rod settings")

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 27 February 2019 - 02:45 PM

io.read() always returns strings, but 1 is a number: so your condition will never be true.


You could do:

if a=="1" then

Or, instead:

a = tonumber(io.read())

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users