Last active
March 1, 2018 02:14
-
-
Save Mr-Coxall/ad80f753ee81036acaec5e96fdeca6bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------------------------------------------------------------------- | |
-- | |
-- 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