diff --git a/bash/randTest.sh b/bash/randTest.sh index 7c9902a..8010b60 100755 --- a/bash/randTest.sh +++ b/bash/randTest.sh @@ -19,4 +19,3 @@ if [ "$answer" = yes ] fi echo "Exiting" exit 0 - diff --git a/lua/randTestExperiment.lua b/lua/randTestExperiment.lua new file mode 100644 index 0000000..b056999 --- /dev/null +++ b/lua/randTestExperiment.lua @@ -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 diff --git a/lua/randTestHelped.lua b/lua/randTestHelped.lua index c338d7e..6221992 100644 --- a/lua/randTestHelped.lua +++ b/lua/randTestHelped.lua @@ -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 \ No newline at end of file +end