ValueLibrary, a replacement for Roblox's ValueInstances

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:

  1. name (string) First identifier of the ValueObject.
  2. value (any) Value of the ValueObject
  3. parent (instance?) Second identifier of the ValueObject.
  4. 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:

  1. name (string) First identifier of the ValueObject.
  2. parent (Instance?) Second identifier of the ValueObject.
  3. func ((any?) → ()) Function that gets called.

ValueLibrary.SetValue(name: string, value: any?, parent: Instance?)

Description: Sets the ValueObject’s Value.

Parameters:

  1. name (string) First identifier of the ValueObject.
  2. value (any?) Value of the ValueObject.
  3. 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:

  1. name (string) First identifier of the ValueObject.
  2. 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:

  1. name (string) The first identifier of the ValueObject.
  2. parent (Instance?) The second identifier of the ValueObject.

Example:

ValueLibrary.Destroy("DownVector", part)

References

3 Likes

There are attributes, I don’t really see a use case for this. And ValueInstances probably wont be deprecated.

why no OOP?? some people might want to use it.

5 Likes

You can use O.O.P outside of the module, but the module self does NOT use O.O.P, because it just isn’t the most efficient. Did you hear D.O.D? If not, here: https://www.youtube.com/watch?v=rX0ItVEVjHc. That is the most legendary learning resource on Data Oriented Design. If you really want to use O.O.P against all odds whatsoever, you could make a wrapper around the ValueLibrary.

Attributes can’t store tables and you can’t change the code for Attributes unlike for the ValueLibary.

3 Likes

I’ve looked at the source code and it’s quite simple. It would also be great if there’s documentation or example code on how to use the module.

1 Like

here’s an OOP wrapper for this module @JAcoboiskaka1121

2 Likes