2020-01-12 05:44:23 +00:00
|
|
|
local tArg = {...}
|
|
|
|
local filename = tArg[1]
|
|
|
|
|
2020-01-12 07:55:47 +00:00
|
|
|
local contrast = 2 -- lower value means higher contrast
|
|
|
|
local addSpeed = 4 -- higher value means brighter colors show up faster
|
2020-01-13 04:50:43 +00:00
|
|
|
local subtractSpeed = 1 -- higher value means darker colors take over faster
|
2020-01-12 07:55:47 +00:00
|
|
|
local minimumStatic = -8 -- lower value means static will be less frequent (not less powerful)
|
|
|
|
local maximumStatic = 0 -- higher value means static will be more powerful (not less frequent) (if zero, disables static)
|
2020-01-12 07:34:21 +00:00
|
|
|
local tint = {
|
|
|
|
1,
|
2020-01-12 07:55:47 +00:00
|
|
|
0.749,
|
|
|
|
0,
|
2020-01-12 07:34:21 +00:00
|
|
|
}
|
|
|
|
|
2020-01-12 05:33:56 +00:00
|
|
|
if not fs.exists("windont.lua") then
|
|
|
|
print("'windont.lua' not found! Downloading...")
|
|
|
|
local net = http.get("https://github.com/LDDestroier/CC/raw/master/windont/windont.lua")
|
|
|
|
if net then
|
|
|
|
local file = fs.open("windont.lua", "w")
|
|
|
|
file.write(net.readAll())
|
|
|
|
file.close()
|
|
|
|
net.close()
|
|
|
|
else
|
|
|
|
error("Could not download Windon't.", 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local windont = require("windont")
|
|
|
|
|
2020-01-12 07:34:21 +00:00
|
|
|
windont.useSetVisible = true
|
|
|
|
|
2020-01-12 06:43:50 +00:00
|
|
|
local newTerm = windont.newWindow(1, 1, term.getSize())
|
|
|
|
local gstTerm = windont.newWindow(1, 1, term.getSize())
|
2020-01-12 05:33:56 +00:00
|
|
|
newTerm.meta.alwaysRender = false
|
|
|
|
gstTerm.meta.alwaysRender = false
|
|
|
|
|
|
|
|
local scr_x, scr_y = term.getSize()
|
|
|
|
|
2020-01-13 04:50:43 +00:00
|
|
|
local ghostPalette = {}
|
2020-01-12 05:33:56 +00:00
|
|
|
local nativePalette = {}
|
|
|
|
|
|
|
|
local alpha, rv_alpha = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}, {}
|
|
|
|
local bright, rv_bright = {"f","7","c","a","b","d","9","8","e","5","2","1","6","3","4","0"}, {}
|
|
|
|
for k,v in pairs(bright) do
|
|
|
|
rv_bright[v] = k
|
|
|
|
end
|
|
|
|
for k,v in pairs(alpha) do
|
|
|
|
rv_alpha[v] = k
|
|
|
|
end
|
|
|
|
|
2020-01-13 04:50:43 +00:00
|
|
|
local setPalette = function(p, t)
|
|
|
|
t = t or term.current()
|
|
|
|
for i = 0, 15 do
|
|
|
|
t.setPaletteColor(2^i, table.unpack(p[2^i]))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local makeGhostPalette = function()
|
2020-01-12 05:33:56 +00:00
|
|
|
local p
|
|
|
|
for i = 0, 15 do
|
|
|
|
p = 2 ^ (-1 + rv_alpha[bright[i + 1]])
|
2020-01-13 04:50:43 +00:00
|
|
|
ghostPalette[p] = {
|
2020-01-12 05:41:21 +00:00
|
|
|
((i + contrast) / (15 + contrast)) * tint[1],
|
|
|
|
((i + contrast) / (15 + contrast)) * tint[2],
|
|
|
|
((i + contrast) / (15 + contrast)) * tint[3],
|
2020-01-12 05:33:56 +00:00
|
|
|
}
|
|
|
|
nativePalette[p] = {term.getPaletteColor(p)}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-13 04:50:43 +00:00
|
|
|
makeGhostPalette()
|
|
|
|
setPalette(ghostPalette)
|
2020-01-12 05:33:56 +00:00
|
|
|
|
|
|
|
newTerm.setPaletteColor = function(col, r, g, b)
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
newTerm.setPaletteColour = newTerm.setPaletteColor
|
|
|
|
|
|
|
|
gstTerm.meta.metaTransformation = function(meta)
|
|
|
|
for y = 1, meta.height do
|
|
|
|
for x = 1, meta.width do
|
2020-01-12 07:34:21 +00:00
|
|
|
|
2020-01-12 05:33:56 +00:00
|
|
|
local BGCOL = newTerm.meta.buffer[3][y][x]
|
|
|
|
local TXCOL
|
|
|
|
if newTerm.meta.buffer[1][y][x] == " " then
|
|
|
|
TXCOL = BGCOL
|
|
|
|
else
|
|
|
|
TXCOL = newTerm.meta.buffer[2][y][x]
|
|
|
|
end
|
|
|
|
local CHAR
|
|
|
|
if newTerm.meta.buffer[1][y][x] == " " and meta.buffer[1][y][x] ~= " " then
|
|
|
|
CHAR = meta.buffer[1][y][x]
|
|
|
|
else
|
|
|
|
CHAR = newTerm.meta.buffer[1][y][x]
|
|
|
|
end
|
|
|
|
|
|
|
|
meta.buffer[1][y][x] = CHAR
|
2020-01-12 07:34:21 +00:00
|
|
|
|
2020-01-12 05:33:56 +00:00
|
|
|
if rv_bright[TXCOL] >= rv_bright[meta.buffer[2][y][x]] then
|
2020-01-12 07:55:47 +00:00
|
|
|
meta.buffer[2][y][x] = bright[ math.min(16, math.min(rv_bright[meta.buffer[2][y][x]] + addSpeed, rv_bright[TXCOL]) + math.max(0, math.random(minimumStatic, maximumStatic))) ]
|
2020-01-12 05:33:56 +00:00
|
|
|
else
|
2020-01-12 07:34:21 +00:00
|
|
|
meta.buffer[2][y][x] = bright[ math.max(rv_bright[meta.buffer[2][y][x]] - subtractSpeed, 1) ]
|
2020-01-12 05:33:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if rv_bright[BGCOL] >= rv_bright[meta.buffer[3][y][x]] then
|
2020-01-12 07:55:47 +00:00
|
|
|
meta.buffer[3][y][x] = bright[ math.min(16, math.min(rv_bright[meta.buffer[3][y][x]] + addSpeed, rv_bright[BGCOL]) + math.max(0, math.random(minimumStatic, maximumStatic))) ]
|
2020-01-12 05:33:56 +00:00
|
|
|
else
|
2020-01-12 07:34:21 +00:00
|
|
|
meta.buffer[3][y][x] = bright[ math.max(rv_bright[meta.buffer[3][y][x]] - subtractSpeed, 1) ]
|
2020-01-12 05:33:56 +00:00
|
|
|
end
|
2020-01-12 07:34:21 +00:00
|
|
|
|
2020-01-12 07:55:47 +00:00
|
|
|
if meta.buffer[2][y][x] == "f" and meta.buffer[3][y][x] == "f" and newTerm.meta.buffer[1][y][x] == " " then
|
|
|
|
meta.buffer[1][y][x] = " "
|
|
|
|
end
|
|
|
|
|
2020-01-12 05:33:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local oldTerm = term.redirect(newTerm)
|
|
|
|
|
2020-01-13 04:50:43 +00:00
|
|
|
local isSelected = true
|
|
|
|
local multishellID
|
|
|
|
if multishell then
|
|
|
|
multishellID = multishell.getCurrent()
|
|
|
|
end
|
|
|
|
|
2020-01-12 05:33:56 +00:00
|
|
|
parallel.waitForAny(function()
|
2020-01-22 09:28:38 +00:00
|
|
|
pcall(function() shell.run(filename or "/rom/programs/shell.lua") end)
|
|
|
|
end, function()
|
2020-01-12 05:33:56 +00:00
|
|
|
while true do
|
2020-01-13 04:50:43 +00:00
|
|
|
if gstTerm.meta.width ~= newTerm.meta.width or gstTerm.meta.height ~= newTerm.meta.height then
|
|
|
|
gstTerm.reposition(1, 1, newTerm.meta.width, newTerm.meta.height)
|
|
|
|
end
|
|
|
|
if multishell then
|
|
|
|
if multishellID == multishell.getFocus() then
|
|
|
|
if not isSelected then
|
|
|
|
setPalette(ghostPalette, term.native())
|
|
|
|
end
|
|
|
|
isSelected = true
|
|
|
|
else
|
|
|
|
if isSelected then
|
|
|
|
setPalette(nativePalette, term.native())
|
|
|
|
end
|
|
|
|
isSelected = false
|
|
|
|
end
|
|
|
|
end
|
2020-01-12 05:33:56 +00:00
|
|
|
gstTerm.redraw()
|
2020-01-12 05:41:21 +00:00
|
|
|
newTerm.restoreCursor()
|
2020-01-12 05:33:56 +00:00
|
|
|
sleep(0)
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
term.redirect(oldTerm)
|
2020-01-13 04:50:43 +00:00
|
|
|
setPalette(nativePalette)
|
2020-01-12 07:55:47 +00:00
|
|
|
newTerm.redraw()
|
2020-01-12 05:33:56 +00:00
|
|
|
term.setCursorPos(1, scr_y)
|