From 8f0c92f99ac3429fa8899b2524d63ae454d625f1 Mon Sep 17 00:00:00 2001 From: LDDestroier Date: Sun, 20 Jan 2019 14:41:04 -0500 Subject: [PATCH] Update wpath.lua --- wpath.lua | 84 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/wpath.lua b/wpath.lua index 8b1b04f..fb41093 100644 --- a/wpath.lua +++ b/wpath.lua @@ -13,63 +13,65 @@ local rbow,bbow local sizePath = "size.lua" if not peripheral.find("monitor") then - return + error("A monitor is needed to use WPath.") end local reset = function() - 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 + 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 end reset() local mons = {peripheral.find("monitor")} local setscales = function() - for a = 1, #mons do - mons[a].setTextScale(wpath.textScale) - end + for a = 1, #mons do + mons[a].setTextScale(wpath.textScale) + end end local wrap = function(txt,amnt) - local output = {} - for a = 0, #txt-1 do - output[((a+amnt) % #txt)+1] = txt:sub(a+1,a+1) - end - return table.concat(output) + local output = {} + for a = 0, #txt-1 do + output[((a+amnt) % #txt)+1] = txt:sub(a+1,a+1) + end + return table.concat(output) end local render = function(shift,mon) - 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 - for y = 1, scr_y do - mon.setCursorPos(1,y) - line = bow:rep(scr_x):sub(1,scr_x) - local text = ("#"):rep(scr_x) - local txcol = wrap(line, -1*math.abs(y-scr_y/2)+shift-1) - local bgcol = wrap(line, -1*math.abs(y-scr_y/2)+shift) - mon.blit(text,txcol,bgcol) - end + 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 + for y = 1, scr_y do + mon.setCursorPos(1,y) + line = bow:rep(scr_x):sub(1,scr_x) + local text = ("#"):rep(scr_x) + local txcol = wrap(line, -1*math.abs(y-scr_y/2)+shift-1) + local bgcol = wrap(line, -1*math.abs(y-scr_y/2)+shift) + mon.blit(text,txcol,bgcol) + end end -local DOITNOW = function(YOUFUCKINGTWAT) - 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 +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 end --parallel.waitForAny(checkForReset,DOITNOW) -DOITNOW() \ No newline at end of file +DOITNOW()