Jump to content

Lua and C++


Benton
 Share

Recommended Posts

Hey guys,

 

I am making my project and I got a few questions,

 

The way it will work is a main script/c++ file that handles the game. So all the scenes, menus etc. Then objects and stuff have lua files. But should I use LUA or C++ for the main game script?

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

Yeah I guess, but then can I run lua functions through C++? Or the other way around? So if I need C++ to do something I can write up a function in C++ and call it through lua?

Windows 7 Professional 64 bit, 16 gigs ram, 3.30GHz Quad Core, GeForce GTX 460 one gig, Leadwerks 2.5, Blender 2.62, Photoshop CS3, UU3D

Link to comment
Share on other sites

http://www.leadwerks.com/files/Tutorials/Lua/Getting_Started_With_Lua.pdf

 

I do not think you can run commands that are lua commands directly, but overall C++ is much more documented for use. It has many libaries and ways to refine the programming to your need. I use C++ for main things, and I find that knowing C++ can help you use lua. It doesn't work the other way around. Both are equally important for making anything decent, with lua for making entities in the editor.

Win7 64bit, Leadwerks SDK 2.5, Visual Studio 2012, 3DWS, 3ds Max, Photoshop CS5.

 

 

 

Life is too short to remove USB safely.

Link to comment
Share on other sites

Lua will run C functions easily but not C++ as it doesn't know anything about the this pointer in order to reference the class objects. There are some libs out there that will wrap C++ for use with Lua so that's always an option but if your prepared to just provide a C interface between the two then that works pretty seamlessly. Lua is written in C after all.

 

As Aggror stated previously, having a good IDE at your disposal makes all the difference in any sizable development. The tools available for C++/C# are just so much better.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Since I love Lua in Leadwerks I would advice to start making your main loop with Lua.

 

Because of (I wrote it before here):

 

- It's simpler than C++;

- You don't need to compile anything or run any external IDE (you don't need any IDE at all);

- It works inside Leadwerks Editor (you can play around with it, you can play your game directly in Editor);

- You can edit LUA-script on fly and see result immediately;

- You can easily include or exclude any features (on fly).

 

 

And when you will see that Lua is not enough for you can rewrite your code to C++ or BlitzMax or whatever you want.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...