Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Almost checkout time.

Sign in to follow this  


I'm about to head home, I'll probably post something on-topic from there... basically have been doing more of the same, I keep meaning to go back to that UV bug, but I'm having fun with the other stuff I'm doing.

Why do I get all the stupid bugs?

** EDIT **
Look at the comments of this post for some LUA stuff =)
Sign in to follow this  


Recommended Comments

I was going to post in the other journal entry you had but oh well.

I got function calls from Lua to C working, but was just so perplexed by the amount of work required to get C++ classes into Lua that I just decided to drop it and continue on my Asteroids clone. I tried out Python and apparently it's really easy to bind in that. I still have to try out GameMonkey and Squirrel as well.

Any progress on your side of the factory? I'll upload the Lua class wrapper I made if you want it.

Share this comment

Link to comment
Well, yes and no... I was able to map C++ objects to LUA in the sense that in LUA you can write script like this:

local p = Vector3(1.1, 2.2, 9.3)
local y = Vector3(3.0, 3.1, 2.4)

local a = Vector3.add(y,p)

print("p: ", p:x(), p:y(), p:z())
print("y: ", y:x(), y:y(), y:z())
print("a: ", a:xyz())

What I was not able to do (even when I tried tolua) was map Vector3.add to C++'s:

Vector3 Vector3::Add(const Vector3& v)

instead, I ended up writing a more generic LUA library that looks like this:

class LUAVector3


static int Create(lua_State* L);

// Getters / Setters
static int x (lua_State *L);
static int y (lua_State *L);
static int z (lua_State *L);
static int xyz (lua_State *L);

// Operations
static int Add(lua_State* L);

// ....

int LUAVector3::Add(lua_State* L)
Vector3* v1 = CheckType(L, 1);
Vector3* v2 = CheckType(L, 2);
Vector3* sum = Push(L);
*sum = *v1 + *v2;
return 1;

which is really just a C++ shell of C style classes... not what I really wanted, but it works. So, not great, not too bad.

So, if all I wanted to do was write libraries of things for LUA to do, then I can. The part that I still haven't figured out how I'm going to do is map events to script, but it's likely that it will involve C style functions in one way or another.

I can also bundle up some of this code if you're interested in checking it out.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!