BLitzmax - LUA ?

BlitzMax Forums/BlitzMax Programming/BLitzmax - LUA ?

Does anyone know where I can download an LUA mod?

or any other scripting language.

I tried BriskVm but it crashes when I use lists.

I *think* this is the latest.

http://www.blitzbasic.com/Community/posts.php?topic=69429

And from the Lua-users wiki: http://lua-users.org/wiki/BlitzMax

I've got a local copy I updated to use Lua-5.1.4. If you want I can post it here.

thanks both of y'all

yeh could I have the 5.1.4 please?

Here you go: http://www.htbaa.com/download/axe.mod.lua.mod-5.1.4.zip
You still need to compile it though, I hope that's not a problem. I wasn't sure which files needed to be included for that. I presume the .a and .i files?

thanks,

has anyone got a tutorial or set of examples ?

http://www.lua.org/pil/ is a nice book. The 1st edition is available online. I've got a hardcopy of the 2nd edition myself.

What exactly do you want to know? Lua is fairly new for me as well but I've been playing quite a bit with making Lua and BlitzMax interact.

Here a small example to help you started, to expose a BlitzMax function to Lua:

LuaState:Byte Ptr
LuaState = luaL_newstate()
luaL_openlibs(LuaState)

lua_register(LuaState, "bmxCameraMove", LuaCameraMove)
luaL_dostring("bmxCameraMove(100,200)")
lua_close(LuaState)

Function LuaCameraMove:Int(LuaState:Byte Ptr)
	Local x:Int = luaL_checkinteger(LuaState, 1)
	Local y:Int = luaL_checkinteger(LuaState, 2)
	TCamera.GetInstance().RemoveFocus()
	TCamera.GetInstance().SetPosition(x, y)
	Return 0
End Function


Important to know, every BlitzMax function exposed to Lua must return an integer containing the amount of values you pushed on to the stack.

Have fun with Lua.

thanks,

An ideal tutorial would consist of
1.blitzmax code as above - to expose functions
2.a small sample LUA script just to see things running
3.blitzmax code to run the script

I tried this but nothing was printed:
Import axe.lua
Import axe.luascript

Local LuaState:Byte Ptr
LuaState = luaL_newstate()
luaL_openlibs(LuaState)

lua_register(LuaState, "bmxCameraMove", LuaCameraMove)
luaL_dostring(luastate,"bmxCameraMove(100,200)")
lua_close(LuaState)

Function LuaCameraMove:Int(LuaState:Byte Ptr)
Local x:Int = luaL_checkinteger(LuaState, 1)
	Local y:Int = luaL_checkinteger(LuaState, 2)
 Print "x "+x+" y "+y
	Return 0
End Function


I ran it without axe.luascript (I don't have that module) and it worked fine.