Hero192 Posted August 9, 2015 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 )
Moderators IIYAMA Posted August 9, 2015 Moderators 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 ) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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