Piorun Posted February 6, 2012 Share Posted February 6, 2012 Hi guys. Firstly i show you my code: for k,v in ipairs(character) do local y = ( k - 1 )* 55 charPane[k] = guiCreateScrollPane(7, 130 + y, 250, 50, false) charLabel[k][1] = guiCreateLabel(5,0,100,15,character[k],false,charPane[k]) guiSetFont(charLabel[k][1], "default-bold-small") end and I have error "attempt to index field '?' (a nil value)" in line: charLabel[k][1] = guiCreateLabel(5,0,100,15,character[k],false,charPane[k]) WHAT's wrong? Link to comment
JR10 Posted February 6, 2012 Share Posted February 6, 2012 charPane[k] stores the variable returned by guiCreateScrollPane, so it's not a table. Link to comment
Kenix Posted February 6, 2012 Share Posted February 6, 2012 local charPane = { } local charLabel = { } for k,v in ipairs( character ) do local y = ( k - 1 )* 55 charPane[k] = guiCreateScrollPane( 7, 130 + y, 250, 50, false ) charLabel[k] = guiCreateLabel( 5,0,100,15,v,false,charPane[k] ) guiSetFont( charLabel[k], "default-bold-small" ) end Link to comment
Piorun Posted February 6, 2012 Author Share Posted February 6, 2012 Sorry, but in my code i have lines: local charPane = { } local charLabel = { } but in future i want to add more labels something like that: charLabel[k][1] = guiCreateLabel(5,0,100,15,character[k],false,charPane[k]) charLabel[k][2] = guiCreateLabel(5,0,100,15,"Something",false,charPane[k]) charLabel[k][3] = guiCreateLabel(5,0,100,15,"Something",false,charPane[k]) guiSetFont(charLabel[k][1], "default-bold-small") end but when I made it i have error. Link to comment
Al3grab Posted February 6, 2012 Share Posted February 6, 2012 you dont need the [k] here charLabel[1] = guiCreateLabel(5,0,100,15,character[k],false,charPane[k]) charLabel[2] = guiCreateLabel(5,0,100,15,"Something",false,charPane[k]) charLabel[3] = guiCreateLabel(5,0,100,15,"Something",false,charPane[k]) for i,v in ipairs ( charLabel ) do guiSetFont(v, "default-bold-small") end end Link to comment
Kenix Posted February 6, 2012 Share Posted February 6, 2012 Wrong code al3grab charLabel[1] = guiCreateLabel( 5,0,100,15,"Something",false ) charLabel[2] = guiCreateLabel( 5,0,100,15,"Something",false ) charLabel[3] = guiCreateLabel( 5,0,100,15,"Something",false ) for _,v in pairs ( charLabel ) do guiSetFont( v, "default-bold-small" ) end 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