lua

package module
v0.0.0-...-6dfe530 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2019 License: MIT Imports: 10 Imported by: 0

README

cgo-lua

A Go(lang) wrapper for LuaJit-2.x(Lua JIT Library) which is often used for embed script support. Forked from [RyouZhang] (https://github.com/RyouZhang/go-lua)

Build Status GoDoc

To use the library you need LuaJit 2.0/2.1 installed.

Example

package main

import (
	"fmt"
	"github.com/kjx98/cgo-lua"
)


func main() {
	res, err := lua.Call("script.lua", "test_args", 69)
	if err != nil {
		fmt.Println("test_args", err)
	} else {
		fmt.Println(res)
	}
}

Installing

Install the dependencies then run

$ go install github.com/kjx98/cgo-lua
Dependencies

To use luajit for go, you need to have the Luajit-2.x already installed:

Mac OS X
$ brew install luajit
Linux

Install from your package manager or install from source.

On Debian/Ubuntu/Fedora Linux luajit-2.1 is available from the distro.

To compile first download Luajit-2.1 and:

$ untar and cd
$ make
$ sudo make install

License

Copyright (c) 2018 Jesse Kuang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(filePath string, methodName string, args ...interface{}) (interface{}, error)

Call -- dofile(filePath) and call methodName on vm

func DoFile

func DoFile(scriptPath string) error

DoFile -- dofile on all core vm

func ExpireScript

func ExpireScript(filePath string)

func LoadScript

func LoadScript(filePath string) (string, error)

func LuaNumberToFloat32

func LuaNumberToFloat32(value interface{}) (float32, error)

func LuaNumberToFloat64

func LuaNumberToFloat64(value interface{}) (float64, error)

func LuaNumberToInt

func LuaNumberToInt(value interface{}) (int, error)

func LuaNumberToInt32

func LuaNumberToInt32(value interface{}) (int32, error)

func LuaNumberToInt64

func LuaNumberToInt64(value interface{}) (int64, error)

func RefreshScriptCache

func RefreshScriptCache()

func RegisterExternMethod

func RegisterExternMethod(methodName string, method func(...interface{}) (interface{}, error)) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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