Jump to content

Table question


Markeloff

Recommended Posts

Hello,

So, here's my table.

For example, I'm in the first row of the table which index is 0, how to get the next row and its data which is indexed at 1.

local radios = { 
{0,"Radio Off",nil}, 
{1,"Radio 1","link"}, 
{2,"Radio 2","link"}, 
{3,"Radio 3","link"}, 
{4,"Radio 4","link"}, 
{5,"Radio 5","link"}, 
} 

function setCurrentChannel(id) 
if (id < 0) or (id > #radios) then return false; end; 
outputChatBox("setting done") 
channelID = id; 
for i,v in ipairs (radios) do  
if v[1] == id then 
actual = v[2] 
suivant = -- is the v[2] of next row of the table 
previous = -- is the v[2] of previous row of the table 
outputChatBox(v[2]) 
end 
return true; 
end 
end 

Link to comment
  
  
function setCurrentChannel(id) 
if (id < 0) or (id > #radios) then return false; end; 
outputChatBox("setting done") 
channelID = id; 
for i,v in ipairs (radios) do 
if v[1] == id then 
actual = v[2] 
suivant = v[i+1][2] -- next row data 2 
previous = v[i-1][2] -- prev row data 2 
outputChatBox(v[2]) 
end 
return true; 
end 
end 
  
  

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...