Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- monkey_typewriter.lua
- math.randomseed(os.time())
- -- characters the "monkey" can type
- local chars = {}
- for i = 32, 126 do -- printable ASCII range
- table.insert(chars, string.char(i))
- end
- -- function to get a random character
- local function random_char()
- return chars[math.random(#chars)]
- end
- -- main typing loop
- while true do
- local num = math.random() * 3 + 1
- if math.random(1, 40) == 1 then
- io.write("\n")
- end
- for i=1, num do
- io.write(random_char())
- sleep(0.05)
- io.flush()
- end
- -- random short delay between keystrokes
- local delay = math.random() * 0.5+0.3 -- between 0 and 0.1 seconds
- sleep(delay)
- end
Advertisement
Add Comment
Please, Sign In to add comment