Advertisement
Mackan90096

String Randomizer

May 15th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. --[[This program made by Max Thor (AKA. Mackan90096.) You may use this in any of your program(s) as long as
  2. credit is given]]--
  3.  
  4.  
  5.  
  6. -- Variables --
  7. stringCount = 0
  8. oldY = 2
  9. newY = oldY + 1
  10. stringNum = 1
  11. -- Tables --
  12. local strings = { }
  13. -- End Tables --
  14. -- End Variables --
  15.  
  16. function check()
  17. if stringCount == tonumber(numb) then
  18. randomString = strings[math.random(#strings)]
  19. term.clear()
  20. term.setCursorPos(1,1)
  21. print("Your random string is: "..randomString)
  22. error()
  23. else
  24. term.setCursorPos(1,newY)
  25. write("String number: "..stringNum..": ")
  26. inputString = read()
  27. table.insert(strings, inputString)
  28. stringCount = stringCount + 1
  29. stringNum = stringNum + 1
  30. newY = newY + 1
  31. check()
  32. end
  33. end
  34.  
  35. function main()
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. write("How many strings> ")
  39. numb = read()
  40. check()
  41. end
  42.  
  43. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement