Skip to content

Instantly share code, notes, and snippets.

@keenan-v1
Created October 5, 2019 15:35
Show Gist options
  • Save keenan-v1/2189d7cedd5cde4295f616661b32bc33 to your computer and use it in GitHub Desktop.
Save keenan-v1/2189d7cedd5cde4295f616661b32bc33 to your computer and use it in GitHub Desktop.
Learning lua in an odd way
print("Hello World")
go_print("Hello from Go inside Lua")
print(test_str)
package main
import (
"fmt"
"github.com/Shopify/go-lua"
)
func goPrint(l *lua.State) int {
n := l.Top()
if n != 1{
panic("expected 1 argument")
}
s := lua.CheckString(l, 1)
fmt.Println(s)
return 0
}
func main() {
l := lua.NewState()
lua.OpenLibraries(l)
l.PushGoFunction(goPrint)
l.SetGlobal("go_print")
l.PushString("testing123")
l.SetGlobal("test_str")
if err := lua.DoFile(l, "hello.lua"); err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment