-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (27 loc) · 915 Bytes
/
Copy pathmain.go
File metadata and controls
35 lines (27 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//go:build ignore
// 实际运行时需要修改这里为 main
package main_test
import (
"embed"
"fmt"
"log"
"github.com/ZingYao/autogo_scriptengine/lua_engine"
"github.com/ZingYao/autogo_scriptengine/lua_engine/define/android/autogo/all_models"
)
//go:embed scripts/*
var scriptsFS embed.FS
func main() {
// 初始化 Lua 引擎,配置文件系统以支持 require
config := lua_engine.DefaultConfig()
config.FileSystem = scriptsFS
engine := lua_engine.NewLuaEngine(&config)
defer engine.Close()
// 注册所有 autogo 风格模块
engine.RegisterModule(all_models.AllModules...)
// 执行主脚本;utils 名称保留给 AutoGo 模块对象,示例辅助函数放在脚本局部作用域。
if err := engine.ExecuteFile("scripts/main.lua"); err != nil {
log.Fatalf("Failed to execute main.lua: %v", err)
}
// 输出执行结果
fmt.Println("Lua autogo style example completed!")
}