Skip to content

Instantly share code, notes, and snippets.

@Mr-Coxall
Last active March 1, 2018 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mr-Coxall/ad80f753ee81036acaec5e96fdeca6bb to your computer and use it in GitHub Desktop.
Save Mr-Coxall/ad80f753ee81036acaec5e96fdeca6bb to your computer and use it in GitHub Desktop.
-----------------------------------------------------------------------------------------
--
-- command line Lua
--
-- show how to use an if statement
-- and random numbers
--
-----------------------------------------------------------------------------------------
math.randomseed( os.time() )
local numberToGuess = math.random( 1, 6 )
local answer
local answerAsNumber
-- io.write(numberToGuess)
io.write( "Pick a number from 1 to 6: " )
answer=io.read()
answerAsNumber = tonumber(answer)
if numberToGuess == answerAsNumber then
io.write( "Correct" )
end
io.write( "Program done." )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment