Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075919 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:32:25 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Design mistakes in mixed C++/C and Lua projects
Pages: 1 [2]
Print
Author Topic: Design mistakes in mixed C++/C and Lua projects  (Read 2689 times)
Prinsessa
Level 10
*****


Ava Skoog


View Profile WWW Email
« Reply #20 on: November 03, 2011, 11:37:45 AM »

Perhaps in another thread, since this is about Lua? Wink Please make it, since both AngelScript, Falcon and Chai are scripting languages that should be discussed more!
Just wondering... but I would actually like to create a thread about it, to see how many are actually using it. I'll do that.
Logged

dum mak gam
Vatnsmyrkr, deep sea exploration: devlog
avaskoog @ twitter
avaskoog.se

Hima
Level 4
****


OM NOM NOM


View Profile WWW Email
« Reply #21 on: November 03, 2011, 08:28:33 PM »

- What I do to reference objects, is that objects inside the core engine are simply named; so if the Lua code tries to reference an object that doesn't exist on the C++ side of things, just print an error that it couldn't find "frog_prince_23". This helps with debugging a lot, much better than leaky pointers and/or segfaults because something was removed from the game engine.

This works great for games with few entities. In my case my game has over 100,000 entities, and looking them up by string would be excruciatingly slow. In cases where you have more than a handful of entities, you can use userdata for super fast access, and allow Lua to manage object lifetime with it's garbage collector.

Could you please write a tutorial on the subject  of userdata? I've embedded lua before but never seem to understand this thing so it's like an unfinished business Sad
Logged

eclectocrat
Level 5
*****


Most of your personality is unconscious.


View Profile
« Reply #22 on: November 03, 2011, 10:02:59 PM »

Hehe, I have a comprehensive Lua tutorial in the tutorials section right now. It covers userdata and metatables. It shows you how to export C++ classes to Lua in a way that makes it easy to use and extend them, plus use Lua garbage collection with C++ destructors.

BTW, mods, I demand to be levelled up, or for the tutorials section's description to be cleansed of empty promises. I've posted two tutorials and have yet to receive my accolades. [/tantrum]  Wink
Logged

I make Mysterious Castle, a Tactics-Roguelike
Hima
Level 4
****


OM NOM NOM


View Profile WWW Email
« Reply #23 on: November 03, 2011, 10:31:24 PM »

Hehe, I have a comprehensive Lua tutorial in the tutorials section right now. It covers userdata and metatables. It shows you how to export C++ classes to Lua in a way that makes it easy to use and extend them, plus use Lua garbage collection with C++ destructors.
Terrific! Thank you so much!  Gentleman
Logged

Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic