Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --https://computercraft.ru/topic/2730-zastavka/?tab=comments#comment-39129
- local gpu = require("component").gpu
- local str = "123456"
- local strLen = nil --если str содержит русские символы написать длину сюда
- local x, y = 1, 1
- local leng = strLen or string.len(str)
- local isRight, isUp = false, false
- local w, h = gpu.getResolution()
- local function moveToXY()
- repeat
- gpu.fill(1, 1, w, h, " ")
- gpu.set(x, y, str)
- x, y = x + 1, y + 1
- if y == h + 1 then
- x = x - 1
- y = h
- isUp = false
- if isRight then
- return 3
- else
- return 4
- end
- end
- os.sleep(0.05)
- until x >= w - leng - 1
- isRight = true
- if isUp then
- return 2
- else
- return 3
- end
- end
- local function moveToMXY()
- repeat
- gpu.fill(1, 1, w, h, " ")
- gpu.set(x, y, str)
- x, y = x - 1, y + 1
- if y == h + 1 then
- x = x + 1
- y = h
- isUp = false
- if isRight then
- return 3
- else
- return 4
- end
- end
- os.sleep(0.05)
- until x <= 1
- isRight = false
- if isUp then
- return 1
- else
- return 4
- end
- end
- local function moveToXMY()
- repeat
- gpu.fill(1, 1, w, h, " ")
- gpu.set(x, y, str)
- x, y = x + 1, y - 1
- if y == 0 then
- x = x - 1
- y = 1
- isUp = true
- if isRight then
- return 2
- else
- return 1
- end
- end
- os.sleep(0.05)
- until x >= w - leng - 1
- isRight = true
- if isUp then
- return 2
- else
- return 3
- end
- end
- local function moveToMXMY()
- repeat
- gpu.fill(1, 1, w, h, " ")
- gpu.set(x, y, str)
- x, y = x - 1, y - 1
- if y == 0 then
- x = x + 1
- y = 1
- isUp = true
- if isRight then
- return 2
- else
- return 1
- end
- end
- os.sleep(0.05)
- until x <= 1
- isRight = false
- return 4
- end
- local fun = {
- [1] = moveToXY,
- [2] = moveToMXY,
- [3] = moveToMXMY,
- [4] = moveToXMY
- }
- gpu.fill(1, 1, w, h, " ")
- local result = moveToXY()
- while true do
- result = fun[result]()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement