Jump to content

What to do with the nill in a table?


IIYAMA

Recommended Posts

  • Moderators
Posted

Hello guys,

I have a very large table, but the problem is that 70% is "0"

WeaponRecoil = {[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0..................ETC 

How can I make sure the table will be small.

The numbers that will be something in the table is 0 t/m 47. (btw in some of my tables does have a "0", for sample you have explosion = 0 or unarmed = 0)

A guy told me once, that I have to use "var" (remi-x)

What is the best way to make a good table?

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

I don't understand you.

You want to make the table small?

just something looks like this instead of 1=0, 2=0, 3=1, 4=0 etc.:

0 to 10 = 0

10 to 20 = 1

11 to 15 = 0

etc. etc.

I hope that you will understand me to ;p

Sometimes I dream about cheese

Posted

Perhaps don't make a table for all weapons if you don't want to change them from zero to anything. Only make a table for the weapons you want to change.

If I helped you, please click the like button on the right ;) Thanks!

  • Moderators
Posted

How do you set a table like that?

denny199

0 to 10 = 0

10 to 20 = 1

11 to 15 = 0

etc. etc.

I get errors if I call a weapon/number, that does not exist in the table it self.

Sample: I ask for 3, but the table is: omfg = {1=[1],2=[2]} -- 3 isn't inside.

myonlake

Perhaps don't make a table for all weapons if you don't want to change them from zero to anything. Only make a table for the weapons you want to change.

How can I check with nil if the number isn't inside?

Renkon

You can use 'nil', unless I'm wrong

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
IIYAMA said:
How do you set a table like that?

denny199

0 to 10 = 0

10 to 20 = 1

11 to 15 = 0

etc. etc.

I get errors if I call a weapon/number, that does not exist in the table it self.

Sample: I ask for 3, but the table is: omfg = {1=[1],2=[2]} -- 3 isn't inside.

myonlake

Perhaps don't make a table for all weapons if you don't want to change them from zero to anything. Only make a table for the weapons you want to change.

How can I check with nil if the number isn't inside?

Renkon

You can use 'nil', unless I'm wrong

It's { [1] = 1, [2] = 2 } not { 1 = [1], 2 = [2] }.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

  • Moderators
Posted

ops sorry xD, just a sample :3

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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