Advertisement
serafim7

скринсейвер как на dvd [OpenComputers]

Nov 8th, 2020 (edited)
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. --https://computercraft.ru/topic/2730-zastavka/?tab=comments#comment-39129
  2.  
  3. local gpu = require("component").gpu
  4.  
  5. local str = "123456"
  6. local strLen = nil --если str содержит русские символы написать длину сюда
  7.  
  8. local x, y = 1, 1
  9. local leng = strLen or string.len(str)
  10. local isRight, isUp = false, false
  11. local w, h = gpu.getResolution()
  12.  
  13. local function moveToXY()
  14.   repeat
  15.     gpu.fill(1, 1, w, h, " ")
  16.     gpu.set(x, y, str)
  17.     x, y = x + 1, y + 1
  18.     if y == h + 1 then
  19.       x = x - 1
  20.       y = h
  21.       isUp = false
  22.       if isRight then
  23.         return 3
  24.       else
  25.         return 4
  26.       end
  27.     end
  28.     os.sleep(0.05)
  29.   until x >= w - leng - 1
  30.   isRight = true
  31.   if isUp then
  32.     return 2
  33.   else
  34.     return 3
  35.   end
  36. end
  37.  
  38. local function moveToMXY()
  39.   repeat
  40.     gpu.fill(1, 1, w, h, " ")
  41.     gpu.set(x, y, str)
  42.     x, y = x - 1, y + 1
  43.     if y == h + 1 then
  44.       x = x + 1
  45.       y = h
  46.       isUp = false
  47.       if isRight then
  48.         return 3
  49.       else
  50.         return 4
  51.       end
  52.     end
  53.     os.sleep(0.05)
  54.   until x <= 1
  55.   isRight = false
  56.   if isUp then
  57.     return 1
  58.   else
  59.     return 4
  60.   end
  61. end
  62.  
  63. local function moveToXMY()
  64.     repeat
  65.     gpu.fill(1, 1, w, h, " ")
  66.     gpu.set(x, y, str)
  67.     x, y = x + 1, y - 1
  68.     if y == 0 then
  69.       x = x - 1
  70.       y = 1
  71.       isUp = true
  72.       if isRight then
  73.         return 2
  74.       else
  75.         return 1
  76.       end
  77.     end
  78.     os.sleep(0.05)
  79.   until x >= w - leng  - 1
  80.   isRight = true
  81.   if isUp then
  82.     return 2
  83.   else
  84.     return 3
  85.   end
  86. end
  87.  
  88. local function moveToMXMY()
  89.   repeat
  90.     gpu.fill(1, 1, w, h, " ")
  91.     gpu.set(x, y, str)
  92.     x, y = x - 1, y - 1
  93.     if y == 0 then
  94.       x = x + 1
  95.       y = 1
  96.       isUp = true
  97.       if isRight then
  98.         return 2
  99.       else
  100.         return 1
  101.       end
  102.     end
  103.     os.sleep(0.05)
  104.   until x <= 1
  105.   isRight = false
  106.   return 4
  107. end
  108.  
  109. local fun = {
  110. [1] = moveToXY,
  111. [2] = moveToMXY,
  112. [3] = moveToMXMY,
  113. [4] = moveToXMY
  114. }
  115.  
  116. gpu.fill(1, 1, w, h, " ")
  117. local result = moveToXY()
  118. while true do
  119.   result = fun[result]()
  120. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement