Hi, i started learning OOP and i combined it with my old strat i call “Micro-Modules”
This strat utilizes small modules with one function named the same in every of them, but you can give different propertiess depending on Object and write specific function.
Explanation of Micro-Modules
For those who don’t understand what i’m talking about, let’s say we have 3 attacks:
- fire
- water
- wind
And all of them do some unique function, to achieve this unique function and make it easy to code i use 3 different lightweight modules for that, each module have function Power:Calculate()
that can be called from object that should own this type of power, inside this function i can write 20 lines of code that deal damage or checks if player is hitted or not
function VFX:__init(effectType:string,effectPropertiess:{})
self.effectType = effectType
self.effectPropertiess = effectPropertiess
local Calculation = require(Calculations[self.effectType])
self.Function = require(Calculations[self.effectType])
local ID = effectType..(effectPropertiess.ID or "_default")
Objects[ID] = self
end
function VFX:Play(origin:Vector3) : void
local Calculation = self.Function
Calculation:Calculate(origin,self.effectType,self.effectPropertiess)
remote:FireAllClients(origin,self.effectType,self.effectPropertiess)
end
I have two options:
1 - Require module every time function :Calculate() is called
2 - Require module on object creation and then add Function property to it with required module
Which option is the best? and is there any alternative?