Jump to content
  • Advertisement
Sign in to follow this  
BiiXteR

How to implement Lua scripting into my game?

This topic is 827 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was wondering how I would go about implementing Lua scripting into my game.

I did some googling and found out about LuaBridge, however it doesn't seem to be supported by it's developers anymore.

 

Is there any replacements with good documentation and maybe some tutorials?

Or maybe it's better writing my own? If yes, is there any tutorials on that? :)

 

All I need it to be able to do is : 

 

  • Call static functions from Lua script, and get their return value (if there is one)
  • Set static variables
  • Get static variables

 

Share this post


Link to post
Share on other sites
Advertisement
There are plenty of solutions. I had a look at both lua-intf and integral in the past and they seemed to offer a lot of convenience and ease of use. Note you might also want to look at less general and more domain-specific solutions for your scripting. That will almost certainly require some work of your own but you can squeeze out a few drops more of performance and support scripting semantics which will be more difficult with a general solution. You will also learn a lot of the nitty gritty details of interaction with Lua.

Share this post


Link to post
Share on other sites

I second that. I tried at first to use Luabridge but in the end I needed to tweak it so much to fit my needs that in the end I felt it was easier to use directly the LUA C API. I don't know about the other libraries but Luabridge makes use of a lot of template tricks to automatically map C++ members to LUA calls but it all feels very heavy. It is also difficult with that library to write methods that can accept arguments that can be one of several LUA types.

If you have the time, I'd recommend you to learn how to use the C API and make the binding yourself. In the long term you may need it anyway, even if you use a pre-existing binding library.

Share this post


Link to post
Share on other sites

LUA C API

twitch

members to LUA calls

twitch

several LUA types

twitch twitch

I'm sorry, but I have to get this out of my system.

Lua (/?lu??/ loo-?, from Portuguese: lua [?lu.(w)?] meaning moon; explicitly not "LUA" because it is not an acronym) is a lightweight multi-paradigm programming language.

Edited by BitMaster

Share this post


Link to post
Share on other sites

 

LUA C API

twitch

members to LUA calls

twitch

several LUA types

twitch twitch

I'm sorry, but I have to get this out of my system.

Lua (/?lu??/ loo-?, from Portuguese: lua [?lu.(w)?] meaning moon; explicitly not "LUA" because it is not an acronym) is a lightweight multi-paradigm programming language.

 

 

Sorry..? Will edit.

I also need to learn what "multi-paradigm" means. :3

 

*Edit :* 

Oh wait, I just realized who you were talking to haha :D

Edited by BiiXteR

Share this post


Link to post
Share on other sites

I second that. I tried at first to use Luabridge but in the end I needed to tweak it so much to fit my needs that in the end I felt it was easier to use directly the LUA C API. I don't know about the other libraries but Luabridge makes use of a lot of template tricks to automatically map C++ members to LUA calls but it all feels very heavy. It is also difficult with that library to write methods that can accept arguments that can be one of several LUA types.

If you have the time, I'd recommend you to learn how to use the C API and make the binding yourself. In the long term you may need it anyway, even if you use a pre-existing binding library.

 

 

I'm still quite new to C++ though, so it might just get even worse if I try to make one myself.

Should I use LuaBridge even if it's not supported by the devs? :D

Or do you recommend just using the LUA API anyways?

Edited by BiiXteR

Share this post


Link to post
Share on other sites

Basically you need some automating binging only if you already have lots of structs you want directly mapped to Lua.

But you're designing from scratch, then consider using plain Lua api.

It will make you plan interop more carefully, clearly separating stuff on either side (Lua vs native), avoiding unneeded copying/conversions.

It will allow to implement native function behavior in a way that is not directly available to C/C++ - when function semantic is flexible, depending on arguments combination.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!