Overview
The ValueLibrary is a library for ValueObjects. I made it, because ValueInstances suck.
Unlike ValueInstances, ValueLibraries’ ValueObjects can store tables and can be statically typed.
Documentation
ValueLibrary.Create(name: string, value: any, parent: instance?, staticType: boolean?)
Description: Creates a new ValueObject.
Parameters:
-
name
(string) First identifier of the ValueObject. -
value
(any) Value of the ValueObject -
parent
(instance?) Second identifier of the ValueObject. -
staticType
(boolean?) Can NOT set the Value of the ValueObject to an other type.
Example:
ValueLibrary.Create("DownVector", -part.CFrame.UpVector, part, true)
ValueLibrary.Changed(name: string, parent: Instance?, func: (any?) -> ())
Description: Calls the function, when the SetValue function is called on the ValueObject.
Parameters:
-
name
(string) First identifier of the ValueObject. -
parent
(Instance?) Second identifier of the ValueObject. -
func
((any?) → ()) Function that gets called.
ValueLibrary.SetValue(name: string, value: any?, parent: Instance?)
Description: Sets the ValueObject’s Value.
Parameters:
-
name
(string) First identifier of the ValueObject. -
value
(any?) Value of the ValueObject. -
parent
(Instance?) Second identifier of the ValueObject.
Example:
ValueLibrary.SetValue("DownVector", -part.CFrame.UpVector, part)
ValueLibrary.Get(name: string, parent: Instance?): ValueObject
Description: Returns the ValueObject.
Parameters:
-
name
(string) First identifier of the ValueObject. -
parent
(Instance?) Second identifier of the ValueObject.
Example:
local UpVector = -ValueLibrary.Get("DownVector", part)
ValueLibrary.Destroy(name: string, parent: Instance?)
Description: Deallocates the ValueObject.
Parameters:
-
name
(string) The first identifier of the ValueObject. -
parent
(Instance?) The second identifier of the ValueObject.
Example:
ValueLibrary.Destroy("DownVector", part)
References