Lua 嵌套列表

Lua Nested Lists

我有这个列表和代码 (tldr):

visualmap = {{{255,0,0},0,47,12,47},{{255,0,0},13,46,13,41},{{255,0,0},12,40,1,40},{{255,0,0},0,39,0,2},{{255,0,0},2,0,185,0},{{255,0,0},187,2,187,39},{{255,0,0},186,40,175,40},{{255,0,0},174,41,174,46},{{255,0,0},175,47,187,47},{{255,0,0},1,1,1,1},{{255,0,0},186,1,186,1},{{255,0,0},186,210,186,210},{{255,0,0},1,210,1,210},{{255,0,0},187,67,175,67},{{255,0,0},174,68,174,107},{{255,0,0},175,108,187,108},{{255,0,0},187,128,175,128},{{255,0,0},174,129,174,149},{{255,0,0},175,150,186,150},{{255,0,0},187,151,187,209},{{255,0,0},185,211,2,211},{{255,0,0},0,209,0,151},{{255,0,0},1,150,12,150},{{255,0,0},13,149,13,129},{{255,0,0},12,128,0,128},{{255,0,0},0,108,12,108},{{255,0,0},13,107,13,68},{{255,0,0},12,67,0,67},{{255,0,0},0,50,15,50},{{255,0,0},16,49,16,38},{{255,0,0},15,37,4,37},{{255,0,0},3,36,3,4},{{255,0,0},4,3,49,3},{{255,0,0},50,4,50,22},{{255,0,0},51,23,56,23},{{255,0,0},57,22,57,4},{{255,0,0},58,3,129,3},{{255,0,0},130,4,130,22},{{255,0,0},131,23,136,23},{{255,0,0},137,22,137,4},{{255,0,0},138,3,183,3},{{255,0,0},184,4,184,36},{{255,0,0},183,37,172,37},{{255,0,0},171,38,171,49},{{255,0,0},172,50,187,50},{{255,0,0},187,64,172,64},{{255,0,0},171,65,171,110},{{255,0,0},172,111,187,111},{{255,0,0},187,125,172,125},{{255,0,0},171,126,171,152},{{255,0,0},172,153,183,153},{{255,0,0},184,154,184,207},{{255,0,0},183,208,4,208},{{255,0,0},3,207,3,154},{{255,0,0},4,153,15,153},{{255,0,0},16,152,16,126},{{255,0,0},15,125,0,125},{{255,0,0},0,111,15,111},{{255,0,0},16,110,16,65},{{255,0,0},15,64,0,64},{{255,0,0},18,17,35,17},{{255,0,0},36,18,36,22},{{255,0,0},35,23,18,23},{{255,0,0},17,22,17,18},{{255,0,0},72,17,115,17},{{255,0,0},116,18,116,22},{{255,0,0},115,23,72,23},{{255,0,0},71,22,71,18},{{255,0,0},152,17,169,17},{{255,0,0},170,18,170,22},{{255,0,0},169,23,152,23},{{255,0,0},151,22,151,18},{{255,0,0},51,37,76,37},{{255,0,0},77,38,77,49},{{255,0,0},76,50,51,50},{{255,0,0},50,49,50,38},{{255,0,0},111,37,136,37},{{255,0,0},137,38,137,49},{{255,0,0},136,50,111,50},{{255,0,0},110,49,110,38},{{255,0,0},31,146,56,146},{{255,0,0},57,147,57,152},{{255,0,0},56,153,31,153},{{255,0,0},30,152,30,147},{{255,0,0},131,146,156,146},{{255,0,0},157,147,157,152},{{255,0,0},156,153,131,153},{{255,0,0},130,152,130,147},{{255,0,0},18,167,36,167},{{255,0,0},37,168,37,193},{{255,0,0},36,194,18,194},{{255,0,0},17,193,17,168},{{255,0,0},151,167,169,167},{{255,0,0},170,168,170,193},{{255,0,0},169,194,151,194},{{255,0,0},150,193,150,168},{{255,0,0},152,37,156,37},{{255,0,0},157,38,157,69},{{255,0,0},156,70,130,70},{{255,0,0},130,69,130,65},{{255,0,0},131,64,150,64},{{255,0,0},151,63,151,38},{{255,0,0},31,37,35,37},{{255,0,0},36,38,36,63},{{255,0,0},37,64,56,64},{{255,0,0},57,65,57,69},{{255,0,0},56,70,31,70},{{255,0,0},30,69,30,38},{{255,0,0},31,84,56,84},{{255,0,0},57,85,57,90},{{255,0,0},56,91,37,91},{{255,0,0},36,92,36,110},{{255,0,0},35,111,31,111},{{255,0,0},30,110,30,85},{{255,0,0},131,84,156,84},{{255,0,0},157,85,157,110},{{255,0,0},156,111,152,111},{{255,0,0},151,110,151,92},{{255,0,0},150,91,131,91},{{255,0,0},130,90,130,85},{{255,0,0},52,167,76,167},{{255,0,0},77,168,77,172},{{255,0,0},76,173,58,173},{{255,0,0},57,174,57,193},{{255,0,0},56,194,52,194},{{255,0,0},51,193,51,168},{{255,0,0},111,167,135,167},{{255,0,0},136,168,136,193},{{255,0,0},135,194,131,194},{{255,0,0},130,193,130,174},{{255,0,0},129,173,111,173},{{255,0,0},110,172,110,168},{{255,0,0},31,84,56,84},{{255,0,0},57,85,57,90},{{255,0,0},56,91,37,91},{{255,0,0},36,92,36,110},{{255,0,0},35,111,31,111},{{255,0,0},30,110,30,85},{{255,0,0},100,87,112,87},{{255,0,0},113,88,113,107},{{255,0,0},112,108,75,108},{{255,0,0},74,107,74,88},{{255,0,0},75,87,87,87},{{255,0,0},100,84,115,84},{{255,0,0},116,85,116,110},{{255,0,0},115,111,72,111},{{255,0,0},71,110,71,85},{{255,0,0},72,84,87,84},{{255,0,0},87,85,87,86},{{255,0,0},100,85,100,86},{{255,0,0},92,37,95,37},{{255,0,0},96,38,96,63},{{255,0,0},97,64,115,64},{{255,0,0},116,65,116,69},{{255,0,0},115,70,72,70},{{255,0,0},71,69,71,65},{{255,0,0},72,64,90,64},{{255,0,0},91,63,91,38},{{255,0,0},51,105,56,105},{{255,0,0},57,106,57,124},{{255,0,0},58,125,76,125},{{255,0,0},77,126,77,131},{{255,0,0},76,132,31,132},{{255,0,0},30,131,30,126},{{255,0,0},31,125,49,125},{{255,0,0},50,124,50,106},{{255,0,0},92,126,95,126},{{255,0,0},96,127,96,145},{{255,0,0},97,146,115,146},{{255,0,0},116,147,116,152},{{255,0,0},115,153,72,153},{{255,0,0},71,152,71,147},{{255,0,0},72,146,90,146},{{255,0,0},91,145,91,127},{{255,0,0},131,105,136,105},{{255,0,0},137,106,137,124},{{255,0,0},138,125,156,125},{{255,0,0},157,126,157,131},{{255,0,0},156,132,111,132},{{255,0,0},110,131,110,126},{{255,0,0},111,125,129,125},{{255,0,0},130,124,130,106},{{255,0,0},92,167,95,167},{{255,0,0},96,168,96,186},{{255,0,0},97,187,115,187},{{255,0,0},116,188,116,193},{{255,0,0},115,194,72,194},{{255,0,0},71,193,71,188},{{255,0,0},72,187,90,187},{{255,0,0},91,186,91,169},{{255,184,151},2,210,185,210},{{255,184,151},1,209,186,209},{{255,184,151},1,208,3,208},{{255,184,151},184,208,186,208},{{255,184,151},1,207,1,151},{{255,184,151},2,207,2,151},{{255,184,151},185,207,185,151},{{255,184,151},186,207,186,151},{{255,184,151},3,151,15,151},{{255,184,151},3,152,15,152},{{255,184,151},3,153,3,153},{{255,184,151},13,150,15,150},{{255,184,151},14,149,14,126},{{255,184,151},15,149,15,126},{{255,184,151},13,128,12,128},{{255,184,151},13,127,0,127},{{255,184,151},13,126,0,126},{{255,184,151},184,153,184,151},{{255,184,151},183,152,172,152},{{255,184,151},183,151,172,151},{{255,184,151},174,150,172,150},{{255,184,151},173,149,173,126},{{255,184,151},172,149,172,126},{{255,184,151},174,128,174,126},{{255,184,151},175,127,187,127},{{255,184,151},175,126,187,126},{{255,184,151},0,110,15,110},{{255,184,151},0,109,15,109},{{255,184,151},13,108,15,108},{{255,184,151},14,107,14,65},{{255,184,151},15,107,15,65},{{255,184,151},13,67,13,65},{{255,184,151},12,66,0,66},{{255,184,151},12,65,0,65},{{255,184,151},187,110,172,110},{{255,184,151},187,109,172,109},{{255,184,151},174,108,172,108},{{255,184,151},173,107,173,65},{{255,184,151},172,107,172,65},{{255,184,151},174,67,174,65},{{255,184,151},175,66,187,66},{{255,184,151},175,65,187,65},{{255,184,151},0,49,15,49},{{255,184,151},0,48,15,48},{{255,184,151},13,47,15,47},{{255,184,151},14,46,14,38},{{255,184,151},15,46,15,38},{{255,184,151},13,40,13,38},{{255,184,151},12,39,1,39},{{255,184,151},12,38,1,38},{{255,184,151},3,37,1,37},{{255,184,151},2,36,2,1},{{255,184,151},1,36,1,2},{{255,184,151},3,3,3,1},{{255,184,151},4,2,186,2},{{255,184,151},2,1,185,1},{{255,184,151},50,3,57,3},{{255,184,151},51,4,51,22},{{255,184,151},52,4,52,22},{{255,184,151},53,4,53,22},{{255,184,151},54,4,54,22},{{255,184,151},55,4,55,22},{{255,184,151},56,4,56,22},{{255,184,151},130,3,137,3},{{255,184,151},131,4,131,22},{{255,184,151},132,4,132,22},{{255,184,151},133,4,133,22},{{255,184,151},134,4,134,22},{{255,184,151},135,4,135,22},{{255,184,151},136,4,136,22},{{255,184,151},184,3,186,3},{{255,184,151},185,4,185,39},{{255,184,151},186,4,186,39},{{255,184,151},184,37,184,39},{{255,184,151},183,38,172,38},{{255,184,151},183,39,172,39},{{255,184,151},174,40,172,40},{{255,184,151},173,41,173,49},{{255,184,151},172,41,172,49},{{255,184,151},174,47,174,49},{{255,184,151},175,48,187,48},{{255,184,151},175,49,187,49},{{255,184,151},18,18,35,18},{{255,184,151},18,19,35,19},{{255,184,151},18,20,35,20},{{255,184,151},18,21,35,21},{{255,184,151},18,22,35,22},{{255,184,151},72,18,115,18},{{255,184,151},72,19,115,19},{{255,184,151},72,20,115,20},{{255,184,151},72,21,115,21},{{255,184,151},72,22,115,22},{{255,184,151},152,18,169,18},{{255,184,151},152,19,169,19},{{255,184,151},152,20,169,20},{{255,184,151},152,21,169,21},{{255,184,151},152,22,169,22},{{255,184,151},51,38,76,38},{{255,184,151},51,39,76,39},{{255,184,151},51,40,76,40},{{255,184,151},51,41,76,41},{{255,184,151},51,42,76,42},{{255,184,151},51,43,76,43},{{255,184,151},51,44,76,44},{{255,184,151},51,45,76,45},{{255,184,151},51,46,76,46},{{255,184,151},51,47,76,47},{{255,184,151},51,48,76,48},{{255,184,151},51,49,76,49},{{255,184,151},111,38,136,38},{{255,184,151},111,39,136,39},{{255,184,151},111,40,136,40},{{255,184,151},111,41,136,41},{{255,184,151},111,42,136,42},{{255,184,151},111,43,136,43},{{255,184,151},111,44,136,44},{{255,184,151},111,45,136,45},{{255,184,151},111,46,136,46},{{255,184,151},111,47,136,47},{{255,184,151},111,48,136,48},{{255,184,151},111,49,136,49},{{255,184,151},18,168,18,193},{{255,184,151},19,168,19,193},{{255,184,151},20,168,20,193},{{255,184,151},21,168,21,193},{{255,184,151},22,168,22,193},{{255,184,151},23,168,23,193},{{255,184,151},24,168,24,193},{{255,184,151},25,168,25,193},{{255,184,151},26,168,26,193},{{255,184,151},27,168,27,193},{{255,184,151},28,168,28,193},{{255,184,151},29,168,29,193},{{255,184,151},30,168,30,193},{{255,184,151},31,168,31,193},{{255,184,151},32,168,32,193},{{255,184,151},33,168,33,193},{{255,184,151},34,168,34,193},{{255,184,151},35,168,35,193},{{255,184,151},36,168,36,193},{{255,184,151},151,168,151,193},{{255,184,151},152,168,152,193},{{255,184,151},153,168,153,193},{{255,184,151},154,168,154,193},{{255,184,151},155,168,155,193},{{255,184,151},156,168,156,193},{{255,184,151},157,168,157,193},{{255,184,151},158,168,158,193},{{255,184,151},159,168,159,193},{{255,184,151},160,168,160,193},{{255,184,151},161,168,161,193},{{255,184,151},162,168,162,193},{{255,184,151},163,168,163,193},{{255,184,151},164,168,164,193},{{255,184,151},165,168,165,193},{{255,184,151},166,168,166,193},{{255,184,151},167,168,167,193},{{255,184,151},168,168,168,193},{{255,184,151},169,168,169,193},{{255,184,151},31,147,56,147},{{255,184,151},31,148,56,148},{{255,184,151},31,149,56,149},{{255,184,151},31,150,56,150},{{255,184,151},31,151,56,151},{{255,184,151},31,152,56,152},{{255,184,151},131,147,156,147},{{255,184,151},131,148,156,148},{{255,184,151},131,149,156,149},{{255,184,151},131,150,156,150},{{255,184,151},131,151,156,151},{{255,184,151},131,152,156,152},{{255,184,151},31,38,31,69},{{255,184,151},32,38,32,69},{{255,184,151},33,38,33,69},{{255,184,151},34,38,34,69},{{255,184,151},35,38,35,69},{{255,184,151},36,64,36,69},{{255,184,151},37,65,56,65},{{255,184,151},37,66,56,66},{{255,184,151},37,67,56,67},{{255,184,151},37,68,56,68},{{255,184,151},37,69,56,69},{{255,184,151},131,65,156,65},{{255,184,151},131,66,156,66},{{255,184,151},131,67,156,67},{{255,184,151},131,68,156,68},{{255,184,151},131,69,156,69},{{255,184,151},151,64,156,64},{{255,184,151},152,38,152,63},{{255,184,151},153,38,153,63},{{255,184,151},154,38,154,63},{{255,184,151},155,38,155,63},{{255,184,151},156,38,156,63},{{255,184,151},31,85,56,85},{{255,184,151},31,86,56,86},{{255,184,151},31,87,56,87},{{255,184,151},31,88,56,88},{{255,184,151},31,89,56,89},{{255,184,151},31,90,56,90},{{255,184,151},31,91,36,91},{{255,184,151},31,92,31,110},{{255,184,151},32,92,32,110},{{255,184,151},33,92,33,110},{{255,184,151},34,92,34,110},{{255,184,151},35,92,35,110},{{255,184,151},131,85,156,85},{{255,184,151},131,86,156,86},{{255,184,151},131,87,156,87},{{255,184,151},131,88,156,88},{{255,184,151},131,89,156,89},{{255,184,151},131,90,156,90},{{255,184,151},151,91,156,91},{{255,184,151},152,92,152,110},{{255,184,151},153,92,153,110},{{255,184,151},154,92,154,110},{{255,184,151},155,92,155,110},{{255,184,151},156,92,156,110},{{255,184,151},52,168,52,193},{{255,184,151},53,168,53,193},{{255,184,151},54,168,54,193},{{255,184,151},55,168,55,193},{{255,184,151},56,168,56,193},{{255,184,151},57,168,57,173},{{255,184,151},58,168,76,168},{{255,184,151},58,169,76,169},{{255,184,151},58,170,76,170},{{255,184,151},58,171,76,171},{{255,184,151},58,172,76,172},{{255,184,151},111,168,135,168},{{255,184,151},111,169,135,169},{{255,184,151},111,170,135,170},{{255,184,151},111,171,135,171},{{255,184,151},111,172,135,172},{{255,184,151},130,173,135,173},{{255,184,151},131,174,131,193},{{255,184,151},132,174,132,193},{{255,184,151},133,174,133,193},{{255,184,151},134,174,134,193},{{255,184,151},135,174,135,193},{{255,184,151},72,65,115,65},{{255,184,151},72,66,115,66},{{255,184,151},72,67,115,67},{{255,184,151},72,68,115,68},{{255,184,151},72,69,115,69},{{255,184,151},91,64,96,64},{{255,184,151},92,38,92,63},{{255,184,151},93,38,93,63},{{255,184,151},94,38,94,63},{{255,184,151},95,38,95,63},{{255,184,151},31,126,76,126},{{255,184,151},31,127,76,127},{{255,184,151},31,128,76,128},{{255,184,151},31,129,76,129},{{255,184,151},31,130,76,130},{{255,184,151},31,131,76,131},{{255,184,151},50,125,57,125},{{255,184,151},51,106,51,124},{{255,184,151},52,106,52,124},{{255,184,151},53,106,53,124},{{255,184,151},54,106,54,124},{{255,184,151},55,106,55,124},{{255,184,151},56,106,56,124},{{255,184,151},111,126,156,126},{{255,184,151},111,127,156,127},{{255,184,151},111,128,156,128},{{255,184,151},111,129,156,129},{{255,184,151},111,130,156,130},{{255,184,151},111,131,156,131},{{255,184,151},130,125,137,125},{{255,184,151},131,106,131,124},{{255,184,151},132,106,132,124},{{255,184,151},133,106,133,124},{{255,184,151},134,106,134,124},{{255,184,151},135,106,135,124},{{255,184,151},136,106,136,124},{{255,184,151},72,147,115,147},{{255,184,151},72,148,115,148},{{255,184,151},72,149,115,149},{{255,184,151},72,150,115,150},{{255,184,151},72,151,115,151},{{255,184,151},72,152,115,152},{{255,184,151},91,146,96,146},{{255,184,151},92,127,92,145},{{255,184,151},93,127,93,145},{{255,184,151},94,127,94,145},{{255,184,151},95,127,95,145},{{255,184,151},72,188,115,188},{{255,184,151},72,189,115,189},{{255,184,151},72,190,115,190},{{255,184,151},72,191,115,191},{{255,184,151},72,192,115,192},{{255,184,151},72,193,115,193},{{255,184,151},91,187,96,187},{{255,184,151},92,168,92,186},{{255,184,151},93,168,93,186},{{255,184,151},94,168,94,186},{{255,184,151},95,168,95,186},{{255,184,151},72,85,86,85},{{255,184,151},72,86,86,86},{{255,184,151},72,87,74,87},{{255,184,151},72,88,72,110},{{255,184,151},73,88,73,110},{{255,184,151},74,108,74,110},{{255,184,151},75,109,115,109},{{255,184,151},75,110,115,110},{{255,184,151},113,108,115,108},{{255,184,151},114,107,114,85},{{255,184,151},115,107,115,85},{{255,184,151},113,87,113,85},{{255,184,151},112,86,101,86},{{255,184,151},112,85,101,85},{{255,184,222},88,85,99,85},{{255,184,222},88,86,99,86}}

platform.window:invalidate()

function on.paint(gc)
    gc:setColorRGB(0,0,0)
    for i,v in ipairs(visualmap) do
        gc:setColorRGB(v[0][0],v[0][1],v[0][2])
        gc:drawLine(v[1],v[2],v[3],v[4])
    end
end

出现的错误:

Line 6:

attempt to index field '?' (a nil value)

v[0]是直线的rgb,v[1] - v[4]是直线的x1,y1,x2,y2。

有人对如何从列表中获取每个值有任何建议吗?

Lua 的 table 构造函数以整数 1 开始默认键,使您的索引减一。想必,TI-Nspire也是如此。

v[0] 将是 nil,因此 v[0][0] 会导致运行时错误。 (在Lua 5.3.4中,我无法匹配你引用的确切错误消息。可能消息格式已更改。)

因此,使用 v[1][1] 代替 v[0][0],依此类推。