Make table less congested?

At this rate, I’ll have this module script be 5,000+ lines once I push the game for release. Is there any way to improve this? I was going to have values located in ServerStorage but I didn’t want to spend time looking for them, instead I’m just making tables in this module script.

Wave1 = {
		{ 
			Name = "Ice Hobo", Placement = 1, Level = 1, DamageAmount = 10
		},
		{ 
			Name = "Ice Hobo", Placement = 2, Level = 1, DamageAmount = 10
		}
	},
	Wave2 = {
		{ 
			Name = "Ice Hobo", Placement = 1, Level = 5, DamageAmount = 10
		},
		{ 
			Name = "Ice Hobo", Placement = 2, Level = 5, DamageAmount = 10
		},
		{ 
			Name = "Ice Archer", Placement = 3, Level = 1, DamageAmount = 11
		},
		{ 
			Name = "Ice Archer", Placement = 4, Level = 1, DamageAmount = 11
		}
	},

Don’t get me wrong, I’m not complaining about this, but for those massive RPG based games where they have over 100+ unique AI, is this truly how they keep track of the stats for each one?

I don’t have a huge setup, but once I hit like 30 units I started to track their 20+ stats in a spreadsheet that I would then copy that into a script that would initialize the table from that.

i dont understand what you want do
but if you want to do what i think you can just store every mob in a module like that
[“Ice archer”] = {Level = 1, DamageAmount = 11}

and then make a loop every wave to spawn the right amount of mobs

sorry for my english not my native language

1 Like

Can’t you make it more programmatically?

Like it looks like position is +1 every time.

You could then make stat modifiers per wave that affect all enemies then just list enemy_name (amount) modifier_randomize_range (or some other description.

That way you can describe a wave just by defining a few basic rulesets for assigning stats to a group instead of handling each enemy one by one.

1 Like

Mabye for loops? I made this based on your code

local Waves = {} --- or wereever your table is
local currentplacement = 1 -- Idk if you wanted specific placement
function InsertWaveMob(WaveNum, count,name, level, damageamount)


	
	if Waves["Wave"..tostring(WaveNum)] == nil then --- If the wave does not exist
		Waves["Wave"..tostring(WaveNum)] = {} 
	end
	
	for i = 1, count do
		table.insert(Waves["Wave"..tostring(WaveNum)],{Name = name, Placement = currentplacement, Level = level, DamageAmount = damageamount})
		currentplacement = currentplacement+1
	end

end
InsertWaveMob(1, 2,"Ice Hobo",1,10)
for i,v in pairs(Waves["Wave1"]) do
	print(v.Name)
end
----Output: Ice Hobo (x2)
1 Like

you’re on the right track, you can use the code made by @WindowsXPisathing as it is valid.

You should use a module script if you will have multiple scripts handling the enemies, however if the provided script is the only wave handler you should just create a table inside of the aforementioned script with general non-variable enemy information, like name and damage.

1 Like

#help-and-feedback:code-review might fit better?