Jump to content

getting color from Table


Hero192

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...