Backsage Posted July 18, 2015 Share Posted July 18, 2015 Hello again, I need some help. I won't post the whole code because it's not important. But function processClick() x = tonumber(guiGetText(GUIEditor.edit[1])) y = tonumber(guiGetText(GUIEditor.edit[2])) z = tonumber(guiGetText(GUIEditor.edit[3])) r = tonumber(guiGetText(GUIEditor.edit[4])) cor = {} cor[coordinates] = {} --table.insert(cor, {x, y, z, r}) if not x and not y and not z and not r then outputChatBox("Input must be in numbers") elseif x and y and z and r then table.insert(cor, {x, y, z, r}) for i=1, #cor do local _x, _y, _z, _r = cor[i][1], cor[i][2], cor[i][3], cor[i][4] table.insert(cor[coordinates], {_x, _y, _z, _r}) for i, tableData in ipairs (cor[coordinates]) do local tName, tx, ty, tz = unpack(tableData) outputChatBox(" " .. tName .. " " .. tx .. " " .. ty .. " " .. tz ) end end end end whenever I click a button called "Set", I get an error: ERROR: teleportscript4\gui2.lua:142:table index is nil and whenever I do function processClick() x = tonumber(guiGetText(GUIEditor.edit[1])) y = tonumber(guiGetText(GUIEditor.edit[2])) z = tonumber(guiGetText(GUIEditor.edit[3])) r = tonumber(guiGetText(GUIEditor.edit[4])) cor = { coordinates = {}, } --table.insert(cor, {x, y, z, r}) if not x and not y and not z and not r then outputChatBox("Input must be in numbers") elseif x and y and z and r then table.insert(cor, {x, y, z, r}) for i=1, #cor do local _x, _y, _z, _r = cor[i][1], cor[i][2], cor[i][3], cor[i][4] table.insert(cor[coordinates], {_x, _y, _z, _r}) for i, tableData in ipairs (cor[coordinates]) do local tName, tx, ty, tz = unpack(tableData) outputChatBox(" " .. tName .. " " .. tx .. " " .. ty .. " " .. tz ) end end end end I get an error: ERROR:teleportscript3\gui2.lua:155: bad argument #1 to 'insert' (table expected, got nil) Strangely, when I do function processClick() x = tonumber(guiGetText(GUIEditor.edit[1])) y = tonumber(guiGetText(GUIEditor.edit[2])) z = tonumber(guiGetText(GUIEditor.edit[3])) r = tonumber(guiGetText(GUIEditor.edit[4])) cor = { } coordinates = {} --table.insert(cor, {x, y, z, r}) if not x and not y and not z and not r then outputChatBox("Input must be in numbers") elseif x and y and z and r then table.insert(cor, {x, y, z, r}) for i=1, #cor do local _x, _y, _z, _r = cor[i][1], cor[i][2], cor[i][3], cor[i][4] table.insert(coordinates, {_x, _y, _z, _r}) for i, tableData in ipairs (coordinates) do local tName, tx, ty, tz = unpack(tableData) outputChatBox(" " .. tName .. " " .. tx .. " " .. ty .. " " .. tz ) end end end end It works, but I know this can't be the only way of making it work because when I do for i, tableData in ipairs(allowedTeams) do local tName, tR, tG, tB = unpack(tableData) outputChatBox(" " .. tName .. " " .. tR .. " " .. tG .. " " .. tB ) createTeam(tName, tR, tG, tB) end and function populateGridlist() local rootnode = xmlLoadFile("vehicles.xml") -- create a blank global table to store our imported data vehicleTable = {} if rootnode then for _,group in ipairs(xmlNodeGetChildren(rootnode)) do -- create an entry in the gridlist for every vehicle "group" local row = guiGridListAddRow(gridlistVehicleSelection) local name = xmlNodeGetAttribute(group,"type") guiGridListSetItemText(gridlistVehicleSelection,row,1,name,false,false) --add an entry containing the group name into the table vehicleTable[name] = {} -- we will use the custom data "header" to indicate that this entry can be expanded/collapsed guiGridListSetItemData(gridlistVehicleSelection,row,1,"header") -- then, for every group that we find, loop all of its children (the vehicle nodes) and store them in a table for _,vehicle in ipairs(xmlNodeGetChildren(group)) do local vname = xmlNodeGetAttribute(vehicle, "name") local id = xmlNodeGetAttribute(vehicle, "id") -- insert both the vehicle id and the vehicle description into the table table.insert(vehicleTable[name],{id,vname}) for i, tableData in ipairs (vehicleTable[name]) do local name1, type1 = unpack(tableData) outputChatBox(" " .. name1 .. " " .. type1 ) end end end -- set element data on the gridlist so we know which group is currently showing setElementData(gridlistVehicleSelection,"expanded","none") -- unload the xml file now that we are finished xmlUnloadFile(rootnode) end end It works. So how can I make it work like either of these two solutions? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now