1
0
mirror of https://github.com/LDDestroier/CC/ synced 2024-11-08 19:09:58 +00:00
ldd-CC/wpath.lua

85 lines
1.8 KiB
Lua
Raw Normal View History

2019-01-20 19:16:59 +00:00
-- Wavey Path
-- Makes a wavey path to the right
local wpath = {}
wpath.cols = "e145d9ba26"
wpath.bwcols = "087f78"
wpath.waveLen = 3
wpath.textScale = 2.5
wpath.delay = 0.05
2020-02-08 05:56:44 +00:00
wpath.doFlip = false
2019-01-20 19:16:59 +00:00
local rbow,bbow
local sizePath = "size.lua"
if not peripheral.find("monitor") then
2019-01-20 19:41:04 +00:00
error("A monitor is needed to use WPath.")
2019-01-20 19:16:59 +00:00
end
local reset = function()
2019-01-20 19:41:04 +00:00
rbow,bbow = "",""
for a = 1,#wpath.cols do
rbow = rbow..wpath.cols:sub(a,a):rep(wpath.waveLen)
end
for a = 1,#wpath.bwcols do
bbow = bbow..wpath.bwcols:sub(a,a):rep(wpath.waveLen)
end
2019-01-20 19:16:59 +00:00
end
reset()
local mons = {peripheral.find("monitor")}
local setscales = function()
2019-01-20 19:41:04 +00:00
for a = 1, #mons do
mons[a].setTextScale(wpath.textScale)
end
2019-01-20 19:16:59 +00:00
end
local wrap = function(txt,amnt)
2019-01-20 19:41:04 +00:00
local output = {}
for a = 0, #txt-1 do
output[((a+amnt) % #txt)+1] = txt:sub(a+1,a+1)
end
return table.concat(output)
2019-01-20 19:16:59 +00:00
end
local render = function(shift,mon)
2019-01-20 19:41:04 +00:00
local line
if not mon.getSize then
return
end
local scr_x,scr_y = mon.getSize()
scr_y = scr_y + (scr_y % 2)
bow = mon.isColor() and rbow or bbow
2020-02-08 05:56:44 +00:00
local txcol, bgcol
2019-01-20 19:41:04 +00:00
for y = 1, scr_y do
mon.setCursorPos(1,y)
line = bow:rep(scr_x):sub(1,scr_x)
local text = ("#"):rep(scr_x)
2020-02-08 05:56:44 +00:00
if wpath.doFlip then
txcol = wrap(line, -1*math.abs(scr_y/2-y)+shift-1)
bgcol = wrap(line, -1*math.abs(scr_y/2-y)+shift)
else
txcol = wrap(line, -1*math.abs(y-scr_y/2)+shift-1)
bgcol = wrap(line, -1*math.abs(y-scr_y/2)+shift)
end
2019-01-20 19:41:04 +00:00
mon.blit(text,txcol,bgcol)
end
2019-01-20 19:16:59 +00:00
end
2019-01-20 19:41:04 +00:00
local DOITNOW = function(KILLME, KILLMENOW)
local shift = 0
while true do
shift = (shift + 1)
mons = {peripheral.find("monitor")}
setscales()
for a = 1, #mons do
render(shift,mons[a])
end
sleep(wpath.delay)
end
2019-01-20 19:16:59 +00:00
end
--parallel.waitForAny(checkForReset,DOITNOW)
2019-01-20 19:41:04 +00:00
DOITNOW()