Stats.Cam = {
["Level 0, 0"] = {
["Dmg"] = 1,
["Attack"] = 2.5,
["Range"] = 15,
["Cost"] = 250,},
["Level 1, 0"] = {
["Dmg"] = 2,
["Attack"] = 2,
["Range"] = 15,
["Cost"] = 300,},
["Level 2, 0"] = {
["Dmg"] = 3,
["Attack"] = 1.5,
["Range"] = 15,
["Cost"] = 350,},
["Level 3, 0"] = {
["Dmg"] = 4,
["Attack"] = 1,
["Range"] = 15,
["Cost"] = 400,},
["Level 0, 1"] = {
["Dmg"] = 1,
["Attack"] = 2.5,
["Range"] = 20,
["Cost"] = 250,},
["Level 0, 2"] = {
["Dmg"] = 1,
["Attack"] = 2.5,
["Range"] = 25,
["Cost"] = 300,},
["Level 0, 3"] = {
["Dmg"] = 1,
["Attack"] = 2.5,
["Range"] = 30,
["Cost"] = 400,},
["Level 1, 1"] = {
["Dmg"] = 2,
["Attack"] = 2,
["Range"] = 20,
["Cost"] = 250,},
["Level 2, 2"] = {
["Dmg"] = 3,
["Attack"] = 1.5,
["Range"] = 25,
["Cost"] = 300,},
["Level 3, 3"] = {
["Dmg"] = 4,
["Attack"] = 1,
["Range"] = 30,
["Cost"] = 400,},
}
What do you mean by upgrading it?
tower defense you have 2 upgrade paths that 1 for range and 1 for dmg thats what I mean by upgrading.
You could ditch the large table an make a function that uses math to calculate the stats.
How would I do that? And would it be easy to change later on? For game nufs or buffs?
function CalculateStats(FirstLevel, SecondLevel)
local Data = {
FirstStat = 1+FirstLevel,
SecondStat = 1+SecondLevel
}
return Data
end
Here is some example code as to what I mean, this is very easy to change in the future.
Ok thats exactly what I needed thanks!
I dont see how I can add five to the range if the level is 3.
function TowerStats.CalcDar(Dmg, Range)
local Stats = {
Dmg = 1+Dmg,
Attck = 3.5-Dmg,
Range = 15+Range
}
end
Do this, Range = 15+(Range*5)
this will solve your issue I hope as it uses multiplication to solve the problem.
Ok, Thanks for help also is it better to do this,
function TowerStats.CalcDar(Dmg, Range)
local Stats = {
{Dmg = 0+Dmg},
{Attck = 3-Dmg},
{Range = 15+Range},
{Cost = 100*Range*Dmg}
}
return Stats
end
or the orignal?
The original will make it so that when you do
local Stats = TowerStats.CalcDar(Dmg, Range) you can do
Stats.Dmg
Stats.Attck
Stats.Range
Stats.Cost
Compared to having to do Stats[0].Dmg and Stats[1].Attck There is no need to put them in a table.
Ok makes sense, I was a bit confused but thanks for clarification.