Lua ... which ??

BlitzMax Forums/BlitzMax Programming/Lua ... which ??

mic_pringle(Posted 2009) [#1]
Hi,

I've been looking to implement Lua scripting for a project I'm about to start working on, so I've been searching the forums and it seems there are a plethora of Lua modules/implementations available ...

brl.lua
axe
LuGi
brl.MaxLua

... just to name a few.

Can anyone suggest the best and most complete one to use ?

I've a feeling it perhaps will be axe but from what I've seen that's only Lua 5.1.1 and I'd really like to use 5.1.4

Thanks

-Mic


Htbaa(Posted 2009) [#2]
axe.lua is the old one. pub.lua is the most recent one and updated to 5.1.4. brl.lua doesn't exist.

brl.maxlua is supposed to be an easy wrapper for BlitzMax to Lua. But LuGi does a far better job at it for what I can see. Haven't tested it yet but I would stay away from brl.maxlua. As brl.maxlua, I think, still uses a global Lua VM which isn't always something you want.

(if anything I say here is incorrect, please do correct me).

So pub.lua is the core Lua module. And optionally you can use LuGi or brl.maxlua to ease the process of connecting your BlitzMax code with Lua.


mic_pringle(Posted 2009) [#3]
Hi Htbaa,

Thanks for the reponse.

So pub.lua is 5.1.4 - that's great, something I didn't realise. And I take it this is included in the stock BlitzMax download ?

Is it as comprehensive and complete as axe is/was ?

Also, since it's you that's replied, I've also been looking at your fsm.mod. Do you have any forums posts I can read up about it on ?

Thanks

-Mic


Htbaa(Posted 2009) [#4]
Yeah pub.lua is now in the stock BlitzMax download. It's almost the same as the latest axe.lua but updated to the latest Lua and the module is no longer dependent to brl.retro. And there were some changes luaconf.h to support LUA_USE_LINUX and LUA_USE_MACOSX.

About my fsm.mod. I've got a request for some examples. Currently working on them, but not sure when they'll be done.


JoshK(Posted 2009) [#5]
lugi is the only one worth using. The others use real-time reflection and will be extremely slow once you start using it in earnest. I paid Noel to make lugi to overcome this problem.


mic_pringle(Posted 2009) [#6]
@Leadwerks

I'm not sure I follow ... could you please elaborate on your statement ?

Thanks

-Mic


N(Posted 2009) [#7]
I'm not sure I follow ... could you please elaborate on your statement ?
I think what he's talking about is that brl.MaxLua and my luareflection code (LuGI's predecessor) both resolve everything at runtime through a series of proxy functions that use the brl.Reflection module to translate and pass messages to the actual objects. In MaxLua's case, it's slightly less flexible since you can only actually register objects as global variables, and those have to act as factories and generally the public API used by Lua.

LuGI, on the other hand, generates glue code (although you don't have to generate the code, if you don't, the objects will only have Compare, SendMessage, and ToString accessible from Lua) that you import into your project, then it registers the generated code with LuGI's core so that it can build VMTs for all the types exposed to Lua scripts. None of the glue code uses reflection during script execution, and only briefly uses it when initializing the code (so that it can get pointers to exposed types' BBClasses).

Hopefully that makes sense. I got distracted a few different times while writing that...

Anyhow, it's not necessary to use any libraries other than pub.Lua, but using either LuGI or brl.MaxLua can be handy in speeding up development. If you don't plan to pass BMax objects and such to Lua, then you probably don't need to use either of them.


mic_pringle(Posted 2009) [#8]
@Nillum

Thanks for making that a bit clearer and helping me understand.

I only plan on making a single 'entity' object available to Lua, and this will be passed as a parameter to predefined functions.

Other than that it will mainly be exposing engine functions to the Lua side, so they can be called from Lua scripts.

-Mic