Experimentation

This commit is contained in:
2026-05-05 21:57:20 -07:00
parent 54666fd55c
commit 41c53e86ec
3 changed files with 29 additions and 4 deletions

View File

@@ -0,0 +1,26 @@
-- Assistance from a friend
-- Instantiate all the things
local run = true
local cmd, number, randnum
-- Start a loop
while run == true do
-- Get the users initial number
io.write("Pick a number: ")
number = io.read("*n")
-- Do some mathemagic
-- randnum = math.random(1, number)
print("The random number is ", math.random(1, number))
-- Ask to rerun script
io.read()
print("Run again (Y/n)?")
cmd = io.read("*l")
-- Exit if the user doesn't want to go again
if string.lower(cmd) ~= "y" then
run = false
end
end

View File

@@ -7,12 +7,12 @@ local cmd, number, randnum
-- Start a loop
while run == true do
-- Get the users initial number
print("Pick a number: ")
io.write("Pick a number: ")
number = io.read("*n")
-- Do some mathemagic
randnum = math.random(1, number)
print("The number is ", randnum)
print("The random number is ", randnum)
-- Ask to rerun script
io.read()
@@ -23,4 +23,4 @@ while run == true do
if string.lower(cmd) ~= "y" then
run = false
end
end
end