My draw function is not working correctly.
A example of my file formate
Spoiler
layers={
l1={
bgColors={
{-1,-1,-1,-1,5},
{-1,-1,-1,4,-1},
{-1,-1,3,-1,-1},
{-1,2,-1,-1,-1},
{1,-1,-1,-1,-1},
},
textColors={
{0,0,0,0,4},
{0,0,0,3,0},
{0,0,2,0,0},
{0,1,0,0,0},
{5,0,0,0,0},
},
text={
{0,0,0,0,"a"},
{0,0,0,"b",0},
{0,0,"c",0,0},
{0,"d",0,0,0},
{"e",0,0,0,0},
}
},
l2={
bgColors={
{-1,2},
{1,-1},
},
textColors={
{0,0},
{0,0},
},
text={
{0,0},
{0,0},
},
}
}
My load function
Spoiler
function readFile(path)
fs.move(path, "a")
os.loadAPI("a")
fs.move("a", path)
local l = a.layers
os.unloadAPI("a")
return l
end
My draw function
Spoiler
function draw(layers,sX,sY)
for a,b in pairs(layers) do
for y=1,#layers[a].bgColors do
sY = sY + y - 1
for x=1,#layers[a].bgColors[1] do
sX = sX + x - 1
term.setCursorPos(sX,sY)
if not layers[a].bgColors[sY][sX] == -1 then
term.setBackgroundColor(color[layers[a].bgColors[sY][sX]])
end
term.setTextColor(color[layers[a].textColors[sY][sX]])
if tonumber(layers[a].text[sY][sX]) == nil or layers[a].text[sY] == nil or layers[a].text == nil then
term.write(layers[a].text[sY][sX])
else
term.write(" ")
end
end
end
end
end
And then at the very top I have
Spoiler
color={colors.white,colors.orange,colors.magenta,colors.lightBlue,
colors.yellow,colors.lime,colors.pink,colors.gray,colors.lightGray,
colors.cyan,colors.purple,colors.blue,colors.green,colors.red,colors.black}