Jump to content

Question regarding Lua tables


Feche1320

Recommended Posts

Posted

Hello, another of my questions :|

  
local table = 
{ 
    [271] = 3000 
} 

  
local table = 
{ 
    [0] = 3000 
} 

Which one is better? I assume that [271] = 0 means that there are 270 empy tables using RAM for nothing, is this like this? The question is regarding a skin system were I am going to put the money on the variable and use the skinid as reference, thanks.

Posted

The first one.

([271] = 3000 )

It's because [271] will be skin ID, and I guess 3000 will be the price.

It won't create something empty, but if you use a loop remember to start from 1 or it can cause a nil

This is only from my knowledge~!

Posted
The first one.

([271] = 3000 )

It's because [271] will be skin ID, and I guess 3000 will be the price.

It won't create something empty, but if you use a loop remember to start from 1 or it can cause a nil

This is only from my knowledge~!

Tables aren't arrays, so they only allocate memory for the keys that contain values.

Thanks guys!

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