Cloud Variables

From Neos Wiki
Revision as of 19:02, 28 April 2021 by Turk (talk | contribs) (Created page with "=What are Cloud Variables?= Cloud Variables are concept that allow persistence across worlds<br> They work in a similar nature to Dynamic Variables but instead of relying...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

What are Cloud Variables?

Cloud Variables are concept that allow persistence across worlds
They work in a similar nature to Dynamic Variables but instead of relying on parenting, they rely heavily on a defined path and User
Cloud variables do not take up any storage, but instead they have a fine limit.
Between Users and Groups, there is a fine limit of 256 Definitions for Users and 8192 for Groups.
Meaning, you can have 256 different paths(test.banana.cheese), each with their own type but as many different values.
(Sam has Red, Sally has Black, Tom has Blue)

The current following datatypes are supported:
-- Neos/C# primitives - bool, byte, int, float, double, etc.
-- string and string:<max_length> (default length of string is 256, maximum is 8192)
-- uri, datetime and timespan
-- More datatypes will be supported in the future
-- Currently they cannot be deleted -- Reads/writes are buffered, batched and cached and will take a bit to propagate. All active instances within Neos are synced in realtime -- Variable Definitions are heavily cached and will typically take several minutes to update. It's recommended to set them up fully in advance -- Current limits, permissions, and other aspects are subject to change

How do they work?

For a Cloud Variable to exist currently they need to be predefined in the NeosBot
To Do so here are the list of commands, and here is a typical setup when predefining a value to be used within the system.
You'll notice most of the commands use /get /set /list/ and /create for actions and then add on respectively for
<Owner> <type> <perm_type> <permission>

List of Commands for Cloud Variables

Here's a list of commands separated by User and Groups

/createUserVar <path>
/setUserVarType <path> <type>
/setUserVarValue (<user>) <path> <value>
/setUserVarDefaultValue <path> <value>
/setUserVarPerms <path> <perm_types> <permissions>

/getUserVar <path>
/getUserVarValue (<user>) <path> (<target user>)
/listUserVars (<user>)


/createGroupVar <group> <path>
/setGroupVarType <group> <path> <type>
/setGroupVarValue <group> <path> <value> (<target user>) <value>
/setGroupVarDefaultValue <group> <path> <value>
/setGroupVarPerms <group> <path> <perm_types> <permissions>

/getGroupVar <group> <path>
/getGroupVarValue <group> <path> (<target user>)
/listGroupVars <group>

Access Permissions:

read -> Who can read the value of given variable
write -> Who can write to the value of given variable
list -> Who can see the definition of given variable
all -> Shortcut to set all of them

You can also do multiple perms at once separated by a comma so something like /setUserVarPerm test.color read,write,list anyone

User Permissions:

definition_owner -> Only the user/group who defined the variable can read/write/list it
variable_owner -> Only the user/group who own the variable (the value) can read/write it in safe context (e.g. Userspace)
variable_owner_unsafe -> Same as above, but works in public (outside Userspace). Requires presence of the user owning the variable value, but anyone in the public world could potentially alter the value
anyone -> Anyone can read/write/list given variable, recommended for read/list for public variables, generally not recommended for writes (means absolutely anyone can change anyone's value)

Examples

/createUserVar testing.enabled
/setUserVarType testing.enabled bool
/setUserVarPerms testing.enabled read anyone
/setUserVarPerms testing.enabled write variable_owner_unsafe

/createUserVar testing.myColor
/setUserVarType testing.myColor color
/setUserVarPerms testing.myColor read variable_owner_unsafe
/setUserVarPerms testing.myColor write variable_owner

/createGroupVar MyGroup testing.enabled
/setGroupVarType MyGroup testing.enabled bool
/setGroupVarPerms MyGroup testing.enabled read,write,list variable_owner_unsafe