Table gets formatted incorrectly

Hello!
Ive been working on a gun, and I made it so some values are stored in a table.

-- table
local configurations_ = {
	Automatic = false;
	Shotgun = false;
	Chambering = false;
	Load_Singular = false;
	Affected_By_Strength = true;
	
	Pellets = 10;
	Spread = 5;
	Damage = 20;
	Fire_Rate = 0.5;
} 
print(configurations_) 

So, it should be… Normal, correct?

Welllllll… Nope.

This is how its printed in the output:

                    ["Affected_By_Strength"] = true,
                    ["Automatic"] = false,
                    ["Chambering"] = false,
                    ["Damage"] = 20,
                    ["Fire_Rate"] = 0.5,
                    ["Load_Singular"] = false,
                    ["Pellets"] = 10,
                    ["Shotgun"] = false,
                    ["Spread"] = 5

Sorry to break it to you, print(), but thats not what my table looks like.

This weird formatting is messing with my scripts because its moving variables to the point that it will check if a NUMBER is equal to true.

uhhh… How do I fix this?

So, I think what you’re looking for is a dictionary.

local configurations_ = {
	["Automatic"] = false,
	["Shotgun"] = false,
	["Chambering"] = false,
	["Load_Singular"] = false,
	["Affected_By_Strength"] = true,
	["Pellets"] = 10,
	["Spread"] = 5,
	["Damage"] = 20,
	["Fire_Rate"] = 0.5,
} 
print(configurations_) 
1 Like

Yep, I just did that… But, If you know, why DID the table… you know, break?

that’s probably to do with indexes.
If it’s a regular array:

local configurations_ = { false, true, 10, 20.5 }

configurations_[1] = false
if it’s a dictionary

local configurations_ = {["Automatic"] = false, ["Shotgun"] = false}

configurations_[“Automatic”] = false.

therefore, this does not have any indexes

local configurations_ = {
	Automatic = false;
	Shotgun = false;
	Chambering = false;
	Load_Singular = false;
	Affected_By_Strength = true;
	
	Pellets = 10;
	Spread = 5;
	Damage = 20;
	Fire_Rate = 0.5;
} 
1 Like

Thank you, I guess this topic really was just an oversight. Im kinda rusty cause i havent coded in a while lol.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.