flutter_lua_vm

package module
v0.0.0-...-2ac651e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2019 License: Unlicense Imports: 2 Imported by: 0

README

Flutter Lua Plugin

Project license Pub package Dartdoc reference Travis CI build status Liberapay patrons

This is a Flutter plugin that embeds a Lua interpreter and runtime for executing dynamic scripts from Flutter apps.

Features

  • Embeds a Lua 5.2 interpreter into your Flutter app.

  • Executes Lua code on a background thread (not on the main UI thread).

  • Supports executing source code snippets from strings as well as from source files bundled in your app's asset bundle.

Compatibility

Android and iOS both.

Examples

Checking the Lua runtime version
import 'package:flutter_lua/flutter_lua.dart' show Lua;

print(await Lua.version);
Spawning a new Lua interpreter thread
import 'package:flutter_lua/flutter_lua.dart' show LuaThread;

var thread = await LuaThread.spawn();
Evaluating a Lua code snippet
import 'package:flutter_lua/flutter_lua.dart' show LuaThread;

var thread = await LuaThread.spawn();

await thread.eval("return 6 * 7"); //=> 42.0
Executing a bundled Lua source file
import 'package:flutter_lua/flutter_lua.dart' show LuaThread;

var thread = await LuaThread.spawn();

await thread.execAsset("scripts/myscript.lua");

Frequently Asked Questions

How much does using this plugin increase my final app size?

About 3.8 MiB, at present.

Caveats

  • Currently the only supported result datatypes from LuaThread#eval*() methods are booleans, floating-point numbers (doubles), and strings. This will be extended further over the next releases.

Documentation

Overview

Package flutter_lua_vm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version

Types

type State

type State struct {
	// contains filtered or unexported fields
}

State

func NewState

func NewState() *State

NewState

func (*State) BoolValue

func (state *State) BoolValue() bool

BoolValue

func (*State) DoubleValue

func (state *State) DoubleValue() float64

DoubleValue

func (*State) ExecFile

func (state *State) ExecFile(path string) error

ExecFile

func (*State) ExecString

func (state *State) ExecString(code string) error

ExecString

func (*State) HasResult

func (state *State) HasResult() bool

HasResult

func (*State) IntValue

func (state *State) IntValue() int

IntValue

func (*State) LongValue

func (state *State) LongValue() int

LongValue

func (*State) ResultType

func (state *State) ResultType() int

ResultType

func (*State) StringValue

func (state *State) StringValue() string

StringValue

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL