Page 1 of 1

Why lua?

Posted: Fri Mar 26, 2010 12:20 am
by mattheweston
I know I could spend hours upon hours researching on the internet, but in doing that I feel I might just be scratching the surface and I thought this might be a good topic for discussion.

I have never used lua so, please forgive me if this seems like a stupid post. So tell me about lua.

How are you using it? What it everything you thought it would be? Are there other things you can envision it being used for that you haven't taken advantage of yet?

Re: Why lua?

Posted: Fri Mar 26, 2010 4:14 am
by LeonBlade
I'll most likely be using Lua myself, either that or Ruby.
It's used as a scripting engine for your game.
For example, NPCs would use Lua scripting and other things like that.

Re: Why lua?

Posted: Fri Mar 26, 2010 6:53 am
by Arce
Allrighty, I'm not quite sure what your question is asking...

Do you want to know "Why use a scripting language period?" or "Why use Lua as my scripting language as opposed to others?"

Or do you just think "Lua" is a person, and you're consulting him about the wonders of life? ("Why, Lua...? Why?") :mrgreen:

^ All of the above are legitimate points of discussion.

Re: Why lua?

Posted: Fri Mar 26, 2010 7:26 am
by mattheweston
It's a combination of your questions. Why use a scripting language and why use lua over say perl or some other scripting language.

Re: Why lua?

Posted: Fri Mar 26, 2010 10:08 am
by Falco Girgis
I'm not going to answer the question "why embed a scripting language into an engine." I have posted entire 2 page philosophies in response to this question and I'm sure you'll be able to find them by doing a forum search. It all boils down to extensibility.

I will, however, answer the question as to why we chose Lua in particular.

Lua is fast, lightweight, and was designed specifically to be an embedded scripting language. The entire interpreter compiles natively with ANSI C, and comes with its own full-fledged C API. Other scripting languages (Perl, Python, Ruby, etc) are full-blown standalone programming languages that are all waaay larger and way slower than Lua. While they can be embedded into C/++ applications, this wasn't their purpose (whereas Lua was designed for this) and take quite a bit of glue code to get C/++ communicating with them.

Re: Why lua?

Posted: Fri Mar 26, 2010 5:57 pm
by mattheweston
so riddle me this...does lua act like a "wrapper" around your code that allows you to call your code external to the application?

Re: Why lua?

Posted: Fri Mar 26, 2010 6:29 pm
by K-Bal
mattheweston wrote:so riddle me this...does lua act like a "wrapper" around your code that allows you to call your code external to the application?
You can call C/C++ functions from Lua and Lua functions from C/C++.