Files
flutter_lua_runtime/docs/quick-start.md
2026-06-07 23:08:21 +08:00

2.0 KiB

Quick start

This package embeds manifest-driven Lua game packages in Flutter apps.

Add dependency

For private Git usage, prefer a pinned tag:

dependencies:
  flame_lua_runtime:
    git:
      url: https://gitea.sdws.shop/xim/flutter_lua_runtime.git
      ref: v0.1.0

For local development:

dependencies:
  flame_lua_runtime:
    path: ../flame_lua_runtime

Add game assets to the host app

A minimal host app should provide one game package:

assets/games/template/manifest.json
assets/games/template/scripts/main.lua
assets/games/template/scripts/state.lua
assets/games/template/scripts/ui.lua

Declare assets in the host app pubspec.yaml:

flutter:
  assets:
    - assets/games/template/manifest.json
    - assets/games/template/scripts/
    - assets/games/template/assets/

The runtime package itself provides shared Runtime Lua helpers from:

packages/flame_lua_runtime/assets/runtime/lua/

Embed in Flutter

import 'package:flutter/material.dart';
import 'package:flame_lua_runtime/flame_lua_runtime.dart';

class GameScreen extends StatelessWidget {
  const GameScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const LuaGameWidget(
      gameId: 'template',
      runtimeOptions: RuntimeOptions(
        runtimeLuaRoot: 'packages/flame_lua_runtime/assets/runtime/lua',
      ),
    );
  }
}

Run the package example

cd example
flutter run --dart-define=LUA_GAME_ID=showcase
flutter run --dart-define=LUA_GAME_ID=template
flutter run --dart-define=LUA_GAME_ID=ludo
flutter run --dart-define=LUA_GAME_ID=flight

Minimal manifest

{
  "id": "template",
  "version": "0.1.0",
  "entry": "main",
  "modules": {
    "main": "scripts/main.lua",
    "state": "scripts/state.lua",
    "ui": "scripts/ui.lua",
    "runtime_ui": "runtime:runtime_ui.lua",
    "runtime_widgets": "runtime:runtime_widgets.lua",
    "runtime_commands": "runtime:runtime_commands.lua",
    "layout": "runtime:layout.lua"
  }
}