Page 1 of 1

What's the use of Lua in SDL?

Posted: Tue Jun 10, 2014 9:38 am
by Enigma001
Greetings,

I was wondering for what exactly Lua is used in the SDL world. I seen many Adventures in Game Development where they talked about the Lua implementation and how helpfull it was for the Project. But i never really understood for what Lua was really used for. Is it rather for Debugging purpose?

Well im thankfull for any Feedback from you guys.

PS: I love your videos and explanations and im ready to learn more from you guys including sensei Falco :worship:

Re: What's the use of Lua in SDL?

Posted: Tue Jun 10, 2014 12:55 pm
by dandymcgee
Lua is a general purpose scripting language which can be embedded in your application. Elysian Shadows uses Lua to expose the engine API to a dynamic scripting language. This allows for separation of game logic and engine logic as well as the ability to change much of the game logic (AI, pathfinding, UI, party system, quests, etc.) without recompiling the engine, or anything for that matter. One main benefit of not having to recompile is a drastic reduction in the amount of time it takes to test changes. With lua you simple edit the .lua script and reload it into the engine. In many cases, you don't even have to restart the application.

Re: What's the use of Lua in SDL?

Posted: Wed Jun 11, 2014 6:33 pm
by superLED
Simplified explanation:
When you run up your game, it reads a file on your computer and acts accordingly (example: you say that the player should start off with 100 HP).
Instead of having to change the C++ code and all that stuff, you can just open that file and edit "100 hp" with something else.

With LUA, you can do a whole lot: Get values from variables (get the player HP), set values from variables, run the engine's functions (methods), and a whole lot more.

LUA is a very simple scripting language (and can be very complex), and even non-programmers can script in LUA with ease.
If you are working in a group, you can let the artists use LUA to test out different things, like testing out your new map, and tweak around with the variables (like lighting brightness).

When your game is 100% done, you can either hardcode your LUA scripts to C++ language (for efficiency?), or ship the game with editable LUA files for the modders to enjoy.

Re: What's the use of Lua in SDL?

Posted: Sat Aug 02, 2014 11:03 pm
by Dean Rivers
Following up from the two previous answers, just think of LUA as a new layer of abstraction from the actual game engine code - the game engine as being the code which is run by the OS. All it does is give you a means of feeding in new inputs to the system without having to restructure the decided upon framework.

The low-level functionality which comprises the game engine infrastructure will be such things as graphics rendering subroutines, physics subroutines, and of course the subroutines which allow you to interface with LUA. Because of this whole new layer of abstraction, you will be able to call all sorts of high-level operations which would be very inefficient to call directly within the engine code. This could be things like "give 10 HP to player," etc.

The actual algorithm which decodes and perform this operation will be somewhere hard-coded in the engine, but the call to the operation itself will be in some external script file(s) which is continuously read by the engine. This is a very generalised explanation of the system as a whole. Remember that you can be flexible in the way you choose to implement/name these operations. Don't limit yourself by trying to implement everything word-for-word from somebody else's framework.