Hi, it’s me again, FrostDracony! I spent these last days on working on a boss battle (I am taking a break from the mesh editor plugin), and I was frustated about some limitations with the default lua tables.
My reasons to create it
Some examples:
If you want to get some Instance from a table, you will need the name or numerical index/key in order to get it, else you will have to do a loop like this to get the Instance:
local Part
local Table = {
"Part1" = workspace.Part1,
"Part2" = workspace.Part2
}
for key, value in pairs(Table) do
if key == "Part1" then
Part = value
end
end
But this isn’t a huge issue. What I really hate is when you have search for some descendant, not a child. When you use the Instance function GetDescendants()
, you get a lot Instances, and you will need to find the right one. In cases like this, you may will need a loop like I wrote above. Another thing wich I find annoying is when you need to index a Instance. There are sometimes where a short workspace.Part
works fine, and other times where you have something like this workspace.Model.SomeSubModel.AnotherSubModelWithAVeryLongName.Part
(I made it extra longer, but you understand what I mean).
You will not find these cases frequently, but they may come. So, I created a little module script wich would help me with this issue. And here comes: My Dictionarier (ok, I admit, I don’t have any name ideas, you always can suggest some here + I startet this year at September to learn the English grammar, it may not be perfect)! I documentated the whole, yes, the whole module, so if you are curious to see how it works (it’s a bit a mess), just go there and watch my comments.
To put it simply, you can create your DictionaryInstance (I choosed this name, again, I have a giant fantasy) by using the new
method (function inside a class). You can pass the Instance you want to convert as parameter, or you pass nothing. `
local Dictionarier = require(6215435539)--or write the path to the modulescript
local DictionaryInstance = Dictionarier.new(InstanceToConvert)
Now, you will need to call the method Dictionary
if you didn’t pass a Instance at the creation of the class. It will return a Dictionary, wich you can watch. The Dictionary is formed in this way:
- Everything is inside a table
- Every table has a key/index of
1
to get the Instance - Each table may have other keys wich index other Instances
If you have, e.g., an Model in your workspace with three parts called “Part1, Part2, Part3”, then you will get something like this:
{
["Part1"] = ▼ {
[1] = Part1
},
["Part2"] = ▼ {
[1] = Part2
},
["Part3"] = ▼ {
[1] = Part3
}
Now, congratulations, you can finally test it out! You write YourDictionaryInstance:FindByName(SomeString)
and it will return you the Instance that you wanted. Best thing: this works with descendants, so something like this:
If I want the ArcHandles, I just write inside the SomeString
the Name that I want and I will get it.
(Code used:
local Module = require(game.ServerScriptService.Dictionarier)
local NewDictionary = Module.new(workspace:WaitForChild("Model"))
print(NewDictionary:FindByName("ArcHandles"))
)
So, this is the main magic.
But, Eterna, and the documentation?
Again, I wrote everything on the documentation, and I even added a support for the Documentation Reader of @ProbableAI, wich, you really should check it out!
What License do it uses?
It uses a GNU Affero General Public License v3.0 (Short: GNU AGPLv3). Read more on this website (it’s sure and without viruses): GNU Affero General Public License v3.0 | Choose a License
I have other questions, where can I ask?
If they are about this module, ask them here, I will be gad to reply to them
But, I am on mobile and I can’t access the module. How can I view what’s inside?
And here some github magical link: https://github.com/FrostDracony/Roblox/blob/master/ModuleScripts/Dictionarier.lua
So, it’s everything, enjoy!
(Sorry if this is really long)