Lua as a Data Format: Success

Published August 28, 2011
Advertisement
I haven't worked on anything in a while because a co-worker of one of my housemates lent me Demon's Souls. That's an addictive game.

I tore myself away from the PS3 this weekend just long enough to finish this latest little mini-project: using Lua as a data file format. Here's my minimal test file:


DRONMesh {
name = "Triangle",
verts = {
{ 0.0, 0.5, 0.5 },
{ 0.5, -0.5, 0.5 },
{ -0.5, -0.5, 0.5 }
},
tris = {
{ 0, 1, 2 }
}
}

I said it was pretty minimal ;)

Anyway, DRONMesh is a lua function that creates a new Mesh object, populates it with the data given in the table, and registers it with the resource manager. I need to expand it to handle materials, bones and whatnot, but I'm happy that I got it working. I haven't stress tested it in any way, but all the models in my game are fairly small (< 100 vertices), so I'm not too worried about long load times.
0 likes 1 comments

Comments

Jason Z
Cool. Can you go into more detail about what is being created in C++ and what is being created in Lua? How much are you doing in Lua that gets copied to C++, or on the other hand, how little do you do in Lua and just pass data to C++ functions?

The reason I ask is that I always have trouble determining the right mixture of one over the other - the flexibility of Lua is great, but at some point you need to use the C++ code you have already written :)
September 03, 2011 07:51 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement