Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Random Name Picker by Short Circuit
- For use in...
- well...
- anything that needs random name picking.
- ]]--
- --Who all is participating in this?
- function getNames()
- --Fancy entry prompts FTW
- print("How many entries do you have?: ")
- --Get the number of entries to enter
- ent = io.read()
- makeSomeRoom(1)
- --Init that table!
- names = {}
- --Make a loop for us, will 'ya?
- for i = 1,ent do
- --Format the input prompt nicely for the user. :)
- print("Name in slot " .. i .. ": ")
- --Gotta be fancy 'bout that io.read() stuff.
- names[i] = io.read()
- makeSomeRoom(1)
- end
- end
- --Let's make things random up in here!
- function genRandomNumber(val)
- --True randomness seed.
- math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
- --Generate the winning number!
- winner = math.random(val)
- end
- --Now that we know who won, let's tell the user!
- function printNameWinner()
- --Call the random number gen- gonna want the number. :p
- genRandomNumber(ent)
- --Use that number to pick the winner! :D
- print(names[winner] .. " is the winner! :D")
- end
- --OCD functions start here
- --OCD pause function
- function pauseAndWait()
- --DOS/Windows-like pause text.
- print("Press the Enter key to continue...")
- --Waits for Enter to be pressed.
- io.read()
- end
- --OCD "make some spaces" function
- function makeSomeRoom(spaces)
- i = 1
- for i = 1, spaces do
- print("")
- end
- end
- --Now we start it all up!
- function initScript()
- --GIVE ME CREDIT :D
- print('----------------------------------')
- print(": :")
- print(": Random Name Picker :")
- print(": Written by Short Circuit :")
- print(": :")
- print("----------------------------------")
- makeSomeRoom(4)
- --Get the input from the user.
- getNames()
- makeSomeRoom(2)
- --Print the winner! :D
- printNameWinner()
- --Make some room! :P
- makeSomeRoom(2)
- --Pauses the script to let users copy the output.
- pauseAndWait()
- end
- --[[
- Okay. Everything is done...
- Oh, wait... I wrapped the init code in a function!
- Let's go ahead and call that, shall we?
- ]]--
- initScript()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement