Who's Using LUA?

BlitzMax Forums/BlitzMax Programming/Who's Using LUA?

Gabriel(Posted 2006) [#1]
Sorry to be posting again about LUA, but a casual comment in the module tweaks forum is perhaps the wrong place to ask. There seem to be at least three public LUA modules and I've found at least another two people who are or were writing their own LUA modules.

I'm really struggling to work out which module(s) I should be using to use LUA in BlitzMax. I'm working on a large, complex game and I don't want to get caught out using the wrong module and suffer a huge waste of time rewriting tons of stuff later. I'm really looking for all kinds of information and advice from people who are seriously using LUA. Which module(s) are you using? Why? Is one easier? Is one more feature-packed? Is one more stable/reliable? Is one more bug-free?

There just doesn't seem to be much discussion of these modules compared to 2d and 3d engines, compression modules, and these sort of things, and that makes it impossible for me to judge the relative merits of each.


Sledge(Posted 2006) [#2]
Is there any particular reason why you can't just download the latest release from lua.org and get going? I thought Max could compile C.


Gabriel(Posted 2006) [#3]
Who's Using LUA?



Sledge(Posted 2006) [#4]

Who's Using LUA?


Well I am. But, y'know, on a community website where you yourself are asking for information it would be nice if you could answer a related query in a civil manner (even if it was simply "I don't know"). Either that or not at all, eh?


Gabriel(Posted 2006) [#5]
Well I am.

And you're doing it as you described? With just the c package and no BlitzMax code to interface with that at all?

Either that or not at all, eh?

That was not at all. Not only that, but it was my sixth attempt at a response and by far the most civil I could manage to a question which doesn't read very civil to me. Perhaps the fault is entirely with my reading of your question.


daaan(Posted 2006) [#6]
I'm using Lua. I like the lua module that you get from axe. It's really easy and quick to implement and change.


Gabriel(Posted 2006) [#7]
You mean Axe.Lua as opposed to Axe.LuaScript?


daaan(Posted 2006) [#8]
Yea, you can create your own interface for lua like Axe.LuaScript does. Then it fits your system to your own needs.


Gabriel(Posted 2006) [#9]
Yeah, I was thinking about doing that. I'm just not clear why the guy who wrote pub.lua felt the need to write his own module. Not sure what in axe.lua is missing or broken and whether I'll miss it. I guess it a number of people are happy with axe.lua that should be good enough. pub.lua doesn't seem to be in use by many other people so using that would be a bigger risk.


Blueapples(Posted 2006) [#10]
I am planning on using Lua for a utility that we are creating. Lua scripts will drive a library of functions written in BMax to help with client configuration.

I say "planning" because the core is ready but we're still not sure if we're going to use this solution.


Sledge(Posted 2006) [#11]

That was not at all. Not only that, but it was my sixth attempt at a response and by far the most civil I could manage to a question which doesn't read very civil to me. Perhaps the fault is entirely with my reading of your question.



Sorry if you found it curt - it was a short post precisely because I didn't want to blabber on when I wasn't about to answer your question.

I'm simply interested in why it needs to be a module. I use LUA in DevC++... I don't own Max but straightforward LUA integration might finally give me an excuse to buy it. What I really want to avoid, though, is the kind of "module limbo" you're experiencing; and I wasn't sure why, in a language that is supposed to compile C (right?) you need anything sitting between your code and the LUA library.


Gabriel(Posted 2006) [#12]
I haven't looked in too much detail at the inner workings of the LUA mode, but in general terms..

BlitzMax can compile C/C++ but it doesn't always ( often? ) have the necessary datatypes for you to interact with it directly. That is, it often has the datatypes, but they're not equivalent with their C++ counterparts. For example, structs with anything but the simplest datatypes cannot be interfaced directly from BMax. You end up writing a simple wrapper ( like my TrueVision wrapper ) where you have a BlitzMax Type which mimics the struct and a series of functions which pass the struct/class instance and then operate on it as you wish. To the person using the module, they don't see any difference. They still have a class with the same methods and fields, but you end up writing a lot of intermediate code in order to achieve that. Arrays are the same way, in C/C++ they're stored in a contiguous block of memory, but in BMax, they're not, it's just a block of pointers. So you end up having to fake it with one of a few different measures ( eg: "unfolding" them into separate variables if they're small arrays or writing a wrapper if they're not. )

Now in terms specifically of the LUA modules, as I say, I haven't looked at them, so I don't know specifically why a module is required. It won't be the classes, I guess, because I think I'm correct in saying that LUA is written in pure ansi C, but I assume it will be something like that, perhaps in terms of letting LUA call BlitzMax functions and access BlitzMax arrays. I'm sure Noel, Tommy and others wouldn't have written the module(s) if it wasn't/they weren't required, and it does often seem to be the case that you need some BlitzMax "glue" ( forgive the LUA pun ) to get BlitzMax and C to bond.


Sledge(Posted 2006) [#13]
Thanks for the info. Makes me hanker for a Max2D C library - would be handy to be able to link everything into C/C++ rather than faff around "glueing" C stuff about Max just to get at the juicy bits.

If you've got time to post on how you find the lua module you eventually opt for then I'd be interested to read it.


Tachyon(Posted 2006) [#14]
Does anyone have a link or two to some really good BMax+LUA samples? I've looked at LUA a bit as well but the samples I've seen lack substance and don't really show off LUA's capabilities.


Gabriel(Posted 2006) [#15]
I agree. Some substantial tutorials would be very useful.


Booticus(Posted 2006) [#16]
Yeah the stuff on the Wiki is a bit too advanced for me. I really am not sure what the heck is going on in it. :)


Gabriel(Posted 2006) [#17]
Exactly. I'm sure the stuff on the Wiki is great when you're past the basics, but something a bit more introductory and a bit more hand-holding would be great for those of us who are completely new to the subject.


SculptureOfSoul(Posted 2006) [#18]
Here's a link to the free online version of "Programming In Lua" (aka the PiL), written by the author of Lua itself.

If there is still some interest I might whip up some real basic tut's. Just the code that I'm playing around with to get a feel for Lua myself.


Gabriel(Posted 2006) [#19]
There's nothing clickable in your post, but I think I already have th free online book you refer to. It's good, but it's really the interfacing BMax with LUA stuff I could use help with.

And yes, I'd definitely like to see some real basic tut's.


SculptureOfSoul(Posted 2006) [#20]
Haha, whoops, totally forgot to include the link. Well, here it is for those who haven't had a chance to look at it yet.

http://www.lua.org/pil/index.html