Jump to content

Multi Dimensional Tables


Recommended Posts

I'm not sure if this is what do you mean:

items = 
    { 
        { 
            [ "category" ] = "Weapons", 
            [ "name" ] = "M4", 
            [ "price" ] = 1000, 
            [ "quantity" ] = 500  
        }, 
         
        { 
            [ "category" ] = "Skills", 
            [ "name" ] = "M4 Skill", 
            [ "price" ] = 2000, 
            [ "quantity" ] = 1000 
        } 
    } 

Link to comment

This?

local cTable = 
    { 
        instance =  
            { 
                [1] = 'Crazy'; 
            } 
    } 
     
outputChatBox ( cTable.instance[1] ) 

Basically, is what Solidsnake said :/

Edited by Guest
Link to comment
I'm not sure if this is what do you mean:
items = 
    { 
        { 
            [ "category" ] = "Weapons", 
            [ "name" ] = "M4", 
            [ "price" ] = 1000, 
            [ "quantity" ] = 500  
        }, 
         
        { 
            [ "category" ] = "Skills", 
            [ "name" ] = "M4 Skill", 
            [ "price" ] = 2000, 
            [ "quantity" ] = 1000 
        } 
    } 

That's singular dimension. I want something like this.

  
local items =  
{ 
    { 
        name = "Something" 
        weight = 20 
        height = 20 
    }, 
    { 
        playerid = 0 
    } 
} 
  
items[name][1] = "something" 
-- The first dimension is the info, the second dimension is the playerid 
  

Link to comment

Both the codes wrong.

  
local t =  
{ 
    tSecond = 
    { 
        nValue = 1; 
    } 
} 
  
print( t.tSecond.nValue ) --1 
------- or -------------------------  
print( t['tSecond']['nValue'] ) -- 1 -- 
------- or ------------------------- 
print( t.tSecond['nValue'] ) -- 1  -- 
------- or -------------------------  --  Some codes  
print( t['tSecond'].nValue ) -- 1 
  

Link to comment
Both the codes wrong.
  
local t =  
{ 
    tSecond = 
    { 
        nValue = 1; 
    } 
} 
  
print( t.tSecond.nValue ) --1 
------- or -------------------------  
print( t['tSecond']['nValue'] ) -- 1 -- 
------- or ------------------------- 
print( t.tSecond['nValue'] ) -- 1  -- 
------- or -------------------------  --  Some codes  
print( t['tSecond'].nValue ) -- 1 
  

Thanks but I have already found a way.

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