ParelVRDocs
Player site

Scripting / Reference

Data

Types in the ParelVR.Volt.Data namespace.

VoltData#

ParelVR.Volt.Data.VoltData class

Structured data with named values, the shape of a JSON object. Use it for web requests, storage and anything that needs more than a flat list of fields.

VoltData constructors#

new VoltData()

Creates an empty object.

VoltData properties#

int Count { get; }

Number of named values.

VoltDataToken this[] { get; set; }

The value of a name. A token that holds nothing when the name is not present.

VoltData methods#

void Clear()

Removes every named value.

bool ContainsKey(string key)

True when a name is present.

bool GetBool(string key, bool fallback)

Bool value of a name, or a fallback.

float GetFloat(string key, float fallback)

Number value of a name as a float, or a fallback.

int GetInt(string key, int fallback)

Number value of a name as an int, or a fallback.

string[] GetKeys()

Every name, in the order the values were added.

string GetString(string key, string fallback)

Text value of a name, or a fallback.

bool Remove(string key)

Removes a named value.

VoltDataList#

ParelVR.Volt.Data.VoltDataList class

A list of data tokens.

VoltDataList constructors#

new VoltDataList()

Creates an empty list.

VoltDataList properties#

int Count { get; }

Number of tokens.

VoltDataToken this[] { get; set; }

The token at an index.

VoltDataList methods#

void Add(VoltDataToken token)

Adds a token at the end.

void Clear()

Removes every token.

void RemoveAt(int index)

Removes the token at an index.

VoltDataToken#

ParelVR.Volt.Data.VoltDataToken class

One value of structured data: nothing, a bool, a number, text, a list or an object.

VoltDataToken properties#

bool Boolean { get; }

The bool, or false when the token is not a bool.

float Float { get; }

The number as a float, or 0.

int Int { get; }

The number as an int, or 0.

bool IsNull { get; }

True when the token holds nothing.

VoltDataList List { get; }

The list, or null when the token is not a list.

static VoltDataToken Null { get; }

A token that holds nothing.

double Number { get; }

The number, or 0 when the token is not a number.

VoltData Object { get; }

The object, or null when the token is not an object.

string String { get; }

The text, or an empty string when the token is not text.

VoltDataType Type { get; }

What the token holds.

Operators and conversions: 7 available.

VoltDataType#

ParelVR.Volt.Data.VoltDataType enum

What a data token holds.

Values: Null, Boolean, Number, String, List, Object

VoltDictionary#

ParelVR.Volt.Data.VoltDictionary<TKey, TValue> class

A table that finds a value by its key. Keys can be numbers, strings, bools, characters and enums.

VoltDictionary constructors#

new VoltDictionary<TKey, TValue>()

Creates an empty dictionary.

VoltDictionary properties#

int Count { get; }

Number of entries.

TValue this[] { get; set; }

The value of a key. Reading a key that is not present stops the script with an error; use TryGetValue when unsure.

VoltDictionary methods#

void Add(TKey key, TValue value)

Adds an entry. The key must not be present yet.

void Clear()

Removes every entry.

bool ContainsKey(TKey key)

True when a key is present.

TKey[] GetKeys()

A new array with every key, in the order the entries were added.

TValue[] GetValues()

A new array with every value, in the order the entries were added.

bool Remove(TKey key)

Removes an entry. Returns false when the key was not present.

bool TryGetValue(TKey key, TValue value)

Reads a value if its key is present.

VoltJson#

ParelVR.Volt.Data.VoltJson static

Converts between structured data and JSON text. Input is limited to one megabyte and 32 levels of nesting.

VoltJson methods#

static string Serialize(VoltDataToken token)

Writes a token as JSON text.

static string SerializeIndented(VoltDataToken token)

Writes a token as JSON text with line breaks and indentation.

static bool TryParse(string json, VoltDataToken result)

Reads JSON text. Returns false when the text is not valid JSON or is too large.

VoltList#

ParelVR.Volt.Data.VoltList<T> class

A resizable list. Every list counts toward the world's script memory, and a list cannot grow beyond one million items.

VoltList constructors#

new VoltList<T>()

Creates an empty list.

VoltList properties#

int Count { get; }

Number of items.

T this[] { get; set; }

The item at an index.

VoltList methods#

void Add(T item)

Adds an item at the end.

void AddRange(T[] items)

Adds every item of an array at the end.

void Clear()

Removes every item.

bool Contains(T item)

True when the list holds an item equal to a value.

int IndexOf(T item)

Index of the first item equal to a value, or -1.

void Insert(int index, T item)

Puts an item at an index and moves the rest up.

bool Remove(T item)

Removes the first item equal to a value. Returns false when there is none.

void RemoveAt(int index)

Removes the item at an index.

void Reverse()

Reverses the order of the items.

void Sort()

Sorts numbers and strings from smallest to largest. Other items keep their order.

T[] ToArray()

A new array with the items of the list.