HGE mostly mound now and a partially working example scripting tip
authorHarley Laue <losinggeneration@gmail.com>
Wed, 24 Aug 2011 13:07:36 -0500
branchscripting
changeset 168 99e499f0cc69
parent 167 4ed45048e2f3
HGE mostly mound now and a partially working example

* With HGE mostly mound now, I've updated the example to do more
interesting things like initialize HGE (mostly at least), load the
resources (no idea if it's actually working the way I think it is),
and do what tutorial 2 does, but in Lua (or at least as much as I
can.)
include/hgeparticle.h
src/core/scripting/lua/CMakeLists.txt
src/core/scripting/lua/binding/hge.lua
src/core/scripting/lua/binding/hgeparticle.lua
src/core/scripting/lua/example/hge_init.lua
src/core/scripting/lua/example/hge_script.lua
src/core/scripting/lua/example/main.cpp
src/core/scripting/lua/luna-gen/luna_gen.lua
--- a/include/hgeparticle.h	Wed Aug 24 01:01:51 2011 -0500
+++ b/include/hgeparticle.h	Wed Aug 24 13:07:36 2011 -0500
@@ -90,13 +90,14 @@
 {
 public:
 	hgeParticleSystemInfo info;
-	
+
 	hgeParticleSystem(const char *filename, hgeSprite *sprite, float fps=0.0f);
 	hgeParticleSystem(hgeParticleSystemInfo *psi, float fps=0.0f);
 	hgeParticleSystem(const hgeParticleSystem &ps);
 	~hgeParticleSystem() { hge->Release(); }
 
-	hgeParticleSystem&	operator= (const hgeParticleSystem &ps);
+	/* Not actually implemented */
+// 	hgeParticleSystem&	operator= (const hgeParticleSystem &ps);
 
 
 	void				Render();
--- a/src/core/scripting/lua/CMakeLists.txt	Wed Aug 24 01:01:51 2011 -0500
+++ b/src/core/scripting/lua/CMakeLists.txt	Wed Aug 24 13:07:36 2011 -0500
@@ -40,7 +40,7 @@
 	cpp/lua_hgevector.h
 
 # Generated source files
-# 	cpp/lua_hge.cpp
+	cpp/lua_hge.cpp
 	cpp/lua_hgeanim.cpp
 	cpp/lua_hgecolor.cpp
 	cpp/lua_hgedistort.cpp
--- a/src/core/scripting/lua/binding/hge.lua	Wed Aug 24 01:01:51 2011 -0500
+++ b/src/core/scripting/lua/binding/hge.lua	Wed Aug 24 13:07:36 2011 -0500
@@ -7,13 +7,68 @@
 --
 
 array.pushBack(gen_lua.enum_types, 'hgeBoolState', 'hgeFuncState', 'hgeHwndState', 'hgeInputEvent', 'hgeIntState', 'hgeStringState')
-array.pushBack(gen_lua.number_types, 'HWND')
+array.pushBack(gen_lua.number_types, 'HTEXTURE', 'HTARGET', 'HEFFECT', 'HMUSIC', 'HSTREAM', 'HCHANNEL')
 
 bindhge = {
 	classes = {
 		{
-			name = 'hge',
-			className = 'HGE_Impl',
+			name = 'hge.Vertex',
+			className = 'hgeVertex',
+-- 			ctors = {
+-- 				'()',
+-- 			},
+			properties = {[[
+				float x;
+				float y;
+				float z;
+				DWORD col;
+				float tx;
+				float ty;
+			]]},
+		},
+		{
+			name = 'hge.Triple',
+			className = 'hgeTriple',
+-- 			ctors = {
+-- 				'()',
+-- 			},
+-- 			properties = {[[
+-- 				hgeVertex v[3];
+-- 				HTEXTURE tex;
+-- 				int blend;
+-- 			]]},
+		},
+		{
+			name = 'hge.Quad',
+			className = 'hgeQuad',
+-- 			ctors = {
+-- 				'()',
+-- 			},
+-- 			properties = {[[
+-- 				hgeVertex v[4];
+-- 				HTEXTURE tex;
+-- 				int blend;
+-- 			]]},
+		},
+		{
+			name = 'hge.InputEvent',
+			className = 'hgeInputEvent',
+-- 			ctors = {
+-- 				'()',
+-- 			},
+			properties = {[[
+				int type;
+				int key;
+				int flags;
+				int chr;
+				int wheel;
+				float x;
+				float y;
+			]]},
+		},
+		{
+			name = 'hge.abstract',
+			className = 'HGE',
 			memberFunctions = {
 				{ rename = 'release', 'void Release();' },
 
@@ -27,111 +82,119 @@
 
 				{ rename = 'system_set_bool_state', 'void System_SetState(hgeBoolState state, bool value);' },
 -- 				{ rename = 'system_set_func_state', 'void System_SetState(hgeFuncState state, hgeCallback value);' },
-				{ rename = 'system_set_hwnd_state', 'void System_SetState(hgeHwndState state, HWND value);' },
+-- 				{ rename = 'system_set_hwnd_state', 'void System_SetState(hgeHwndState state, HWND value);' },
 				{ rename = 'system_set_int_state', 'void System_SetState(hgeIntState state, int value);' },
 				{ rename = 'system_set_string_state', 'void System_SetState(hgeStringState state, const char *value);' },
 				{ rename = 'system_get_bool_state', 'bool System_GetState(hgeBoolState state);' },
 -- 				{ rename = 'system_get_func_state', 'hgeCallback System_GetState(hgeFuncState state);' },
-				{ rename = 'system_get_hwnd_state', 'HWND System_GetState(hgeHwndState state);' },
+-- 				{ rename = 'system_get_hwnd_state', 'HWND System_GetState(hgeHwndState state);' },
 				{ rename = 'system_get_int_state', 'int System_GetState(hgeIntState state);' },
 				{ rename = 'system_get_string_state', 'const char* System_GetState(hgeStringState state);' },
---
+
 -- 				{ rename = 'resource_load', 'void* Resource_Load(const char *filename, DWORD *size);' },
--- 				{ rename = 'resource_free', 'void Resource_Free(void *res);' },
--- 				{ rename = 'resource_attachpack', 'bool Resource_AttachPack(const char *filename, const char *password);' },
--- 				{ rename = 'resource_removepack', 'void Resource_RemovePack(const char *filename);' },
--- 				{ rename = 'resource_removeallpacks', 'void Resource_RemoveAllPacks();' },
--- 				{ rename = 'resource_makepath', 'char* Resource_MakePath(const char *filename);' },
--- 				{ rename = 'resource_enumfiles', 'char* Resource_EnumFiles(const char *wildcard);' },
--- 				{ rename = 'resource_enumfolders', 'char* Resource_EnumFolders(const char *wildcard);' },
---
--- 				{ rename = 'ini_setint', 'void Ini_SetInt(const char *section, const char *name, int value);' },
--- 				{ rename = 'ini_getint', 'int Ini_GetInt(const char *section, const char *name, int def_val);' },
--- 				{ rename = 'ini_setfloat', 'void Ini_SetFloat(const char *section, const char *name, float value);' },
--- 				{ rename = 'ini_getfloat', 'float Ini_GetFloat(const char *section, const char *name, float def_val);' },
--- 				{ rename = 'ini_setstring', 'void Ini_SetString(const char *section, const char *name, const char *value);' },
--- 				{ rename = 'ini_getstring', 'char* Ini_GetString(const char *section, const char *name, const char *def_val);' },
---
--- 				{ rename = 'random_seed', 'void Random_Seed(int seed);' },
--- 				{ rename = 'random_int', 'int Random_Int(int min, int max);' },
--- 				{ rename = 'random_float', 'float Random_Float(float min, float max);' },
---
--- 				{ rename = 'timer_gettime', 'float Timer_GetTime();' },
--- 				{ rename = 'timer_getdelta', 'float Timer_GetDelta();' },
--- 				{ rename = 'timer_getfps', 'int Timer_GetFPS();' },
---
--- 				{ rename = 'effect_load', 'HEFFECT Effect_Load(const char *filename, DWORD size);' },
--- 				{ rename = 'effect_free', 'void Effect_Free(HEFFECT eff);' },
--- 				{ rename = 'effect_play', 'HCHANNEL Effect_Play(HEFFECT eff);' },
--- 				{ rename = 'effect_playex', 'HCHANNEL Effect_PlayEx(HEFFECT eff, int volume, int pan, float pitch, bool loop);' },
---
--- 				{ rename = 'music_load', 'HMUSIC Music_Load(const char *filename, DWORD size);' },
--- 				{ rename = 'music_free', 'void Music_Free(HMUSIC mus);' },
--- 				{ rename = 'music_play', 'HCHANNEL Music_Play(HMUSIC mus, bool loop, int volume, int order, int row);' },
--- 				{ rename = 'music_setamplification', 'void Music_SetAmplification(HMUSIC music, int ampl);' },
--- 				{ rename = 'music_getamplification', 'int Music_GetAmplification(HMUSIC music);' },
--- 				{ rename = 'music_getlength', 'int Music_GetLength(HMUSIC music);' },
--- 				{ rename = 'music_setpos', 'void Music_SetPos(HMUSIC music, int order, int row);' },
+-- 				{ rename = 'resource_free', 'void Resource_Free(void * res);' },
+				{ rename = 'resource_attachpack', 'bool Resource_AttachPack(const char *filename, const char *password);' },
+				{ rename = 'resource_removepack', 'void Resource_RemovePack(const char *filename);' },
+				{ rename = 'resource_removeallpacks', 'void Resource_RemoveAllPacks();' },
+				{ rename = 'resource_makepath', 'char * Resource_MakePath(const char * filename);' },
+				{ rename = 'resource_enumfiles', 'char * Resource_EnumFiles(const char * wildcard);' },
+				{ rename = 'resource_enumfolders', 'char * Resource_EnumFolders(const char * wildcard);' },
+
+				{ rename = 'ini_setint', 'void Ini_SetInt(const char *section, const char *name, int value);' },
+				{ rename = 'ini_getint', 'int Ini_GetInt(const char *section, const char *name, int def_val);' },
+				{ rename = 'ini_setfloat', 'void Ini_SetFloat(const char *section, const char *name, float value);' },
+				{ rename = 'ini_getfloat', 'float Ini_GetFloat(const char *section, const char *name, float def_val);' },
+				{ rename = 'ini_setstring', 'void Ini_SetString(const char *section, const char *name, const char *value);' },
+				{ rename = 'ini_getstring', 'char * Ini_GetString(const char *section, const char *name, const char *def_val);' },
+
+				{ rename = 'random_seed', 'void Random_Seed(int seed);' },
+				{ rename = 'random_int', 'int Random_Int(int min, int max);' },
+				{ rename = 'random_float', 'float Random_Float(float min, float max);' },
+
+				{ rename = 'timer_gettime', 'float Timer_GetTime();' },
+				{ rename = 'timer_getdelta', 'float Timer_GetDelta();' },
+				{ rename = 'timer_getfps', 'int Timer_GetFPS();' },
+
+				{ rename = 'effect_load', 'HEFFECT Effect_Load(const char *filename, DWORD size);' },
+				{ rename = 'effect_free', 'void Effect_Free(HEFFECT eff);' },
+				{ rename = 'effect_play', 'HCHANNEL Effect_Play(HEFFECT eff);' },
+				{ rename = 'effect_playex', 'HCHANNEL Effect_PlayEx(HEFFECT eff, int volume, int pan, float pitch, bool loop);' },
+
+				{ rename = 'music_load', 'HMUSIC Music_Load(const char *filename, DWORD size);' },
+				{ rename = 'music_free', 'void Music_Free(HMUSIC mus);' },
+				{ rename = 'music_play', 'HCHANNEL Music_Play(HMUSIC mus, bool loop, int volume, int order, int row);' },
+				{ rename = 'music_setamplification', 'void Music_SetAmplification(HMUSIC music, int ampl);' },
+				{ rename = 'music_getamplification', 'int Music_GetAmplification(HMUSIC music);' },
+				{ rename = 'music_getlength', 'int Music_GetLength(HMUSIC music);' },
+				{ rename = 'music_setpos', 'void Music_SetPos(HMUSIC music, int order, int row);' },
 -- 				{ rename = 'music_getpos', 'bool Music_GetPos(HMUSIC music, int *order, int *row);' },
--- 				{ rename = 'music_setinstrvolume', 'void Music_SetInstrVolume(HMUSIC music, int instr, int volume);' },
--- 				{ rename = 'music_getinstrvolume', 'int Music_GetInstrVolume(HMUSIC music, int instr);' },
--- 				{ rename = 'music_setchannelvolume', 'void Music_SetChannelVolume(HMUSIC music, int channel, int volume);' },
--- 				{ rename = 'music_getchannelvolume', 'int Music_GetChannelVolume(HMUSIC music, int channel);' },
---
--- 				{ rename = 'stream_load', 'HSTREAM Stream_Load(const char *filename, DWORD size);' },
--- 				{ rename = 'stream_free', 'void Stream_Free(HSTREAM stream);' },
--- 				{ rename = 'stream_play', 'HCHANNEL Stream_Play(HSTREAM stream, bool loop, int volume);' },
---
--- 				{ rename = 'channel_setpanning', 'void Channel_SetPanning(HCHANNEL chn, int pan);' },
--- 				{ rename = 'channel_setvolume', 'void Channel_SetVolume(HCHANNEL chn, int volume);' },
--- 				{ rename = 'channel_setpitch', 'void Channel_SetPitch(HCHANNEL chn, float pitch);' },
--- 				{ rename = 'channel_pause', 'void Channel_Pause(HCHANNEL chn);' },
--- 				{ rename = 'channel_resume', 'void Channel_Resume(HCHANNEL chn);' },
--- 				{ rename = 'channel_stop', 'void Channel_Stop(HCHANNEL chn);' },
--- 				{ rename = 'channel_pauseall', 'void Channel_PauseAll();' },
--- 				{ rename = 'channel_resumeall', 'void Channel_ResumeAll();' },
--- 				{ rename = 'channel_stopall', 'void Channel_StopAll();' },
--- 				{ rename = 'channel_isplaying', 'bool Channel_IsPlaying(HCHANNEL chn);' },
--- 				{ rename = 'channel_getlength', 'float Channel_GetLength(HCHANNEL chn);' },
--- 				{ rename = 'channel_getpos', 'float Channel_GetPos(HCHANNEL chn);' },
--- 				{ rename = 'channel_setpos', 'void Channel_SetPos(HCHANNEL chn, float fSeconds);' },
--- 				{ rename = 'channel_slideto', 'void Channel_SlideTo(HCHANNEL channel, float time, int volume, int pan, float pitch);' },
--- 				{ rename = 'channel_issliding', 'bool Channel_IsSliding(HCHANNEL channel);' },
---
+				{ rename = 'music_setinstrvolume', 'void Music_SetInstrVolume(HMUSIC music, int instr, int volume);' },
+				{ rename = 'music_getinstrvolume', 'int Music_GetInstrVolume(HMUSIC music, int instr);' },
+				{ rename = 'music_setchannelvolume', 'void Music_SetChannelVolume(HMUSIC music, int channel, int volume);' },
+				{ rename = 'music_getchannelvolume', 'int Music_GetChannelVolume(HMUSIC music, int channel);' },
+
+				{ rename = 'stream_load', 'HSTREAM Stream_Load(const char *filename, DWORD size);' },
+				{ rename = 'stream_free', 'void Stream_Free(HSTREAM stream);' },
+				{ rename = 'stream_play', 'HCHANNEL Stream_Play(HSTREAM stream, bool loop, int volume);' },
+
+				{ rename = 'channel_setpanning', 'void Channel_SetPanning(HCHANNEL chn, int pan);' },
+				{ rename = 'channel_setvolume', 'void Channel_SetVolume(HCHANNEL chn, int volume);' },
+				{ rename = 'channel_setpitch', 'void Channel_SetPitch(HCHANNEL chn, float pitch);' },
+				{ rename = 'channel_pause', 'void Channel_Pause(HCHANNEL chn);' },
+				{ rename = 'channel_resume', 'void Channel_Resume(HCHANNEL chn);' },
+				{ rename = 'channel_stop', 'void Channel_Stop(HCHANNEL chn);' },
+				{ rename = 'channel_pauseall', 'void Channel_PauseAll();' },
+				{ rename = 'channel_resumeall', 'void Channel_ResumeAll();' },
+				{ rename = 'channel_stopall', 'void Channel_StopAll();' },
+				{ rename = 'channel_isplaying', 'bool Channel_IsPlaying(HCHANNEL chn);' },
+				{ rename = 'channel_getlength', 'float Channel_GetLength(HCHANNEL chn);' },
+				{ rename = 'channel_getpos', 'float Channel_GetPos(HCHANNEL chn);' },
+				{ rename = 'channel_setpos', 'void Channel_SetPos(HCHANNEL chn, float fSeconds);' },
+				{ rename = 'channel_slideto', 'void Channel_SlideTo(HCHANNEL channel, float time, int volume, int pan, float pitch);' },
+				{ rename = 'channel_issliding', 'bool Channel_IsSliding(HCHANNEL channel);' },
+
 -- 				{ rename = 'input_getmousepos', 'void Input_GetMousePos(float *x, float *y);' },
--- 				{ rename = 'input_setmousepos', 'void Input_SetMousePos(float x, float y);' },
--- 				{ rename = 'input_getmousewheel', 'int Input_GetMouseWheel();' },
--- 				{ rename = 'input_ismouseover', 'bool Input_IsMouseOver();' },
--- 				{ rename = 'input_keydown', 'bool Input_KeyDown(int key);' },
--- 				{ rename = 'input_keyup', 'bool Input_KeyUp(int key);' },
--- 				{ rename = 'input_getkeystate', 'bool Input_GetKeyState(int key);' },
--- 				{ rename = 'input_getkeyname', 'const char* Input_GetKeyName(int key);' },
--- 				{ rename = 'input_getkey', 'int Input_GetKey();' },
--- 				{ rename = 'input_getchar', 'int Input_GetChar();' },
--- 				{ rename = 'input_getevent', 'bool Input_GetEvent(hgeInputEvent *event);' },
---
--- 				{ rename = 'gfx_beginscene', 'bool Gfx_BeginScene(HTARGET target);' },
--- 				{ rename = 'gfx_endscene', 'void Gfx_EndScene();' },
--- 				{ rename = 'gfx_clear', 'void Gfx_Clear(DWORD color);' },
--- 				{ rename = 'gfx_renderline', 'void Gfx_RenderLine(float x1, float y1, float x2, float y2, DWORD color, float z);' },
--- 				{ rename = 'gfx_rendertriple', 'void Gfx_RenderTriple(const hgeTriple *triple);' },
--- 				{ rename = 'gfx_renderquad', 'void Gfx_RenderQuad(const hgeQuad *quad);' },
+				{ rename = 'input_setmousepos', 'void Input_SetMousePos(float x, float y);' },
+				{ rename = 'input_getmousewheel', 'int Input_GetMouseWheel();' },
+				{ rename = 'input_ismouseover', 'bool Input_IsMouseOver();' },
+				{ rename = 'input_keydown', 'bool Input_KeyDown(int key);' },
+				{ rename = 'input_keyup', 'bool Input_KeyUp(int key);' },
+				{ rename = 'input_getkeystate', 'bool Input_GetKeyState(int key);' },
+				{ rename = 'input_getkeyname', 'const char* Input_GetKeyName(int key);' },
+				{ rename = 'input_getkey', 'int Input_GetKey();' },
+				{ rename = 'input_getchar', 'int Input_GetChar();' },
+				{ rename = 'input_getevent', 'bool Input_GetEvent(hgeInputEvent *event);' },
+
+				{ rename = 'gfx_beginscene', 'bool Gfx_BeginScene(HTARGET target);' },
+				{ rename = 'gfx_endscene', 'void Gfx_EndScene();' },
+				{ rename = 'gfx_clear', 'void Gfx_Clear(DWORD color);' },
+				{ rename = 'gfx_renderline', 'void Gfx_RenderLine(float x1, float y1, float x2, float y2, DWORD color, float z);' },
+				{ rename = 'gfx_rendertriple', 'void Gfx_RenderTriple(const hgeTriple *triple);' },
+				{ rename = 'gfx_renderquad', 'void Gfx_RenderQuad(const hgeQuad *quad);' },
 -- 				{ rename = 'gfx_startbatch', 'hgeVertex* Gfx_StartBatch(int prim_type, HTEXTURE tex, int blend, int *max_prim);' },
--- 				{ rename = 'gfx_finishbatch', 'void Gfx_FinishBatch(int nprim);' },
--- 				{ rename = 'gfx_setclipping', 'void Gfx_SetClipping(int x, int y, int w, int h);' },
--- 				{ rename = 'gfx_settransform', 'void Gfx_SetTransform(float x, float y, float dx, float dy, float rot, float hscale, float vscale);' },
---
--- 				{ rename = 'target_create', 'HTARGET Target_Create(int width, int height, bool zbuffer);' },
--- 				{ rename = 'target_free', 'void Target_Free(HTARGET target);' },
--- 				{ rename = 'target_gettexture', 'HTEXTURE Target_GetTexture(HTARGET target);' },
---
--- 				{ rename = 'texture_create', 'HTEXTURE Texture_Create(int width, int height);' },
--- 				{ rename = 'texture_load', 'HTEXTURE Texture_Load(const char *filename, DWORD size, bool bMipmap);' },
--- 				{ rename = 'texture_free', 'void Texture_Free(HTEXTURE tex);' },
--- 				{ rename = 'texture_getwidth', 'int Texture_GetWidth(HTEXTURE tex, bool bOriginal);' },
--- 				{ rename = 'texture_getheight', 'int Texture_GetHeight(HTEXTURE tex, bool bOriginal);' },
--- 				{ rename = 'texture_lock', 'DWORD* Texture_Lock(HTEXTURE tex, bool bReadOnly, int left, int top, int width, int height);' },
--- 				{ rename = 'textureunlock', 'void Texture_Unlock(HTEXTURE tex);' },
+				{ rename = 'gfx_finishbatch', 'void Gfx_FinishBatch(int nprim);' },
+				{ rename = 'gfx_setclipping', 'void Gfx_SetClipping(int x, int y, int w, int h);' },
+				{ rename = 'gfx_settransform', 'void Gfx_SetTransform(float x, float y, float dx, float dy, float rot, float hscale, float vscale);' },
+
+				{ rename = 'target_create', 'HTARGET Target_Create(int width, int height, bool zbuffer);' },
+				{ rename = 'target_free', 'void Target_Free(HTARGET target);' },
+				{ rename = 'target_gettexture', 'HTEXTURE Target_GetTexture(HTARGET target);' },
+
+				{ rename = 'texture_create', 'HTEXTURE Texture_Create(int width, int height);' },
+				{ rename = 'texture_load', 'HTEXTURE Texture_Load(const char *filename, DWORD size, bool bMipmap);' },
+				{ rename = 'texture_free', 'void Texture_Free(HTEXTURE tex);' },
+				{ rename = 'texture_getwidth', 'int Texture_GetWidth(HTEXTURE tex, bool bOriginal);' },
+				{ rename = 'texture_getheight', 'int Texture_GetHeight(HTEXTURE tex, bool bOriginal);' },
+-- 				{ rename = 'texture_lock', 'DWORD * Texture_Lock(HTEXTURE tex, bool bReadOnly, int left, int top, int width, int height);' },
+				{ rename = 'textureunlock', 'void Texture_Unlock(HTEXTURE tex);' },
+			},
+		},
+		{
+			name = 'hge.HGE',
+			className = 'HGE_Impl',
+			inheritsFrom = 'HGE',
+			staticMemberFunctions = {
+				{ rename = 'create', 'HGE * hgeCreate(int ver);' },
 			},
 			enums = {
 				-- enum hgeBoolState
@@ -187,6 +250,133 @@
 				{ 'HGE_LOGFILE', '(int)HGE_LOGFILE' },
 
 				{ 'HGESTRINGSTATE_FORCE_DWORD', '(int)HGESTRINGSTATE_FORCE_DWORD' },
+
+				-- HGE Blending constants (defines)
+				{ 'BLEND_COLORADD', '(int)BLEND_COLORADD' },
+				{ 'BLEND_COLORMUL', '(int)BLEND_COLORMUL' },
+				{ 'BLEND_ALPHABLEND', '(int)BLEND_ALPHABLEND' },
+				{ 'BLEND_ALPHAADD', '(int)BLEND_ALPHAADD' },
+				{ 'BLEND_ZWRITE', '(int)BLEND_ZWRITE' },
+				{ 'BLEND_NOZWRITE', '(int)BLEND_NOZWRITE' },
+
+				{ 'BLEND_DEFAULT', '(int)BLEND_DEFAULT' },
+				{ 'BLEND_DEFAULT_Z', '(int)BLEND_DEFAULT_Z' },
+
+				-- defines for HGEK
+				{ 'HGEK_LBUTTON', '(int)HGEK_LBUTTON' },
+				{ 'HGEK_RBUTTON', '(int)HGEK_RBUTTON' },
+				{ 'HGEK_MBUTTON', '(int)HGEK_MBUTTON' },
+
+				{ 'HGEK_ESCAPE', '(int)HGEK_ESCAPE' },
+				{ 'HGEK_BACKSPACE', '(int)HGEK_BACKSPACE' },
+				{ 'HGEK_TAB', '(int)HGEK_TAB' },
+				{ 'HGEK_ENTER', '(int)HGEK_ENTER' },
+				{ 'HGEK_SPACE', '(int)HGEK_SPACE' },
+
+				{ 'HGEK_SHIFT', '(int)HGEK_SHIFT' },
+				{ 'HGEK_CTRL', '(int)HGEK_CTRL' },
+				{ 'HGEK_ALT', '(int)HGEK_ALT' },
+
+				{ 'HGEK_LWIN', '(int)HGEK_LWIN' },
+				{ 'HGEK_RWIN', '(int)HGEK_RWIN' },
+				{ 'HGEK_APPS', '(int)HGEK_APPS' },
+
+				{ 'HGEK_PAUSE', '(int)HGEK_PAUSE' },
+				{ 'HGEK_CAPSLOCK', '(int)HGEK_CAPSLOCK' },
+				{ 'HGEK_NUMLOCK', '(int)HGEK_NUMLOCK' },
+				{ 'HGEK_SCROLLLOCK', '(int)HGEK_SCROLLLOCK' },
+
+				{ 'HGEK_PGUP', '(int)HGEK_PGUP' },
+				{ 'HGEK_PGDN', '(int)HGEK_PGDN' },
+				{ 'HGEK_HOME', '(int)HGEK_HOME' },
+				{ 'HGEK_END', '(int)HGEK_END' },
+				{ 'HGEK_INSERT', '(int)HGEK_INSERT' },
+				{ 'HGEK_DELETE', '(int)HGEK_DELETE' },
+
+				{ 'HGEK_LEFT', '(int)HGEK_LEFT' },
+				{ 'HGEK_UP', '(int)HGEK_UP' },
+				{ 'HGEK_RIGHT', '(int)HGEK_RIGHT' },
+				{ 'HGEK_DOWN', '(int)HGEK_DOWN' },
+
+				{ 'HGEK_0', '(int)HGEK_0' },
+				{ 'HGEK_1', '(int)HGEK_1' },
+				{ 'HGEK_2', '(int)HGEK_2' },
+				{ 'HGEK_3', '(int)HGEK_3' },
+				{ 'HGEK_4', '(int)HGEK_4' },
+				{ 'HGEK_5', '(int)HGEK_5' },
+				{ 'HGEK_6', '(int)HGEK_6' },
+				{ 'HGEK_7', '(int)HGEK_7' },
+				{ 'HGEK_8', '(int)HGEK_8' },
+				{ 'HGEK_9', '(int)HGEK_9' },
+
+				{ 'HGEK_A', '(int)HGEK_A' },
+				{ 'HGEK_B', '(int)HGEK_B' },
+				{ 'HGEK_C', '(int)HGEK_C' },
+				{ 'HGEK_D', '(int)HGEK_D' },
+				{ 'HGEK_E', '(int)HGEK_E' },
+				{ 'HGEK_F', '(int)HGEK_F' },
+				{ 'HGEK_G', '(int)HGEK_G' },
+				{ 'HGEK_H', '(int)HGEK_H' },
+				{ 'HGEK_I', '(int)HGEK_I' },
+				{ 'HGEK_J', '(int)HGEK_J' },
+				{ 'HGEK_K', '(int)HGEK_K' },
+				{ 'HGEK_L', '(int)HGEK_L' },
+				{ 'HGEK_M', '(int)HGEK_M' },
+				{ 'HGEK_N', '(int)HGEK_N' },
+				{ 'HGEK_O', '(int)HGEK_O' },
+				{ 'HGEK_P', '(int)HGEK_P' },
+				{ 'HGEK_Q', '(int)HGEK_Q' },
+				{ 'HGEK_R', '(int)HGEK_R' },
+				{ 'HGEK_S', '(int)HGEK_S' },
+				{ 'HGEK_T', '(int)HGEK_T' },
+				{ 'HGEK_U', '(int)HGEK_U' },
+				{ 'HGEK_V', '(int)HGEK_V' },
+				{ 'HGEK_W', '(int)HGEK_W' },
+				{ 'HGEK_X', '(int)HGEK_X' },
+				{ 'HGEK_Y', '(int)HGEK_Y' },
+				{ 'HGEK_Z', '(int)HGEK_Z' },
+
+				{ 'HGEK_GRAVE', '(int)HGEK_GRAVE' },
+				{ 'HGEK_MINUS', '(int)HGEK_MINUS' },
+				{ 'HGEK_EQUALS', '(int)HGEK_EQUALS' },
+				{ 'HGEK_BACKSLASH', '(int)HGEK_BACKSLASH' },
+				{ 'HGEK_LBRACKET', '(int)HGEK_LBRACKET' },
+				{ 'HGEK_RBRACKET', '(int)HGEK_RBRACKET' },
+				{ 'HGEK_SEMICOLON', '(int)HGEK_SEMICOLON' },
+				{ 'HGEK_APOSTROPHE', '(int)HGEK_APOSTROPHE' },
+				{ 'HGEK_COMMA', '(int)HGEK_COMMA' },
+				{ 'HGEK_PERIOD', '(int)HGEK_PERIOD' },
+				{ 'HGEK_SLASH', '(int)HGEK_SLASH' },
+
+				{ 'HGEK_NUMPAD0', '(int)HGEK_NUMPAD0' },
+				{ 'HGEK_NUMPAD1', '(int)HGEK_NUMPAD1' },
+				{ 'HGEK_NUMPAD2', '(int)HGEK_NUMPAD2' },
+				{ 'HGEK_NUMPAD3', '(int)HGEK_NUMPAD3' },
+				{ 'HGEK_NUMPAD4', '(int)HGEK_NUMPAD4' },
+				{ 'HGEK_NUMPAD5', '(int)HGEK_NUMPAD5' },
+				{ 'HGEK_NUMPAD6', '(int)HGEK_NUMPAD6' },
+				{ 'HGEK_NUMPAD7', '(int)HGEK_NUMPAD7' },
+				{ 'HGEK_NUMPAD8', '(int)HGEK_NUMPAD8' },
+				{ 'HGEK_NUMPAD9', '(int)HGEK_NUMPAD9' },
+
+				{ 'HGEK_MULTIPLY', '(int)HGEK_MULTIPLY' },
+				{ 'HGEK_DIVIDE', '(int)HGEK_DIVIDE' },
+				{ 'HGEK_ADD', '(int)HGEK_ADD' },
+				{ 'HGEK_SUBTRACT', '(int)HGEK_SUBTRACT' },
+				{ 'HGEK_DECIMAL', '(int)HGEK_DECIMAL' },
+
+				{ 'HGEK_F1', '(int)HGEK_F1' },
+				{ 'HGEK_F2', '(int)HGEK_F2' },
+				{ 'HGEK_F3', '(int)HGEK_F3' },
+				{ 'HGEK_F4', '(int)HGEK_F4' },
+				{ 'HGEK_F5', '(int)HGEK_F5' },
+				{ 'HGEK_F6', '(int)HGEK_F6' },
+				{ 'HGEK_F7', '(int)HGEK_F7' },
+				{ 'HGEK_F8', '(int)HGEK_F8' },
+				{ 'HGEK_F9', '(int)HGEK_F9' },
+				{ 'HGEK_F10', '(int)HGEK_F10' },
+				{ 'HGEK_F11', '(int)HGEK_F11' },
+				{ 'HGEK_F12', '(int)HGEK_F12' },
 			},
 		},
 	},
@@ -216,7 +406,6 @@
 #define M_2_PI	0.636619772367581343076f
 #endif
 
-
 /*
 ** Hardware color macros
 */
@@ -230,43 +419,23 @@
 #define SETG(col,g)		(((col) & 0xFFFF00FF) + (DWORD(g)<<8))
 #define SETB(col,b)		(((col) & 0xFFFFFF00) + DWORD(b))
 
-
-/*
-** HGE Blending constants
-*/
-#define	BLEND_COLORADD		1
-#define	BLEND_COLORMUL		0
-#define	BLEND_ALPHABLEND	2
-#define	BLEND_ALPHAADD		0
-#define	BLEND_ZWRITE		4
-#define	BLEND_NOZWRITE		0
-
-#define BLEND_DEFAULT		(BLEND_COLORMUL | BLEND_ALPHABLEND | BLEND_NOZWRITE)
-#define BLEND_DEFAULT_Z		(BLEND_COLORMUL | BLEND_ALPHABLEND | BLEND_ZWRITE)
-
-
-
-
 /*
 ** Callback protoype used by HGE
 */
 typedef bool (*hgeCallback)();
 
-
 /*
 ** HGE_FPS system state special constants
 */
 #define HGEFPS_UNLIMITED	0
 #define HGEFPS_VSYNC		-1
 
-
 /*
 ** HGE_POWERSTATUS system state special constants
 */
 #define HGEPWR_AC			-1
 #define HGEPWR_UNSUPPORTED	-2
 
-
 /*
 ** HGE Primitive type constants
 */
@@ -274,56 +443,6 @@
 #define HGEPRIM_TRIPLES		3
 #define HGEPRIM_QUADS		4
 
-
-/*
-** HGE Vertex structure
-*/
-struct hgeVertex
-{
-	float			x, y;		// screen position
-	float			z;			// Z-buffer depth 0..1
-	DWORD			col;		// color
-	float			tx, ty;		// texture coordinates
-};
-
-
-/*
-** HGE Triple structure
-*/
-struct hgeTriple
-{
-	hgeVertex		v[3];
-	HTEXTURE		tex;
-	int				blend;
-};
-
-
-/*
-** HGE Quad structure
-*/
-struct hgeQuad
-{
-	hgeVertex		v[4];
-	HTEXTURE		tex;
-	int				blend;
-};
-
-
-/*
-** HGE Input Event structure
-*/
-struct hgeInputEvent
-{
-	int		type;			// event type
-	int		key;			// key code
-	int		flags;			// event flags
-	int		chr;			// character code
-	int		wheel;			// wheel shift
-	float	x;				// mouse cursor x-coordinate
-	float	y;				// mouse cursor y-coordinate
-};
-
-
 /*
 ** HGE Input Event type constants
 */
@@ -334,7 +453,6 @@
 #define INPUT_MOUSEMOVE		5
 #define INPUT_MOUSEWHEEL	6
 
-
 /*
 ** HGE Input Event flags
 */
@@ -346,126 +464,6 @@
 #define HGEINP_NUMLOCK		32
 #define HGEINP_REPEAT		64
 
-
 extern "C" { EXPORT HGE * CALL hgeCreate(int ver); }
 
-
-/*
-** HGE Virtual-key codes
-*/
-#define HGEK_LBUTTON	0x01
-#define HGEK_RBUTTON	0x02
-#define HGEK_MBUTTON	0x04
-
-#define HGEK_ESCAPE		0x1B
-#define HGEK_BACKSPACE	0x08
-#define HGEK_TAB		0x09
-#define HGEK_ENTER		0x0D
-#define HGEK_SPACE		0x20
-
-#define HGEK_SHIFT		0x10
-#define HGEK_CTRL		0x11
-#define HGEK_ALT		0x12
-
-#define HGEK_LWIN		0x5B
-#define HGEK_RWIN		0x5C
-#define HGEK_APPS		0x5D
-
-#define HGEK_PAUSE		0x13
-#define HGEK_CAPSLOCK	0x14
-#define HGEK_NUMLOCK	0x90
-#define HGEK_SCROLLLOCK	0x91
-
-#define HGEK_PGUP		0x21
-#define HGEK_PGDN		0x22
-#define HGEK_HOME		0x24
-#define HGEK_END		0x23
-#define HGEK_INSERT		0x2D
-#define HGEK_DELETE		0x2E
-
-#define HGEK_LEFT		0x25
-#define HGEK_UP			0x26
-#define HGEK_RIGHT		0x27
-#define HGEK_DOWN		0x28
-
-#define HGEK_0			0x30
-#define HGEK_1			0x31
-#define HGEK_2			0x32
-#define HGEK_3			0x33
-#define HGEK_4			0x34
-#define HGEK_5			0x35
-#define HGEK_6			0x36
-#define HGEK_7			0x37
-#define HGEK_8			0x38
-#define HGEK_9			0x39
-
-#define HGEK_A			0x41
-#define HGEK_B			0x42
-#define HGEK_C			0x43
-#define HGEK_D			0x44
-#define HGEK_E			0x45
-#define HGEK_F			0x46
-#define HGEK_G			0x47
-#define HGEK_H			0x48
-#define HGEK_I			0x49
-#define HGEK_J			0x4A
-#define HGEK_K			0x4B
-#define HGEK_L			0x4C
-#define HGEK_M			0x4D
-#define HGEK_N			0x4E
-#define HGEK_O			0x4F
-#define HGEK_P			0x50
-#define HGEK_Q			0x51
-#define HGEK_R			0x52
-#define HGEK_S			0x53
-#define HGEK_T			0x54
-#define HGEK_U			0x55
-#define HGEK_V			0x56
-#define HGEK_W			0x57
-#define HGEK_X			0x58
-#define HGEK_Y			0x59
-#define HGEK_Z			0x5A
-
-#define HGEK_GRAVE		0xC0
-#define HGEK_MINUS		0xBD
-#define HGEK_EQUALS		0xBB
-#define HGEK_BACKSLASH	0xDC
-#define HGEK_LBRACKET	0xDB
-#define HGEK_RBRACKET	0xDD
-#define HGEK_SEMICOLON	0xBA
-#define HGEK_APOSTROPHE	0xDE
-#define HGEK_COMMA		0xBC
-#define HGEK_PERIOD		0xBE
-#define HGEK_SLASH		0xBF
-
-#define HGEK_NUMPAD0	0x60
-#define HGEK_NUMPAD1	0x61
-#define HGEK_NUMPAD2	0x62
-#define HGEK_NUMPAD3	0x63
-#define HGEK_NUMPAD4	0x64
-#define HGEK_NUMPAD5	0x65
-#define HGEK_NUMPAD6	0x66
-#define HGEK_NUMPAD7	0x67
-#define HGEK_NUMPAD8	0x68
-#define HGEK_NUMPAD9	0x69
-
-#define HGEK_MULTIPLY	0x6A
-#define HGEK_DIVIDE		0x6F
-#define HGEK_ADD		0x6B
-#define HGEK_SUBTRACT	0x6D
-#define HGEK_DECIMAL	0x6E
-
-#define HGEK_F1			0x70
-#define HGEK_F2			0x71
-#define HGEK_F3			0x72
-#define HGEK_F4			0x73
-#define HGEK_F5			0x74
-#define HGEK_F6			0x75
-#define HGEK_F7			0x76
-#define HGEK_F8			0x77
-#define HGEK_F9			0x78
-#define HGEK_F10		0x79
-#define HGEK_F11		0x7A
-#define HGEK_F12		0x7B
-
 --]]
--- a/src/core/scripting/lua/binding/hgeparticle.lua	Wed Aug 24 01:01:51 2011 -0500
+++ b/src/core/scripting/lua/binding/hgeparticle.lua	Wed Aug 24 13:07:36 2011 -0500
@@ -97,7 +97,8 @@
 				'(const hgeParticleSystem &ps);',
 			},
 			memberFunctions =  {
-				{ 'hgeParticleSystem& operator= (const hgeParticleSystem &ps);' },
+				-- in header, but wasn't implemented
+-- 				{ 'hgeParticleSystem& operator= (const hgeParticleSystem &ps);' },
 
 				{ 'void Render();' },
 				{ 'void FireAt(float x, float y);' },
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/scripting/lua/example/hge_init.lua	Wed Aug 24 13:07:36 2011 -0500
@@ -0,0 +1,18 @@
+-- Just the basic hge initialization
+HGE = hge.HGE
+lhge = HGE.create(0x181) -- hard coded for now, it should be based off the define HGE_VERSION
+
+if lhge then
+	-- Setup log file and window title
+	lhge:system_set_string_state(HGE.HGE_LOGFILE, 'lua_scripting_example.log')
+	lhge:system_set_string_state(HGE.HGE_TITLE, 'HGE Scripting Example (like tutorial 2)');
+
+	-- Setup video mode
+	lhge:system_set_bool_state(HGE.HGE_WINDOWED, true);
+	lhge:system_set_bool_state(HGE.HGE_USESOUND, true);
+	lhge:system_set_int_state(HGE.HGE_SCREENWIDTH, 800);
+	lhge:system_set_int_state(HGE.HGE_SCREENHEIGHT, 600);
+	lhge:system_set_int_state(HGE.HGE_SCREENBPP, 32);
+else
+	print("Unable to initialize HGE")
+end
--- a/src/core/scripting/lua/example/hge_script.lua	Wed Aug 24 01:01:51 2011 -0500
+++ b/src/core/scripting/lua/example/hge_script.lua	Wed Aug 24 13:07:36 2011 -0500
@@ -17,6 +17,8 @@
 	print("-------------------------------------")
 end
 
+print('Doing some basic tests')
+
 v = hge.Vector()
 v1 = hge.Vector(2.2, 3.3)
 print_vector(v)
@@ -68,3 +70,214 @@
 test_bound(false, r2:intersect(r3))
 
 print_separator()
+
+print("Tests finished, loading HGE")
+
+print_separator()
+
+function pairsByKeys (t, f)
+   local a = {}
+   for n in pairs(t) do table.insert(a, n) end
+   if f==nil then
+	   f=function (a,b) -- default key comparison function
+		   if type(a)==type(b) then
+			   return a<b
+		   end
+		   return type(a)<type(b)
+	   end
+   end
+   table.sort(a, f)
+   local i = 0      -- iterator variable
+   local iter = function ()   -- iterator function
+		   i = i + 1
+		   if a[i] == nil then return nil
+		   else return a[i], t[a[i]]
+		   end
+		end
+   return iter
+end
+
+function printTable(t, bPrintUserData)
+	local out="{"
+	for k,v in pairsByKeys(t) do
+		local tv=type(v)
+		if tv=="string" or tv=="number" or tv=="boolean" then
+			out=out..'['..k..']='..tostring(v)..', '
+		elseif tv=="userdata" then
+			if bPrintUserData==true then
+				out=out..'\n['..k..']=\n'..v..', '
+			else
+				out=out..'['..k..']='..tv..', '
+			end
+		else
+			out=out..'['..k..']='..tv..', '
+		end
+	end
+	print(out..'}')
+end
+
+-- print(hge.Vertex.new():x)
+-- os.exit()
+
+-- Quad is the basic primitive in HGE
+-- used for rendering graphics.
+-- Quad contains 4 vertices, numbered
+-- 0 to 3 clockwise.
+quad = {
+-- 	v = hge.Vertex.new()[4],
+	tex = 0,
+	blend = 0,
+}
+
+-- Handle for a sound effect
+snd = HGE.HEFFECT
+
+-- Some "gameplay" variables and constants
+x = 100.0
+y = 100.0
+dx = 0.0
+dy = 0.0
+
+speed = 90
+friction = 0.98
+
+-- This function plays collision sound with
+-- parameters based on sprite position and speed
+function boom()
+	local pan= tonumber((x - 400) / 4, 10)
+	local pitch= (dx * dx + dy * dy) * 0.0005 + 0.2
+	lhge:effect_playex(snd, 100, pan, pitch)
+end
+
+function FrameFunc()
+	-- Get the time elapsed since last call of FrameFunc().
+	-- This will help us to synchronize on different
+	-- machines and video modes.
+	local dt = lhge:timer_getdelta();
+
+	-- Process keys
+	if lhge:input_getkeystate(HGE.HGEK_ESCAPE) then
+		return true
+	end
+	if lhge:input_getkeystate(HGE.HGEK_LEFT) then
+		dx = dx - speed * dt
+	end
+	if lhge:input_getkeystate(HGE.HGEK_RIGHT) then
+		dx = dx + speed * dt
+	end
+	if lhge:input_getkeystate(HGE.HGEK_UP) then
+		dy = dy - speed * dt
+	end
+	if lhge:input_getkeystate(HGE.HGEK_DOWN) then
+		dy = dy + speed * dt
+	end
+
+	-- Do some movement calculations and collision detection
+	dx = dx * friction
+	dy = dy * friction
+	x = x + dx
+	y = y + dy
+
+	if x > 784 then
+		x = 784 - (x - 784)
+		dx = -dx
+		boom()
+	end
+	if x < 16 then
+		x = 16 + 16 - x
+		dx = -dx
+		boom()
+	end
+	if y > 584 then
+		y = 584 - (y - 584)
+		dy = -dy;
+		boom();
+	end
+	if y < 16 then
+		y = 16 + 16 - y;
+		dy = -dy
+		boom()
+	end
+
+	-- Set up quad's screen coordinates
+-- 	quad.v[0].x = x - 16; quad.v[0].y = y - 16
+-- 	quad.v[1].x = x + 16; quad.v[1].y = y - 16;
+-- 	quad.v[2].x = x + 16; quad.v[2].y = y + 16;
+-- 	quad.v[3].x = x - 16; quad.v[3].y = y + 16;
+
+	-- Continue execution
+	return false
+end
+
+function RenderFunc()
+	-- Begin rendering quads.
+	-- This function must be called
+	-- before any actual rendering.
+	lhge:gfx_beginscene(0)
+
+	-- Clear screen with black color
+	lhge:gfx_clear(0)
+
+	-- Render quads here. This time just
+	-- one of them will serve our needs.
+-- 	lhge:gfx_renderquad(quad)
+
+	-- End rendering and update the screen
+	lhge:gfx_endscene()
+
+	-- RenderFunc should always return false
+	return false
+end
+
+if lhge:system_initiate() then
+	require('bit')
+
+	-- Load sound and texture
+	snd = lhge:effect_load("menu.ogg", 0);
+
+	-- for windows
+-- 	snd = lhge:effect_load("menu.wav");
+
+	quad.tex = lhge:texture_load("particles.png", 0, false);
+
+	if snd == 0 or quad.tex == 0 then
+		-- If one of the data files is not found, display
+		-- an error message and shutdown.
+		print("Error: Can't load menu.wav or particles.png");
+
+		lhge:system_shutdown();
+		lhge:release();
+		return 1;
+	end
+
+	-- Set up quad which we will use for rendering sprite
+	quad.blend = bit.bor(bit.bor(HGE.BLEND_ALPHAADD, HGE.BLEND_COLORMUL), HGE.BLEND_ZWRITE);
+
+-- 	for(int i=0;i<4;i++)
+-- 	{
+-- 		-- Set up z-coordinate of vertices
+-- 		quad.v[i].z=0.5f;
+-- 		-- Set up color. The format of DWORD col is 0xAARRGGBB
+-- 		quad.v[i].col=0xFFFFA000;
+-- 	}
+--
+-- 	-- Set up quad's texture coordinates.
+-- 	-- 0,0 means top left corner and 1,1 -
+-- 	-- bottom right corner of the texture.
+-- 	quad.v[0].tx=96.0/128.0; quad.v[0].ty=64.0/128.0;
+-- 	quad.v[1].tx=128.0/128.0; quad.v[1].ty=64.0/128.0;
+-- 	quad.v[2].tx=128.0/128.0; quad.v[2].ty=96.0/128.0;
+-- 	quad.v[3].tx=96.0/128.0; quad.v[3].ty=96.0/128.0;
+
+	lhge:system_start()
+
+	-- Free loaded texture and sound
+	lhge:texture_free(quad.tex);
+	lhge:effect_free(snd);
+else
+	fprintf(stderr, "Unable to initialize HGE: %s\n", lhge:system_geterrormessage())
+end
+
+-- Finish up hge
+lhge:system_shutdown();
+lhge:release();
\ No newline at end of file
--- a/src/core/scripting/lua/example/main.cpp	Wed Aug 24 01:01:51 2011 -0500
+++ b/src/core/scripting/lua/example/main.cpp	Wed Aug 24 13:07:36 2011 -0500
@@ -4,49 +4,82 @@
 #include "lua.hpp"
 
 HGE *hge = 0;
+// Needed for the callbacks
+lua_State *global_state;
 
 void bind_to_lua(lua_State *L) {
+	void bind_lua_hgeAnim(lua_State *L);
+	void bind_lua_hgeColor(lua_State *L);
+	void bind_lua_hgeDistort(lua_State *L);
+	void bind_lua_hgeFont(lua_State *L);
+	void bind_lua_hgeSprite(lua_State *L);
 	void bind_lua_hgeRect(lua_State *L);
 	void bind_lua_hgeStrings(lua_State *L);
 	void bind_lua_hgeVector(lua_State *L);
+	void bind_lua_hgeParticle(lua_State *L);
+	void bind_lua_hgeGui(lua_State *L);
+	void bind_lua_hgeGuiCtrls(lua_State *L);
+	void bind_lua_hgeResource(lua_State *L);
+	void bind_lua_hge(lua_State *L);
 
+	bind_lua_hgeAnim(L);
+	bind_lua_hgeColor(L);
+	bind_lua_hgeDistort(L);
+	bind_lua_hgeFont(L);
+	bind_lua_hgeSprite(L);
 	bind_lua_hgeRect(L);
 	bind_lua_hgeStrings(L);
 	bind_lua_hgeVector(L);
+	bind_lua_hgeParticle(L);
+// 	bind_lua_hgeGui(L);
+	bind_lua_hgeGuiCtrls(L);
+// 	bind_lua_hgeResource(L);
+	bind_lua_hge(L);
 }
 
-bool FrameFunction() {
-	if(hge->Input_GetKeyState(HGEK_ESCAPE))
-		return true;
+bool callLuaFunction(const char *f) {
+	lua_getfield(global_state, LUA_GLOBALSINDEX, f);
+	lua_call(global_state, 0, 1);
+	bool rv = lua_toboolean(global_state, -1);
+	lua_pop(global_state, 1);
+	return rv;
+}
+
+bool FrameFunc() {
+	callLuaFunction("FrameFunc");
 
 	return  false;
 }
 
+bool RenderFunc() {
+	callLuaFunction("RenderFunc");
+
+	return false;
+}
+
 int main(int argc, char *argv[]) {
-	lua_State *L = luaL_newstate();
-	hge = hgeCreate(HGE_VERSION);
-
-	hge->System_SetState(HGE_FRAMEFUNC, FrameFunction);
-	hge->System_SetState(HGE_TITLE, "HGE Scripting Example");
-	hge->System_SetState(HGE_WINDOWED, true);
-	hge->System_SetState(HGE_USESOUND, true);
+	lua_State *L = global_state = luaL_newstate();
 
 	luaL_openlibs(L);
 	bind_to_lua(L);
 
-	if(luaL_dofile(L, "hge_script.lua")) {
+	if(luaL_dofile(L, "hge_init.lua")) {
 		fprintf(stderr, "%s\n", lua_tolstring(L, 1, NULL));
 	}
 
-	if(hge->System_Initiate()) {
-		hge->System_Start();
-	}
-	else {
-		fprintf(stderr, "Unable to initialize HGE: %s\n", hge->System_GetErrorMessage());
+	// get the instance of hge
+	hge = hgeCreate(HGE_VERSION);
+	if(hge) {
+		// Still have to do the frame function in C/C++
+		hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
+		hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
+
+		if(luaL_dofile(L, "hge_script.lua")) {
+			fprintf(stderr, "%s\n", lua_tolstring(L, 1, NULL));
+		}
 	}
 
 	lua_close(L);
-	hge->System_Shutdown();
-	hge->Release();
+
 	return 0;
 }
\ No newline at end of file
--- a/src/core/scripting/lua/luna-gen/luna_gen.lua	Wed Aug 24 01:01:51 2011 -0500
+++ b/src/core/scripting/lua/luna-gen/luna_gen.lua	Wed Aug 24 13:07:36 2011 -0500
@@ -10,8 +10,8 @@
 	gen_lua.number_types={'int', 'double', 'float'}
 	gen_lua.enum_types={}
 	gen_lua.boolean_types={'bool'}
-	gen_lua.string_types={'const%s+char%s*%*', 'std%s*::%s*string', 'TString'} -- string types has to support static conversion  to const char*, and construction from const char*.
-	gen_lua.string_to_cstr={'@'              , '@.c_str()',         '@.ptr()'}
+	gen_lua.string_types={'const%s+char%s*%*', 'char%s+*', 'std%s*::%s*string', 'TString'} -- string types has to support static conversion  to const char*, and construction from const char*.
+	gen_lua.string_to_cstr={'@'              , '@'       , '@.c_str()',         '@.ptr()'}
 	gen_lua.string_from_cstr={'@'            , 'std::string(@)',    'TString(@)'}
 	gen_lua.auto_rename={{'__eq','operator%s*=='},{'__le', 'operator%s*<='},{'__lt', 'operator%s*<'},{'rsub', 'operator%s*-='},{'rmod', 'operator%s*%%='},{'radd', 'operator%s*+='},{'rmult', 'operator%s*%*='}, {'rdiv', 'operator%s*/='},{'assign', 'operator%s*='},{'__call','operator%s*%(%s*%)'},{'__div','operator%s*/'},{'__mul','operator%s*%*'},{'__add','operator%s*+'}, {'__sub','operator%s*-'},{'__mod', 'operator%s*%%'},} -- operator()
 	gen_lua.modifiers={'const', '%*', '&','inline','virtual'}