bump still needing this -
This NEEDS to be added.
ObjectValues
are a necessity in some cases to Packages, for example, which will cease auto-updates if users that wish to set up settings for Packages modify anything of that package excluding the attributes linked directly to the Package’s base Instance. A solution to this would be creating a string to directly loop through from a directory, splitting descendant names and running FindFirstChild()
through each of them, let’s say “ReplicatedStorage.Modules.Shared.Config
”, you’d have to remove all the dot operators via gsub
I believe (haven’t run over the exact method recently) and iterate through, which is less efficient than directly using an ObjectValue
…
Bump, it’s almost 2x faster for script to retrieve attribute values than any instance value (the reference part), takes less memory (no instance required) and shorter to type (said in the original post).
In terms of what Roblox could have done to implement this to begin with, they could have utilized adding a new Enum
, or just adding the option to set more specific Enums
, even past ObjectValue
attributes (not sure yet). They could have done something like this:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local values = ReplicatedStorage.Values
local packageFolder = Instance.new("Folder")
packageFolder.Name = "PackageFolder"
packageFolder:SetAttribute("ValuesFolder", values)
packageFolder.Parent = ReplicatedStorage
local retrievedValuesFolder = packageFolder:GetAttribute("ValuesFolder")
print("Values Folder Name:", retrievedValuesFolder.Name) --> Values Folder Name: Values
-- Setting it to the default value where you can reassign different Instances:
packageFolder:SetAttribute("ValuesFolder", Enum.AttributePlaceholderType.ObjectValue)
-- Check the newly set attribute's value
retrievedValuesFolder = packageFolder:GetAttribute("ValuesFolder")
print("Values Folder Type:", typeof(retrievedValuesFolder)) --> Values Folder Type: EnumItem
-- Check the status of the value assigned so we know if the attribute has even
-- been created yet or not
if retrievedValuesFolder == Enum.AttributePlaceholderType.ObjectValue then
print("It's a placeholder type!")
elseif retrievedValuesFolder == nil then
print("The attribute was never created!")
end
You may not even need to rework the system, with it being like that. I don’t know, please let me know what you think!
Also, apologies, I didn’t mean to reply to you directly, @maxim01689.
It’s all fine
Well, you used typeof in your example code, it returns a string type (unlike type, it supports all roblox types aka vector3, etc…), which means enums are not needed (unless, you want the new fashion way)
I think this is something components can solve, both Unity and Godot have them. For example, Godot has GDScript as their built-in scripting language. You can create a new script and then attach it to an node in the scene (in Roblox it would be an instance).
The only issue is how Roblox treats scripts, they don’t extend anything, but I am sure they could come up with something similar if they wanted to.
that’d be something cool to see but i doubt roblox would implement something like this anytime soon if they did at all.
Enums have already been implemented into attributes. They don’t show as an option in the UI, but you can set them via the command line, and a dropdown menu will display options for the enum!
Now we need attributes that can reference instances. Please Roblox!
Both Godot and Roblox, you “kinda” just parent/attach scripts to objects, it just Godot scripts lack a bit as they need to refer to a real file on your computer rather than the source being retrieved from a .Source property.
If Roblox allowed for file system aswell, i am sure .Source property could’ve reference a .lua file on the local system but it’s an online game, so it needs to have the script’s source be self-contained instead.
But both systems are the same, they both attach to an object and run it’s code in that object. The script itself is a container for the lua code, it’s just Godot and also Unity just reference a external file versus Roblox has it self-contained