Advertisement
Dima99

Random generator

Oct 7th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. arg = { ... }
  2. name = shell.getRunningProgram()
  3. dir = shell.dir()
  4. text = ""
  5. rand = 0
  6. fin = 0
  7. let = ""
  8. select = 0
  9.  
  10. function letter()
  11.  rand = math.random(1, 5)
  12.  if rand == 1 then
  13.  let = "a"
  14.  elseif rand == 2 then
  15.  let = "b"
  16.  elseif rand == 3 then
  17.  let = "c"
  18.  elseif rand == 4 then
  19.  let = "d"
  20.  elseif rand == 5 then
  21.  let = "e"
  22.  end
  23. end
  24.  
  25. function finger()
  26.  fin = math.random(0, 9)
  27. end
  28.  
  29. function testKey()
  30.  if fs.exists(dir.."/key") then
  31.  fs.delete(dir.."/key")
  32.  end
  33. end
  34.  
  35. function select()
  36.  if arg[1] == nil then
  37.   print("Use 8 for randomizer.")
  38.   arg[1] = 8
  39.  end
  40.  for i = 1, arg[1] do
  41.   select = math.random(1, 2)
  42.   if select == 1 then
  43.    letter()
  44.    text = text .. let
  45.    elseif select == 2 then
  46.    finger()
  47.    text = text .. tostring(fin)
  48.   end
  49.  end
  50.  print(text)
  51. end
  52.  
  53. select()
  54. testKey()
  55. h = fs.open(dir.."/key", "w")
  56. h.writeLine(text)
  57. h.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement