Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require("event")
- local term = require("term")
- local shell = require("shell")
- local args = shell.parse(...)
- local path = " "
- local speed = 2
- if #args == 1 then
- path = args[1]
- elseif #args == 2 then
- path = args[1]
- speed = tonumber(args[2])
- else
- print("Usage: typer FILE [speed]")
- print("FILE - путь к файлу")
- print("speed - опционально, сколько будет печататься букв при нажитии кнопки")
- os.exit(0)
- end
- term.clear()
- local file = io.open(path)
- local function counts(test)
- local numb=1
- while true do
- local subs = string.sub(test,1,speed*numb)
- local lens = string.len(subs)
- local subs2 = string.sub(test,1,speed*numb+1)
- local lens2 = string.len(subs2)
- numb=numb+1
- if lens==lens2 then
- return numb-1
- end
- end
- end
- local function doubling(linen,mi)
- local n1 = (speed*mi)-(speed-1)
- local n2 = speed*mi
- local subs = string.sub(linen,n1,n2)
- return subs
- end
- for line in file:lines() do
- local count= counts(line)
- for i=1,count do
- event.pull("key_up")
- if event.pull("key_up") then
- io.write(doubling(line,i))
- end
- end
- io.write("\n")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement