I don’t know if this was already suggested, but it would be nice if there was a way for us to configure how properties interpret inputs using patterns.
For example: I want to input a shorthand Vector2 value of 4, 1, 2x4
and I expect 8, 2, 4
. If I wanted to have this kind of shortcut, I would go to the studio settings and add a new shorthand value format.
Pattern: [\s]*([\d\.]+)[\s]*,[\s]*([\d\.]+)[\s]*,[\s]*([\d\.]+)[\s]*x[\s]*([\d\.]+)
(X,Y,ZxS)
And for me to make this work, I will also need to give a bit of code which returns a Vector2 value. The code’s first returned argument is the deciding factor on what properties will support this format, and if the returned value has more than one possible value type then it either throw an error or becomes available to multiple value types, throwing an error if it returns a value not supported by the property.
local args = {...} -- '...' refers to pattern args. (1, 2, 3x4)
local x = tonumber(args[1])
local y = tonumber(args[2])
local z = tonumber(args[3])
assert(x and y and z, "Invalid Vector3 format.")
local v = Vector3.new(x,y,z)
local mult = tonumber(args[4])
assert(mult, "Invalid multiplier.")
return v * mult -- Always returns Vector3, so this is a Vector3-exclusive shorthand.
The pattern could be shortened to \*([\d\.]+)
(*x) and use this code instead, treating self
as the current value before the input. At second thought, it might be better to have a list of valid property types to toggle for a custom interpretation in the case a returned value is typed as “any” or you need to correct the interpretation’s interpreted type.
local mult = tonumber(({...})[1])
assert(mult, "Invalid multiplier.")
return self * mult
With custom interpretations, the sky’s the limit. We could really streamline things with this kind of freedom, and if there was ever a input-related problem exclusive to one person/group, that same person/group can implement the interpretation themselves!