LuauState class abstract

Constructors

LuauState()

Properties

consoleHasData → ChangeNotifier
final
hashCode → int
The hash code for this object.
no setterinherited
hasPendingAsyncWork → bool
Check if there are any pending async tasks.
no setter
isDisposed → bool
Returns true if this VM has been disposed. After disposal, all operations on this state are invalid.
no setter
nativeAddress → int
Returns the integer address of the underlying native Lua state pointer. Used to detect pointer reuse when swapping VMs.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

advanceDetachedViewModels() → void
Advances (resets) script-created view model instances that are detached from any bound view model tree. Call once at the end of each frame so fired triggers are consumed/re-armed. Mirrors the runtime's Artboard::advanceScriptedViewModels.
booleanAt(int index) → bool
call(int numArgs, int numResults) → void
clearGeneratorRefs() → void
Clear all stored generator refs. Called when VM is disposed.
clearStateWithFile(File file) → void
createMetaTable(String name) → void
Creates a meta table
createTable({int arraySize = 0, int recordCount = 0}) → void
Creates a table and pushes it on the stack, reserving memory for arraySize and recordCount.
createViewModelInstance(File file, String viewModelName) → int
createViewModelInstanceFromInstance(File file, String viewModelName, String viewModelInstanceName) → int
dataValueAt(int index) → ScriptedDataValue
decodeImage() → int
Decodes image data from Lua stack position 2 and pushes a Promise. Returns 1 (promise pushed) or 0.
disableDrawCanvasPhase() → void
dispose() → void
dumpStack() → void
enableDrawCanvasPhase() → void
equal(int index1, int index2) → bool
gc(GarbageCollection what, [int data = 0]) → int
Controls the garbage collector. This function performs several tasks, according to the value of the what parameter.
getExecutionTimeout() → int
Gets the current execution timeout in milliseconds.
getField(int index, String name) → LuauType
Pushes onto the stack the value tk, where t is the value at the given index. As in Lua, this function may trigger a metamethod for the "index" event.
getGeneratorRef(int assetId) → int
Get a generator ref from the scripting context by asset ID. Returns 0 if not found.
getGlobal(String name) → LuauType
Pushes onto the stack the value of the global name. Returns the type of that value.
getTop() → int
lua_gettop equivalent. Returns the number of elements in the stack, which is also the index of the top element. Notice that a negative index -x is equivalent to the positive index gettop - x + 1.
gpuBeginFrame() → void
Begins a GPU frame. Must be called before any GPU canvas draw calls.
gpuEndFrame() → void
Ends a GPU frame. Must be called after all GPU canvas draw calls.
insert(int index) → void
integerAt(int index) → int
isBoolean(int index) → bool
isBuffer(int index) → bool
isFunction(int index) → bool
isInteger(int index) → bool
isLightUserdata(int index) → bool
isNil(int index) → bool
isNumber(int index) → bool
isString(int index) → bool
isTable(int index) → bool
isThread(int index) → bool
isUserdata(int index) → bool
isVector(int index) → bool
lessThan(int index1, int index2) → bool
load(String name, Uint8List bytecode, {int env = 0}) → void
memoryUsedKB() → int
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
numberAt(int index) → double
pathAt(int index) → ScriptedPath
pcall(int numArgs, int numResults) → LuauStatus
pollAsyncWork({int maxCallbacks = 16}) → int
Poll for completed async tasks (image decodes, etc.) and invoke callbacks. Returns the number of callbacks processed.
pop(int count) → void
pushArtboard(Artboard artboard, InternalDataContext? dataContext) → void
pushAudio(AudioSource audio) → int
Pushes AudioSource onto the Lua stack as a ScriptedAudioSource userdata. Returns 1 if successful, 0 if the image is null.
pushBlob(String name, Uint8List data) → void
pushBoolean(bool value) → void
pushCanvas(int width, int height) → int
Creates a (non-GPU) Canvas and pushes it onto the Lua stack. Returns 1 on success, pushes nil and returns 1 on failure.
pushDataContext(InternalDataContext dataContext) → int
pushDataValueBoolean(bool value) → ScriptedDataValue
pushDataValueColor(int value) → ScriptedDataValue
pushDataValueNumber(double value) → ScriptedDataValue
pushDataValueString(String value) → ScriptedDataValue
pushFocusListenerInvocation(bool isFocus) → void
pushFont(Font font) → int
Pushes font onto the Lua stack as a Font userdata. Returns 1 on success, 0 when the font could not be pushed.
pushFunction(LuauFunction t, {String debugName = 'unknown'}) → void
pushGamepadListenerInvocation({required int kind, required int deviceId, required int buttonMask, required List<double> buttonValues, required List<double> axes, required int mapping, int changeKind = 0, int changeIndex = 0, double changeValue = 0}) → void
Push the ScriptedInvocation userdata that backs a Luau listener action's performAction(self, listenerContext) for gamepad records. kind is 0 (connected), 1 (event), or 2 (disconnected) and selects which ListenerInvocation variant the script sees via isGamepad* / asGamepad*. changeKind, changeIndex, and changeValue are only consumed when kind is event.
pushGPUCanvas(int width, int height) → int
Creates a GPUCanvas and pushes it onto the Lua stack. Returns 1 on success, pushes nil and returns 1 on failure. The canvas is a 1× presentation target only; MSAA color + depth are user-allocated via GPUTexture.new and passed in the canvas:beginRenderPass(desc) descriptor.
pushGPUFeatures() → int
Pushes a GPU features table onto the Lua stack. Queries the ORE context when available, otherwise returns conservative defaults. Always returns 1.
pushImage(RenderImage image) → int
Pushes a RenderImage onto the Lua stack as a ScriptedImage userdata. Returns 1 if successful, 0 if the image is null.
pushInteger(int value) → void
pushKeyboardListenerInvocation(int key, int modifiers, bool isPressed, bool isRepeat) → void
pushMatrix(Mat2D value) → void
pushNil() → void
pushNoneListenerInvocation() → void
pushNumber(double value) → void
pushPath(RenderPath path) → void
pushPointerEvent(int id, Vec2D position) → PointerEvent
pushPointerListenerInvocation(int id, Vec2D position, Vec2D previousPosition, int listenerType, double timeStamp) → void
pushRef(int id) → LuauType
pushRenderer(Renderer renderer) → ScriptedRenderer?
Pushes a renderer onto the Lua stack. Returns null if the renderer is invalid (e.g., null pointer).
pushReportedEventListenerInvocation(double delaySeconds) → void
pushScriptedGamepadInvocation({required int kind, required int deviceId, required int buttonMask, required List<double> buttonValues, required List<double> axes, required int mapping, int changeKind = 0, int changeIndex = 0, double changeValue = 0}) → void
Push the Lua userdata expected by a ScriptedDrawable's gamepadConnected / gamepadEvent / gamepadDisconnected method. kind is 0 (connected), 1 (event), or 2 (disconnected). changeKind, changeIndex, and changeValue are only consumed when kind is event.
pushScriptedKeyboardInvocation(int key, int modifiers, bool isPressed, bool isRepeat) → void
Node script keyboardEvent (KeyboardInvocation userdata), not listener ScriptedInvocation.
pushScriptedTextInputInvocation(String text) → void
Node script textEvent (TextInputInvocation userdata).
pushShader(String name) → int
Looks up a shader by name from the per-VM ScriptingContext (editor) or file assets (runtime) and pushes the ScriptedShader onto the stack. Returns 1 on success, 0 if not found or compile failed.
pushString(String value) → void
pushTextInputListenerInvocation(String text) → void
pushUnsigned(int value) → void
pushValue(int index) → void
Pushes on the top of the stack a copy of the element at the given index.
pushVector(Vec2D value) → void
pushViewModel(InternalDataContext dataContext) → int
pushViewModelChangeListenerInvocation() → void
pushViewModelInstanceValue(InternalViewModelInstanceValue value) → void
rawGetField(int index, String name) → LuauType
lua_rawgetfield equivalent. Pushes onto the stack tk, where t is the table at the given index. The access is raw, that is, it does not invoke the __index metamethod. Returns the type of the pushed value.
rawGeti(int idx, int n) → LuauType
lua_rawgeti equivalent. Pushes onto the stack the value tn, where t is the table at the given index. The access is raw, that is, it does not invoke the __index metamethod. Returns the type of the pushed value.
readConsole(List<ConsoleEntry> entries) → bool
ref(int idx) → int
lua_unref equivalent. Stores the value at idx in the registry and returns an integer id to unref and get it. This is a strong reference, the object will not get garbage collected until it is unreffed.
registerModule(String name, Uint8List bytecode) → bool
registerScript(String name, Uint8List bytecode) → bool
remove(int index) → void
Removes the element at the given valid index, shifting down the elements above this index to fill the gap. Cannot be called with a pseudo-index, because a pseudo-index is not an actual stack position.
renderPath(ScriptedPath path, RenderPath renderPath) → RenderPath?
replace(int index) → void
Moves the top element into the given valid index without shifting any element (therefore replacing the value at that given index), and then pops the top element.
setExecutionTimeout(int timeoutMs) → void
Sets the execution timeout in milliseconds. A value of 0 disables the timeout entirely. Default is 50ms.
setField(int index, String name) → void
Does the equivalent to tk = v, where t is the value at the given index and v is the value on the top of the stack.
setGeneratorRef(int assetId, int ref) → void
Store a generator ref in the scripting context, keyed by asset ID. This allows ScriptAsset::initScriptedObjectWith() to look up refs without needing to serialize/deserialize through genRuntimeFile.
setGlobal(String name) → void
setMetaTable(int index) → void
The function pops a table from the stack and sets it as the metatable of the object at the given index.
setTop(int index) → void
lua_settop equivalent.
startPlayback() → void
Indicates to the vm that playback has started
stopPlayback() → void
Indicates to the vm that playback has stopped
stringAt(int index) → String
toString() → String
A string representation of this object.
inherited
typeAt(int index) → LuauType
unref(int id) → void
Removes the reference with id from the registry. The object will be garbage collected when it is no longer used elsewhere.
unregisterModule(String name) → void
unsignedAt(int index) → int
vectorAt(int index) → Vec2D
where(int level) → void
Pushes onto the stack a string identifying the current position of the control at level level in the call stack. Typically this string has the following format: chunkname:currentline:
writeConsole(ConsoleEntry entry) → void

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

adopt(int vmPointer, Factory riveFactory, {RenderTexture? renderTexture}) → LuauState
Adopt a ScriptingVM created by C++ requestVM. Replaces the C++ scripting context with one compatible with Dart (factory + console callback). On web, renderTexture provides the GL context handle for this VM.
init(Factory riveFactory) → LuauState

Constants

luaGlobalsIndex → const int
luaRegistryIndex → const int
maxCStack → const int