How should I go about abilities?

I’ve made ability systems before, but it’s tiring having thousand line scripts. I’m wondering if its best to make trees of module scripts
Screenshot 2023-02-21 at 12.49.08
or have one module script with all the functions for one ability.

Yes, having modules is a great idea for this type of game. Since you want a lot of the effects to be consistent, modules can help with that.

For example, you should have all the basic effects to be creatable in one module, and another one would replicate abilites from server and client.

Some would contain data on abilities like their description, name, level required, etc. It depends on how organized you can make this.

?
I mean like lets say There are two abilities, Fire and Water. Would I keep all their functions in that modulescript or make each function seperate in child modulescripts

Any effect you want to be able to recreate the same way every time, should be contained in a module to prevent boilerplate (repeated) code.

Modules are good but not if you use them for only 10 lines for a single guiscreen.

Remember

modules are modules
modules are created to separate an independent script that should be used in alot of places.
or
modules can be a list of information you would like to send into multiple scripts (doesn’t mean alot, but a little. (EXAMPLE Client and server.))

DO NOT USE MODULESCRIPTS FOR SMALL BITS OF DATA.
so If you are tring to get a module, It should be like attack info or effect info. Heres what I think you need to do

How

make a module made for processing attacks.
make a module for a dictionary of effects.
make a module for a dictionary of animation.(You can put the animation in the ability but putting it in a module can preload it.)

Idea

and for the ability put in function of how the effect is gonna go. and a list of effects and animations. and put in a sequence order.
A better way to do this is by making a metamethod on the effect and so that it has more control of the effects.

2 Likes

It’s hard to say, your question is very general. Can you show some example code for 1 or 2 abilities, maybe people can suggest how to make it more concise then?

I don’t think you understand my question.

@apictrain0
Could you give an example on how to use it with OOP for effects?

@ThanksRoBama
Screenshot 2023-02-21 at 23.21.22
If I place all the functions in one module, the script can get very long. Alternately, I can have a seperate modulescript for each function, but I don’t think that would be good, because I would have to get all my services and folders and modules in each script.

1 Like

I think this all just comes down to your own personal preference. There is no down side to using multiple module scripts (besides having to reference all of them individually). In my opinion, I would use multiple: it would make the readability much easier as I’d know instantly which element’s abilities I’m dealing with. Again, it all comes down to what you think is best! Hope this helps!

1 Like

Is there a lot of repetition from ability to ability? That’s usually the simplest place to make code more concise

For example an EffectScript could be

local module={}
module.__index=module
function module:sparkle(modifications)
	
end
function module:explosion(modifications)
	
end
function module:brightlight(modifications)

end
return module

and then for the AttackScript

local Effects=require(script.Parent.effects)
local module = {}
setmetatable(module,Effects)
function module:Throw()
	Effects:explosion(modifications)
end

return module

The attacks can call an Effect from the effect script because of the __index
and the customizable effect are a great way to use for the module scripts.

It is ok if module script has like 500 lines but not if it has another independent script.
I think A tree is good but with like 50 module scripts is probably bad.
But Just try to use it the way it works best with you

3 Likes

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