Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Lua Usage in Games

Author
Message
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 13th Feb 2008 09:32
Hi,

I'm just wondering exactly what usage does Lua have in games?

I mean, I understand you can store variables in it and in tables etc, which has proved useful to me.
What I want to know is what other aspects of the language are useful in games, and possibly examples of where they would come in handy.

Cheers,
Bozzy

"I'm a firm believer that if a team scores one goal, then the other has to score two to win."
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 13th Feb 2008 10:10
As much or as little as you want, it's a scripting language so you can use lua to run your whole game, personally I find using lua just to store variables very wasteful as you could easily enough create your own config file to store variable names and their values.

Greenster
20
Years of Service
User Offline
Joined: 3rd Feb 2005
Location: US ©
Posted: 13th Feb 2008 12:05 Edited at: 13th Feb 2008 12:07
I made a thread regarding this, but with more technical questions regarding callbacks, print statements, and the security model with system wide file i/o etc..

It never got any responses.

It's very easy to put LUA in C++, and you can even define function sets to allow. Like my DLL only uses coroutine, table, string, and math functions from LUA with the addition of the core logic like IF. I also use a listener loop for my own I/O(ex:print "" and input var). I've never used the DX API in c++ to send strings ether. I use a native API function to send the string to the window as if it where keyboard input, and use meta data to dictate formatting.

Evidently the documation costs a fraction of the $20.
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 13th Feb 2008 12:12
Can I possibly have some examples of Lua usage in games?

Like how would functions work etc...


Cheers,
Bozzy

"I'm a firm believer that if a team scores one goal, then the other has to score two to win."
Wilf
Valued Member
19
Years of Service
User Offline
Joined: 1st Jun 2006
Location: Gone to Unity.
Posted: 13th Feb 2008 21:10
Hi Bozzy,

We used LUA in FarCry; each mission had a mission script that had a list of functions in it, e.g.:



which allowed us designers to set events and localized speech tokens without having to hit up a programmer.

Also, reloading changed scripts (rather than recompiling changed code) saves a lot of time when tweaking values - here's a segment from the Proximity Mine script:


All the scripts for FarCry are easily accessible in the FCData directory on the CD, none of them are compiled.
da power pwnerer
18
Years of Service
User Offline
Joined: 28th Jul 2006
Location: Pittsburgh, PA
Posted: 13th Feb 2008 22:09
Quote: "All the scripts for FarCry are easily accessible in the FCData directory on the CD, none of them are compiled."


Rize of tah h4x0rs!!

Just kidding, but really, never used Lua.



-Dan


http://Freewebs.com/noobisoft
Come to Noobisoft's website today!
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 13th Feb 2008 23:22
Thanks a lot Wilf. That really helped me understand how LUA could be used in games.

"I'm a firm believer that if a team scores one goal, then the other has to score two to win."
Bozzy
18
Years of Service
User Offline
Joined: 10th Sep 2006
Location: Birmingham, UK
Posted: 14th Feb 2008 19:13
I have it to call functions, but should I use Lua for my games variable storage:

player = {
Health = 110,
--...
}


Cheers,
Bozzy

"I'm a firm believer that if a team scores one goal, then the other has to score two to win."

Login to post a reply

Server time is: 2025-06-20 04:13:46
Your offset time is: 2025-06-20 04:13:46