I’m making a move handler, and I’d like to “pre-require” all the move modules, as repeating requires can impact performance. I’m wondering how to insert the value as a dictionary. Example:
for _,MoveModule in ipairs(MovesFolder:GetChildren()) do
table.insert(MoveModules,require(MoveModule))
end
You need to insert dictionary values? For what it’s worth, this is more a question for Google than for us, since it deals with fundamentals and you know how to word the question already.
dictionary[key] = value
dictionary[MoveModule.Name] = require(MoveModule)
If key is a string beginning with a letter or underscore, you can also do this.
The thing is that dictionary["Kamehameha Wave"] doesn’t exist yet.
The move modules have the function Start(), I don’t have their Names in the dictionary with their Start function aswell; when I insert their functions, index returns with [1] and [2] when I need it to be Kamehameha Wave and Afterimage
It’s difficult using dictionaries though, as dictionary[MoveModule.Name doesn’t exist yet. All I have is a blank table. If I were to use that method I’d have to hardcode each move name into the dictionary which isn’t optimal, as I’m trying to go organized and easy to add stuff; at the cost of complex systems.