gameObjects.scriptBehaivior#

class gameObjects.scriptBehaivior.ScriptBehaivior(context, gameObject)#

Bases: object

class Exported(default=None)#

Bases: object

Exported Attribute System - IMPORTANT DESIGN NOTES

When a script declares:

value : int = export(1)

the class attribute value does not become an integer. Instead, it becomes an instance of Exported, which stores metadata about the exported field:

  • the default value (1)

  • the expected type (int)

  • whether the export is active/valid

At runtime, the script instance receives a separate attribute:

self.value
This is initialized during script loading using:

setattr(script_instance, name, value.default)

Meaning:
  • Class-level: value -> Exported(…) (metadata object)

  • Instance: self.value -> actual runtime value (e.g. int)

For primitive types (int, float, bool, str):
  • value.default holds the raw primitive value

  • self.value receives a COPY of that primitive

  • They contain the same data but are distinct objects

For engine reference types (e.g. Transform, GameObject references):
  • value.default stores a UUID (persistent identifier)

  • self.value is resolved at runtime into the actual GameObject with to that UUID

In other words:
  • value = Exported(…): metadata about the field

  • self.value = the runtime value used during script execution (onUpdate, etc.)

__init__(default=None)#
default_for_annotation_type(t)#

Return a default value for a given type.

For primitive types: returns 0, 0.0, False, or “” For other types: tries to instantiate t(), returns None when failed.

Parameters:

t – Type to get default value for

Returns:

Default value for the type or None

get()#

Get the meta value used to init the instance attribute

Returns:

Either primitive value, or UUID

Return type:

int | float | bool | str | uuid.UUID

set(value) None#

Set meta value for this export, user for saving and loading

if primitive type, validate that the value matches the current data type

else, engine types allow mismatched types. eg, ‘value.default’ contains the UUID, and instance ‘self.value’ is resolved to that GameObject at runtime

__init__(context, gameObject)#

Base class for dynamic loaded scripts, setting up references to context, events and the gameObject itself

Parameters:
  • context (EmberEngine) – This is the main context of the application

  • gameObject (GameObject) – A reference to the gameObject the script is attached to

export()#

Create an exported script attribute.

Used inside script classes to declare editable fields:

  • value: int = export(1)

  • value: float = export(1.0)

  • value: bool = export(True)

  • value: str = export(“Hello world”)

  • value: Transform = export() # no argument

During script loading, exported class attributes are detected and their values are copied into the script instance as:

# either the stored scene value, a type-based default, or a resolved GameObject reference (for engine types)

self.value

Parameters:

default – Optional initial value. When omitted, a type-based default is used.

Returns:

An Exported metadata descriptor.

Return type:

ScriptBehaivior.Exported

onDisable()#

Implemented by script

onEnable()#

Implemented by script

onStart()#

Implemented by script

onUpdate()#

Implemented by script