mirror of
https://github.com/LDDestroier/CC/
synced 2025-06-09 22:34:04 +00:00
Fixed multishell
This commit is contained in:
parent
9536565dfe
commit
ec3ae28af9
@ -3,7 +3,7 @@ local filename = tArg[1]
|
|||||||
|
|
||||||
local contrast = 2 -- lower value means higher contrast
|
local contrast = 2 -- lower value means higher contrast
|
||||||
local addSpeed = 4 -- higher value means brighter colors show up faster
|
local addSpeed = 4 -- higher value means brighter colors show up faster
|
||||||
local subtractSpeed = 2 -- higher value means darker colors take over faster
|
local subtractSpeed = 1 -- higher value means darker colors take over faster
|
||||||
local minimumStatic = -8 -- lower value means static will be less frequent (not less powerful)
|
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)
|
local maximumStatic = 0 -- higher value means static will be more powerful (not less frequent) (if zero, disables static)
|
||||||
local tint = {
|
local tint = {
|
||||||
@ -36,7 +36,7 @@ gstTerm.meta.alwaysRender = false
|
|||||||
|
|
||||||
local scr_x, scr_y = term.getSize()
|
local scr_x, scr_y = term.getSize()
|
||||||
|
|
||||||
local palette = {}
|
local ghostPalette = {}
|
||||||
local nativePalette = {}
|
local nativePalette = {}
|
||||||
|
|
||||||
local alpha, rv_alpha = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}, {}
|
local alpha, rv_alpha = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}, {}
|
||||||
@ -48,21 +48,28 @@ for k,v in pairs(alpha) do
|
|||||||
rv_alpha[v] = k
|
rv_alpha[v] = k
|
||||||
end
|
end
|
||||||
|
|
||||||
local resetPalette = function()
|
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()
|
||||||
local p
|
local p
|
||||||
for i = 0, 15 do
|
for i = 0, 15 do
|
||||||
p = 2 ^ (-1 + rv_alpha[bright[i + 1]])
|
p = 2 ^ (-1 + rv_alpha[bright[i + 1]])
|
||||||
palette[p] = {
|
ghostPalette[p] = {
|
||||||
((i + contrast) / (15 + contrast)) * tint[1],
|
((i + contrast) / (15 + contrast)) * tint[1],
|
||||||
((i + contrast) / (15 + contrast)) * tint[2],
|
((i + contrast) / (15 + contrast)) * tint[2],
|
||||||
((i + contrast) / (15 + contrast)) * tint[3],
|
((i + contrast) / (15 + contrast)) * tint[3],
|
||||||
}
|
}
|
||||||
nativePalette[p] = {term.getPaletteColor(p)}
|
nativePalette[p] = {term.getPaletteColor(p)}
|
||||||
term.setPaletteColor(p, table.unpack(palette[p]))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resetPalette()
|
makeGhostPalette()
|
||||||
|
setPalette(ghostPalette)
|
||||||
|
|
||||||
newTerm.setPaletteColor = function(col, r, g, b)
|
newTerm.setPaletteColor = function(col, r, g, b)
|
||||||
return nil
|
return nil
|
||||||
@ -111,10 +118,32 @@ end
|
|||||||
|
|
||||||
local oldTerm = term.redirect(newTerm)
|
local oldTerm = term.redirect(newTerm)
|
||||||
|
|
||||||
|
local isSelected = true
|
||||||
|
local multishellID
|
||||||
|
if multishell then
|
||||||
|
multishellID = multishell.getCurrent()
|
||||||
|
end
|
||||||
|
|
||||||
parallel.waitForAny(function()
|
parallel.waitForAny(function()
|
||||||
shell.run(filename or "/rom/programs/shell.lua")
|
shell.run(filename or "/rom/programs/shell.lua")
|
||||||
end, function()
|
end, function()
|
||||||
while true do
|
while true do
|
||||||
|
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
|
||||||
gstTerm.redraw()
|
gstTerm.redraw()
|
||||||
newTerm.restoreCursor()
|
newTerm.restoreCursor()
|
||||||
sleep(0)
|
sleep(0)
|
||||||
@ -122,8 +151,6 @@ end, function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
term.redirect(oldTerm)
|
term.redirect(oldTerm)
|
||||||
for i = 0, 15 do
|
setPalette(nativePalette)
|
||||||
term.setPaletteColor(2^i, table.unpack(nativePalette[2^i]))
|
|
||||||
end
|
|
||||||
newTerm.redraw()
|
newTerm.redraw()
|
||||||
term.setCursorPos(1, scr_y)
|
term.setCursorPos(1, scr_y)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user