Update wpath.lua

This commit is contained in:
LDDestroier 2019-01-20 14:41:04 -05:00 committed by GitHub
parent 8efa77adcd
commit 8f0c92f99a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 41 deletions

View File

@ -13,63 +13,65 @@ local rbow,bbow
local sizePath = "size.lua" local sizePath = "size.lua"
if not peripheral.find("monitor") then if not peripheral.find("monitor") then
return error("A monitor is needed to use WPath.")
end end
local reset = function() local reset = function()
rbow,bbow = "","" rbow,bbow = "",""
for a = 1,#wpath.cols do for a = 1,#wpath.cols do
rbow = rbow..wpath.cols:sub(a,a):rep(wpath.waveLen) rbow = rbow..wpath.cols:sub(a,a):rep(wpath.waveLen)
end end
for a = 1,#wpath.bwcols do for a = 1,#wpath.bwcols do
bbow = bbow..wpath.bwcols:sub(a,a):rep(wpath.waveLen) bbow = bbow..wpath.bwcols:sub(a,a):rep(wpath.waveLen)
end end
end end
reset() reset()
local mons = {peripheral.find("monitor")} local mons = {peripheral.find("monitor")}
local setscales = function() local setscales = function()
for a = 1, #mons do for a = 1, #mons do
mons[a].setTextScale(wpath.textScale) mons[a].setTextScale(wpath.textScale)
end end
end end
local wrap = function(txt,amnt) local wrap = function(txt,amnt)
local output = {} local output = {}
for a = 0, #txt-1 do for a = 0, #txt-1 do
output[((a+amnt) % #txt)+1] = txt:sub(a+1,a+1) output[((a+amnt) % #txt)+1] = txt:sub(a+1,a+1)
end end
return table.concat(output) return table.concat(output)
end end
local render = function(shift,mon) local render = function(shift,mon)
local line local line
if not mon.getSize then return end if not mon.getSize then
local scr_x,scr_y = mon.getSize() return
scr_y = scr_y + (scr_y % 2) end
bow = mon.isColor() and rbow or bbow local scr_x,scr_y = mon.getSize()
for y = 1, scr_y do scr_y = scr_y + (scr_y % 2)
mon.setCursorPos(1,y) bow = mon.isColor() and rbow or bbow
line = bow:rep(scr_x):sub(1,scr_x) for y = 1, scr_y do
local text = ("#"):rep(scr_x) mon.setCursorPos(1,y)
local txcol = wrap(line, -1*math.abs(y-scr_y/2)+shift-1) line = bow:rep(scr_x):sub(1,scr_x)
local bgcol = wrap(line, -1*math.abs(y-scr_y/2)+shift) local text = ("#"):rep(scr_x)
mon.blit(text,txcol,bgcol) local txcol = wrap(line, -1*math.abs(y-scr_y/2)+shift-1)
end local bgcol = wrap(line, -1*math.abs(y-scr_y/2)+shift)
mon.blit(text,txcol,bgcol)
end
end end
local DOITNOW = function(YOUFUCKINGTWAT) local DOITNOW = function(KILLME, KILLMENOW)
local shift = 0 local shift = 0
while true do while true do
shift = (shift + 1) shift = (shift + 1)
mons = {peripheral.find("monitor")} mons = {peripheral.find("monitor")}
setscales() setscales()
for a = 1, #mons do for a = 1, #mons do
render(shift,mons[a]) render(shift,mons[a])
end end
sleep(wpath.delay) sleep(wpath.delay)
end end
end end
--parallel.waitForAny(checkForReset,DOITNOW) --parallel.waitForAny(checkForReset,DOITNOW)
DOITNOW() DOITNOW()