i have a problem with the program i try to write,
when i write
variable = mt[x][y]
it is workingbut when i write
variable=_G["mt"..i][x][y]
it isn't working.Could it be that _G isn't working in computer craft?
variable = mt[x][y]
it is working
variable=_G["mt"..i][x][y]
it isn't working.
while true do
for i=1, 51 do
for j=1, 19 do
local os_cur =os_mt_screen[i][j]
paintutils.drawPixel(i,j,_G["os_graphic".. 0][i-_G["x"..os_mt_screen[i][j]]][_G["y"..os_mt_screen[i][j]]])
paintutils.drawPixel(i,j,os_graphic0[i][j] )
if os_text0[i][j] ~= "" then
term.setCursorPos(i,j)
term.write(_G["os_text"..os_cur][i-_G["x"..os_cur]][j-_G["y"..os_cur]])
end
end
end
sleep(10)
end
that is my codewhile true do
for i=1, 51 do
for j=1, 19 do
local os_cur = os_mt_screen[i][j]
paintutils.drawPixel(i,j,os_graphic[0][i-xTable[os_cur]][yTable[os_cur]])
paintutils.drawPixel(i,j,os_graphic[0][i][j] )
if os_text[0][i][j] ~= "" then
term.setCursorPos(i,j)
term.write(os_text[os_cur][i-xTable[os_cur]][j-yTable[os_cur]])
end
end
end
sleep(10)
end
while true do
for i=1, 51 do
for j=1, 19 do
local os_cur =os_mt_screen[i][j]
paintutils.drawPixel(i,j,_G["os_graphic".. os_cur][i-_G["x"..os_mt_screen[i][j]]][_G["y"..os_mt_screen[i][j]]])
if os_text0[i][j] ~= "" then
term.setCursorPos(i,j)
term.write(_G["os_text"..os_cur][i-_G["x"..os_cur]][j-_G["y"..os_cur]])
end
end
end
sleep(10)
end
this is happened because i test parts of the code._G["os_graphic0"] = {} -- Force a new table into _G.
print(_G["os_graphic0"] == os_graphic0) -- true
os_graphic0["hello"] = "moo"
print(os_graphic0["hello"] == _G["os_graphic0"]["hello"]) -- still true
os_graphic0 = {} -- Now we have a new os_graphic0, in the user environment table (still making it global to all scripts in that environment)...
print(_G["os_graphic0"] == os_graphic0) -- false!
os_graphic0 = nil -- Clear the user environment version of "os_graphic0"
print(type(os_graphic0)) -- Guess!
oh sorry i made a mistake in the post
this is the orginal code