Piorun Posted June 28, 2011 Posted June 28, 2011 I have a question - why this code doesn't works? newTable = { "1st value", "2nd value" } addCommandHandler("showmetable", getRootElement(), function() for i,v in ipairs(newTable) do outputChatBox(tostring(newTable[i])) end end) ???
Subtixx Posted June 28, 2011 Posted June 28, 2011 show the error. EDIT: i think this is correct: newTable = { "1st value", "2nd value" } addCommandHandler("showmetable", getRootElement(), function() for i,v in ipairs(newTable) do outputChatBox(tostring(v)) end end)
Wojak Posted June 28, 2011 Posted June 28, 2011 i tested the code here (with a little edition): http://www.lua.org/cgi-bin/demo and it works fine: newTable = { "1st value", "2nd value" } -- loop from your code works fine (print instead of outputChatBox to run it in demo) for i,v in ipairs(newTable) do print(tostring(newTable[i])) end --this also works, I think its better for i,v in ipairs(newTable) do print(v) end
Piorun Posted June 28, 2011 Author Posted June 28, 2011 newTable = { "1st value", "2nd value" } addCommandHandler("showmetable", getRootElement(), function() for i,v in ipairs(newTable) do outputChatBox(v) end end) I edited my code and i still have an error. Bad argument in outputChatBox
Piorun Posted June 28, 2011 Author Posted June 28, 2011 ah .. i've got an error not in outputChatBox but in addCommandHandler. I fix it but thanks a lot
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