axe.luascript help

BlitzMax Forums/BlitzMax Programming/axe.luascript help

You can only pass strings, numbers, and boolean parameter in the axe.luascriptengine module.

Is there a way to return a class to a lua function through the module?

I believe in lua they are called tables:
{value1="<value>",value2="<value>,etc}

How can I pass something like that to a lua function? I need to get this working in order to pass several attributes of a TItem type I have going.

Thanks

I tried messing around with the lua stuff a couple months ago, but no one on here is very interested in it - it was a pain just finding the thing. So I moved over to looking at BriskVM.

I'm interested in Lua :-). Although I used axe.lua. I don't know what axe.luascript is?

The tutorial over at GameDev helped me understand how to use Lua in BlitzMax: http://www.gamedev.net/reference/programming/features/lua/

You can skip the first pages since it's about implementing it in C++ but the rest is almost the same as with BlitzMax.

Here's a small example:

test.bmx
SuperStrict
Import axe.lua

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

lua_pushstring(LuaState, "BMXString")
lua_setglobal (LuaState, "luaglobal")

lua_register(LuaState, "BMXName", BMXName)
luaL_dofile(luaState, "test1.lua");
lua_close(LuaState)

End

Function BMXName:Int (LuaState:Byte Ptr)
	' handling of parameters passed from Lua (if required)
	' actual function body
	' passing results back to Lua (if required)
	luaL_dostring(LuaState, "print('Ahum!')")
	Return 0 ' number of values returned to Lua
End Function


test.lua
print("Test!");
print(luaglobal);

-- Simple lua script
-- comments indicated with a '--'
a = 5;
b = 10;
c = a + b;
print ("5+10=" .. c);

BMXName();



Very simple example but it does show how you can call your BlitzMax functions in a Lua script.

As for methods, I'm now sure. Native Lua doesn't support it if I'm correct. I must say I haven't done a lot with Lua yet but the way I figured is that you need to create Functions that can access the required object.

I ended up just going a less efficient route by retreiving field counts and having lua request each field independently.

There just does not seem to be a way to pass a table of values through lua from blitzmax properly. And i'm not the one to spend more then a day on the same thing as this is just one of the million things I need to get going.

I tried messing around with the lua stuff a couple months ago, but no one on here is very interested in it - it was a pain just finding the thing. So I moved over to looking at BriskVM.


That's too bad, Lua is great. And I know what you mean...there's hardly any topics on it. I spent some time screwing around with Garrys Mod lua to get a better understanding of how most is done before working on it.

The issue is more with understanding the axe.lua(script) modules, as lua itself is pretty straight forward.

There just does not seem to be a way to pass a table of values through lua from blitzmax properly

I only looked at Lua briefly and some time ago at that, but isn't it possible for the Blitz function to push a bunch of stuff on to the stack for Lua to pick up?

I would quite like to get more familiar with Lua myself but, as has been said, it's difficult getting definitive info on it -- I don't even know which of the existing modules is the recommended.

I don't even know which of the existing modules is the recommended.

I recommend Andreas Rozek's modified version of Axe.Lua. It's excellent.

Can't help with passing a table from BlitzMax. I think you can use Lua_PushValue if the table is already on the stack somewhere to push it up to the top. But no idea about anything else.