>>106185492I tried porting for my cmd.exe console on Windows 11, but I can't seem to get unicode working very well.
pipes.sh.lua ;3
local cols, lines = 80, 25
local function sleep(ms)
os.execute("(PATHPING 127.0.0.1 -n -q 1 -p "..tostring(ms)..")>NUL")
end
local buffer = {}
for y=1,lines do
buffer[y] = {}
for x=1,cols do
buffer[y][x] = {char=" ", color=0}
end
end
local colors = {31,32,33,34,35,36,37}
math.randomseed(os.time())
local x, y = math.floor(cols/2), math.floor(lines/2)
local dir = math.random(0,3)
local color = colors[math.random(#colors)]
local steps = 0
local min_straight = 3
io.write("\027[2J\027[?25l")
io.flush()
local function set_buffer(x, y, char, color)
buffer[y][x] = {char=char, color=color}
end
local function draw()
io.write("\027[1;1H")
for y=1,lines do
local last_color = 0
for x=1,cols do
local cell = buffer[y][x]
if cell.color ~= last_color then
if cell.color == 0 then
io.write("\027[0m")
else
io.write(string.format("\027[1;%dm", cell.color))
end
last_color = cell.color
end
io.write(cell.char)
end
io.write("\n")
end
io.write("\027[0m\n")
end
while true do
if dir == 0 then y = y-1
elseif dir == 1 then x = x+1
elseif dir == 2 then y = y+1
elseif dir == 3 then x = x-1 end
if x < 1 then x = cols end
if x > cols then x = 1 end
if y < 1 then y = lines end
if y > lines then y = 1 end
set_buffer(x, y, "#", color)
steps = steps + 1
if steps >= min_straight then
local new_dir
repeat
new_dir = math.random(0,3)
until new_dir ~= (dir+2)%4 and new_dir ~= dir
dir = new_dir
color = colors[math.random(#colors)]
steps = 0
end
draw()
sleep(30)
end
There is also cmatrix