What do you think of Lua?

BlitzMax Forums/BlitzMax Programming/What do you think of Lua?

shinkiro1(Posted 2011) [#1]
Hello,

1) Are you using Lua in your game?

If yes:
2) How useful would you say it is? Could you live without it?
3) How much of your game is scripted? (only initialization and setup, game logic, etc. )

I'm nearly finished building my engine, and have not planned to include Lua from the beginning. But as I have seen, you have to wrap your functions anyway, so that should be no problem?


Gabriel(Posted 2011) [#2]
1) I used it in Star Sentinel Tactics, but not in anything I'm currently working on.

2) Vital. I couldn't live without it. I wanted to make all of the gameplay scriptable and I wanted to let people mod the game, and I couldn't do that without a fast, robust script engine. I could have done it with Python, I suppose, but I don't really like Python's syntax and in my experience, Lua is a lot faster too.

3) Everything. The GUI is completely scripted. The AI is all scripted. The gameplay is scripted.

I'm nearly finished building my engine, and have not planned to include Lua from the beginning. But as I have seen, you have to wrap your functions anyway, so that should be no problem?

I don't know that you *have* to wrap your functions, but I did, and I prefer that way. It shouldn't be a problem to do that, although it's a bit boring writing all those wrapper functions.


ima747(Posted 2011) [#3]
Any good references for how to get started writing and implementing lua?


slenkar(Posted 2011) [#4]
the object system is weird, its unlike any language ive heard of or used.
I never got a hang of the class system,

Its cool but the class system isnt simple


Kirkkaf(Posted 2011) [#5]
@ima747

A good place to start with Lua - Here

Free online ref book from Lua.

Hope this helps.


ima747(Posted 2011) [#6]
Thnx, will read up!


shinkiro1(Posted 2011) [#7]
Thanks a lot for the link and also the other answers.

It would also be great if someone could write a sort of tutorial how they implent lua in their game. Things like:
* Calling BMax Functions
* Working with BMax Objects
* Executing lua Script-Code
* ...


Kirkkaf(Posted 2011) [#8]
Not sure if this will help but you can try read up here http://lua-users.org/wiki/BlitzMax


Zeke(Posted 2011) [#9]
also check this link: http://www.blitzbasic.com/Community/posts.php?topic=85952

i also use this https://github.com/nilium/lugi.mod (look wiki pages)

Last edited 2011


Czar Flavius(Posted 2011) [#10]
Everything. The GUI is completely scripted. The AI is all scripted. The gameplay is scripted.
Could you elaborate on this? Which parts of gameplay are scripted and which are "hardcoded"? Eg if it's a squad based game, are the squad mechanics hardcoded? But perhaps some code to adjust their formation is scripted?

Thanks.

Last edited 2011


Gabriel(Posted 2011) [#11]
Could you elaborate on this? Which parts of gameplay are scripted and which are "hardcoded"?

The basic facets of gameplay are hardcoded in the engine. I mean you couldn't change it from being a turn-based squad game into being a third person shooter with scripts, because the turn-based nature and the controls are fixed. The next level is data, and that controls things like how many AP it costs to cross terrain, the diagonal movement modifiers, the behaviours of different weapons, characters, etc. Then what I call the "gameplay" is controlled entirely by Lua. So that would things like "What happens when my character opens this door?" "What happens when I kill all the bad guys?" "What happens when I enter this room?" "What happens if I shoot this barrel?" "If I activate this computer terminal, what happens?" All of that is controlled with script events. It's a simple event-based model so objects have an OnHit event for when they get attacked, an OnExplode method for when something explodes near them, and an OnUse method for when a character tries to use them. Within those functions they have access to quite a lot of data (eg: which character used them, where he's standing, what he's carrying, etc) so there's quite a scope for controlling things. There are also custom objects called triggers which are completely invisible but trigger an OnTrigger event when a character walks into them. Scripts have the power to open cutscenes, activate new enemies, destroy things, kill people, take objects from you, give objects to you, change characters AP or HP, or more abstract concepts which might only exist in a particular level.

Is that enough of an idea of what the scripts control?


shinkiro1(Posted 2011) [#12]
@Zeke: So one can use your mod with LuGI?
Thanks for the link (but I read that already ^^)

Just reading the documentation of LuGI and I already like it. It all sounds so simple. Anybody used it in a game and can tell about any issues (stability, cross-platform, etc.)?


Zeke(Posted 2011) [#13]
there is pub.lua and also brl.maxlua
and in MaxIDE:
bmax ide-> help-> Modules -> system -> Lua scripting

AND

bmaxide-> Other -> Lua Core

but i use lugi instead maxlua..

http://www.blitzbasic.com/Community/posts.php?topic=85902 <=Lugi topic

Last edited 2011


Czar Flavius(Posted 2011) [#14]
Yes, thank you. That's very helpful.


JoshK(Posted 2011) [#15]
Great language for game scripting, with a very poorly design implementation of OO. LuaBind for C++ and Lugi for BMX are both good. Don't use anything else.


Galaxy613(Posted 2011) [#16]
This thread made me take another look at adding Lua to my project. And I found this thread: http://www.blitzbasic.com/Community/posts.php?topic=85952

Go to post #10 after to get LuGI working and try it out. But then look at the code. I have concluded Lua is INSANE. It declare GLOBALS inside of the Init() function. And then proceeds to declare variables INSIDE of the Aliens and Player types. D: Is there any way to put it into strict mode so I don't accidentally screw myself over like I used to do in BlitzMax?

*Edit* It's also really hard to find help for a Lua "Stack Overflow" when there's a website with that exact name... I'm getting the error for a very simple Update loop function. :S Should I post my function problems here or post in a LuGI thread?

I can't believe LuGI also works with Extended types! This is awesome.

*EditEdit* It turns out if you have a global function in Lua called "Update", then it won't work when you try "CurrentSystem:Update" or even "playerShip:Update". So I renamed the global function "Game_Update" and it works fine, no Stack Overflow o.O Lua is a mysterious beast.

Last edited 2011