Advertisement Jump to content
  • Advertisement
  • entries
  • comments
  • views

Lua's meets Hieroglyph

Sign in to follow this  
Jason Z


Lua meets Hieroglyph

I've been planning to start using Lua again for scripting in Hieroglyph 3 for quite some time. Initially I had planned to follow the same pattern as I had for Hieroglyph 2, which was basically to try to expose everthing in the script and have more or less every option available to me. The plan was to use SWIG to generate the wrappers, which would save an immense amount of time manually writing and debugging the script bindings. That was the original plan...

Since then, I've taken a "less is more" approach. After porting the scripting system and ensuring that it works at a basic level (Unicode and Lua don't get along too good...) I set out to implement my new design. Where I had nearly 30 script classes (and the corresponding 30 script bindings in the engine plus the 30 Lua glue files) I currently only have two - one for the 'App' class and one for an 'Actor' class. The Actor more or less is created by a single funtion in the App and gets added to a scene variable on the C++ side automatically. The geometry file and is specified by a string, and the material type is also specified by a string.

The grand total of two arguments to the create function will be all that is available for game entity types - all of the fancy material system configuration is now going to be done on the C++ side in the application. This allows for each application to provide specialized materials (with render views or whatever attached) for each Actor to use, but keeps the script extremely simple. Here is a basic application script, including the needed initialize, update, and shutdown functions:

dofile( "../Data/Scripts/Actor.lua" )

function Initialize()
handle = 0;
handle = App.CreateActor( "../Data/Models/box.ms3d", "Phong" );
actor = Actor:Create( handle );

App.Log( "Handle Value: " .. handle );

function Update( time )
App.Log( "Update Here" );

function Shutdown()
App.Log( "Shutdown Here" );

function OnKeyDown( char )
if char == 50 then -- '2' Key

With the return of scripting to the application, I also brought the Lua console window back into the library. The class that manages it needs some serious overhauling, but it is functional. In the following screenshot, I loaded the script from above and ran the 'SetPosition' command on my new actor to position where I wanted it:

This is really the most basic part of the scripting interface, with still much more to add and clean and test. However, it feels good to have Lua back in the game (so to speak...) and now I can modify scenes during runtime instead of always recompiling. Good times, good times... I pushed the latest copy of source code into the Hieroglyph 3 codeplex repository if you are interested in seeing how I use Lua. No guarantees, except that I actually ran the code above and got a cube to move [grin].
Sign in to follow this  


Recommended Comments

There are no comments to display.

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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!