So I am learning to program while also trying to make a category of games I enjoy(Button Simulators) and after realizing how much my code was repeating and how many nested loops I had. I ended up with an OOP setup for a button. I do not know how I would exactly go about giving the player the boosts.
Lets say there is currently only Cash, Multiplier and Rebirth like it is here with their associated boosts:
local ButtonTypeData = {
Multiplier = {
Resets = false,
Boosts = {
Cash = 1.0
}
},
Rebirth = {
Resets = true,
Boosts = {
Multiplier = 1.0
}
},
SuperRebirth = {
Resets = true,
Boosts = {
Rebirth = 1.0,
Multiplier = 1.5,
Cash = 1.25,
}
},
}
return ButtonTypeData
How would I exactly provide these to the player? Below is a function from my module of how the button works, when the player can afford the button they will obviously get the amount that the button states it will give, and lose whatever the price was. But would I instead make a separate script that is like a BoostsHandler? and like it would check how much of each “tier” the player has and applies a certain formula or is there an easier or better way of going about this.
function Button:Purchase(player)
if not self:CanAfford(player) then
print(player.Name .. " is broke as FUCK!")
return
end
local leaderstats = player:FindFirstChild("leaderstats")
local currency = leaderstats:FindFirstChild(self.PriceType)
local stat = leaderstats:FindFirstChild(self.StatName)
if currency and stat then
currency.Value -= self.Price
stat.Value += self.Bonus
print(player.Name .. "bought" .. self.StatName .. "for" .. self.Price)
end
end
Sorry if like this is a stupid question I am just trying to improve and trying to avoid tutorial hell and AI for now