I was writing a script that stores the functions of all the items in my game, and was wondering if it’s possible to do something like this:
local dictionary = {
["func1"] = function()
print(???)
--Outputs "func1" without putting in print(“func1”) directly
end;
["func2"] = function()
print(???)
--Outputs "func2" without putting in print(“func2”) directly
end;
}
Here’s the actual section of the script I am working on, perhaps it makes my question more clear:
module.ItemFunctions = {
["Adventure Card"] = function()
if animationTrack.IsPlaying then
remotesFolder.RemoveAccessory:FireServer("Adventure Card")
--Can I just grab the name from the dictionary this function is stored in somehow?
animationTrack:Stop()
else
remotesFolder.AddAccessory:FireServer("Adventure Card")
--Same here
animationTrack:Play()
task.wait(animationTrack.Length * 0.8)
animationTrack:AdjustSpeed(0)
end
end;
}