Skip to content

luxe: system/values.modifier


import "luxe: system/values.modifier" for Data

no docs found

var values : List = []
import "luxe: system/values.modifier" for Value

no docs found

var kind : ValuesKind = ValuesKind.number
var name : String = "value"
var number : Num = 0
var string : String = ""
var boolean : Bool = false
var float2 : Float2 = [0, 0]
var float3 : Float3 = [0, 0, 0]
var float4 : Float4 = [0, 0, 0, 0]
var color : Color = [1, 1, 1, 1]
import "luxe: system/values.modifier" for Values

Values is a modifier that lets you store Key -> Value pairs. Store values like numbers, strings, and colors on an entity, which can then be accessed by name (a Key).

//we can use an enum for keys
class Keys {
static watered { "watered" }
static apples { "apples" }
}
var tree = Entity.create(world)
Values.create(tree)
Values.set(tree, Keys.watered, true)
Values.set(tree, Keys.apples, 10)
Values.set(tree, "keys are strings", true)
var watered = Values.get(tree, Keys.watered, false)
var apples = Values.get(tree, Keys.apples, -1)
Log.print("The tree is %(watered ? "watered" : "thirsty") and has %(apples) apples!")

Values.create(entity : Entity) : None

Attach a Values modifier to entity.

var entity = Entity.create(world)
Values.create(entity)

Values.destroy(entity : Entity) : None

Detach and destroy the Values attached to entity

Values.destroy(entity)

Values.has(entity : Entity) : Bool

Returns true if entity has a Values modifier attached.

if(Values.has(entity)) {
Log.print("Has a Values modifier!")
}

Values.has_key(entity : Entity, key : String) : Bool

Returns true the entity’s Values modifier has a value with the given ‘key’

if(Values.has_key(entity, "apples")) {
Log.print("The tree has some apples!")
}

Values.remove_key(entity : Entity, key : String) : None

Removes a value by key from ‘entity’s Values modifier, if it exists

Values.remove_key(tree, "apples")

Values.get_keys(entity : Entity) : List

Get a List of all the String keys for values on ‘entity’s Values modifier

var keys = Values.get_keys(grass)
for (key in keys) {
Log.print("Has Value Key: %(key)")
}

Values.get(entity : Entity, key : String, default : Any) : Any

Get the current value stored with key on the Values modifier on entity, with a default value which is returned if the key isn’t found.

var seeds = Values.get(watermelon, "seeds", 0)
Log.print("The watermelon has %(seeds) seeds!")

Values.set(entity : Entity, key : String, value : Any) : None

Set the value stored at the ‘key’ on the Values modifier on ‘entity’.

if(Values.has(seed)) {
Values.set(seed, "planted", true)
}
import "luxe: system/values.modifier" for ValuesKind

no docs found

ValuesKind.number : unknown

no docs found

ValuesKind.string : unknown

no docs found

ValuesKind.boolean : unknown

no docs found

ValuesKind.float2 : unknown

no docs found

ValuesKind.float3 : unknown

no docs found

ValuesKind.float4 : unknown

no docs found

ValuesKind.color : unknown

no docs found

import "luxe: system/values.modifier" for ValuesType

no docs found

ValuesType.unknown : unknown

no docs found

ValuesType.bool : unknown

no docs found

ValuesType.number : unknown

no docs found

ValuesType.string : unknown

no docs found

ValuesType.float2 : unknown

no docs found

ValuesType.float3 : unknown

no docs found

ValuesType.float4 : unknown

no docs found

ValuesType.name(value : Any) : unknown

no docs found