Hero192 Posted August 9, 2015 Share Posted August 9, 2015 Hey,i want to get color from this table to outputChatBox i tried but failed here's the ERROR attempt to index global 'tonumber( (a function value) local messages = { {"TEXT1",255,0,0}, {"TEXT2",0,0,255}, {"TEXT3",0,255,0} } local i = 0 function sendNextAutomatedMessage ( ) i = i + 1 if ( i > #messages ) then i = 1 end outputChatBox( messages [i], root ,tonumber[2],tonumber[3],tonumber[4]) setTimer ( sendNextAutomatedMessage, 150000, 1 ) end setTimer ( sendNextAutomatedMessage, 200, 1 ) Link to comment
Moderators IIYAMA Posted August 9, 2015 Moderators Share Posted August 9, 2015 You have to index twice instead of one time. Because you have tables inside a table. local messages = { -- < table 1 {"TEXT1",255,0,0}, -- table inside table 1 {"TEXT2",0,0,255}, -- table inside table 1 {"TEXT3",0,255,0} -- table inside table 1 } local i = 0 function sendNextAutomatedMessage ( ) i = i + 1 if ( i > #messages ) then i = 1 end local content = messages[i] outputChatBox( content[1], root ,content[2],content[3],content[4]) setTimer ( sendNextAutomatedMessage, 150000, 1 ) end setTimer ( sendNextAutomatedMessage, 200, 1 ) 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