What's the use of Lua in SDL?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

What's the use of Lua in SDL?

Postby Enigma001 on Tue Jun 10, 2014 10:38 am

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:
Enigma001
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 1
Joined: Tue Jun 10, 2014 10:30 am

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

Postby dandymcgee on Tue Jun 10, 2014 1:55 pm

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.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
 
Posts: 4911
Joined: Tue Apr 29, 2008 4:24 pm
Location: New Hampshire

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

Postby superLED on Wed Jun 11, 2014 7:33 pm

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.
User avatar
superLED
Chaos Rift Junior
Chaos Rift Junior
 
Posts: 337
Joined: Sun Nov 21, 2010 12:56 pm
Location: Norway

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

Postby Dean Rivers on Sun Aug 03, 2014 12:03 am

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.
No trees were harmed in the posting of this message, although a large number of electrons were terribly inconvenienced.

"A genius is just a crazy person with an audience." - Tim Minchin

http://www.youtube.com/user/devlogstudios
User avatar
Dean Rivers
Chaos Rift Newbie
Chaos Rift Newbie
 
Posts: 7
Joined: Sat Aug 02, 2014 9:39 pm


Return to Programming Discussion

Who is online

Users browsing this forum: No registered users and 4 guests