Lua scripting for Torque
by Joe Rossi · 02/01/2006 (5:01 pm) · 91 comments
Download Code File
"What is this?!"
It's a "bridge" between Torquescript and the scripting language Lua. This allows the languages to access each others variables and execute each others code and scripts. If you have no idea what Lua is, go to lua.org or Google it up. Lua is used all over the games industry and is popping up in PC/Mac, PS2, PSP/handheld and Xbox titles. It's a small and simple language with some nice "modern" features, and it only adds a few hundred KB to the EXE.
This was written to be used with Lua 5.1 or better.
"So how do I use it?"
Unzip the archive into your "libs" folder and add all the source to your project, except for lua.c and luac.c. Be sure to add a path to libs/lua in your compiler options. On Windows you have to change winOGLvideo.cc line 168 and make the execScript function non-static.
The only other changes required are in main.cc and are listed below:
at the top of main.cc about line 45 add:
add this to the initLibraries function (about line 94):
add this to your initGame function (after SimChunk::initChunkMappings();)
add this to the shutdownLibraries function (about line 191)
That should do it! It should work with most TGE based product. I use it with TGB. Some issues I came across so far that you should watch for, is calling schedule from lua with docode (it seems not to work). Also returning values from the docode functions may be unreliable. It's better to use the access functions.,
With this you can use Lua scripts like so:
The file lua_export.h contains all of the important code and some documentation. During development you should build with LUA_DEBUG and exception handling turned on Let me know if you have problems, patches, or complaints!
Update: (7/28/07) Major fixes to error reporting functions, now errors are printed properly, and should not crash the engine.
Update: (9/17/06) Updates and bugfixes mostly contributed by Zhang Xinli via email.
* Now the engine won't crash when you make a syntax error in your lua code! ( using lua_pcall ).
* Now all docode() calls will return data from valid code statements to and from either language.
* Bugfix for docode() where numbers were not being returned properly unless you tonumber()'ed them.
* Now dofile() will adhere to TGE's directory rule.
Update: (3/5/06) DLL and libraries added for those who prefer dynamic linkage, and changed the archive from .ZIP to tar.gz to get around the GG resource filesize limit...sorry for the inconvenience!
Update: (2/19/06) files updated to Lua 5.1 Final[/b]
Credits go out to John Vanderbeck (Basic Scriptobject), Lenny Palozzi (Lunar.h lua/C++ bindings), Melv May (Scriptobject access functions), Zhang Xinli, and all other testers/users/contributors.
"What is this?!"
It's a "bridge" between Torquescript and the scripting language Lua. This allows the languages to access each others variables and execute each others code and scripts. If you have no idea what Lua is, go to lua.org or Google it up. Lua is used all over the games industry and is popping up in PC/Mac, PS2, PSP/handheld and Xbox titles. It's a small and simple language with some nice "modern" features, and it only adds a few hundred KB to the EXE.
This was written to be used with Lua 5.1 or better.
"So how do I use it?"
Unzip the archive into your "libs" folder and add all the source to your project, except for lua.c and luac.c. Be sure to add a path to libs/lua in your compiler options. On Windows you have to change winOGLvideo.cc line 168 and make the execScript function non-static.
The only other changes required are in main.cc and are listed below:
at the top of main.cc about line 45 add:
#include "lua/lua_inc.h" // all lua includes lua_State *L=0; #include "lua/lua_export.h" // main bridge classes
add this to the initLibraries function (about line 94):
L = lua_open();
lua_gc(L, LUA_GCSTOP, 0);
luaL_openlibs(L);
Lunar<game>::Register(L);
lua_gc(L, LUA_GCRESTART, 0);add this to your initGame function (after SimChunk::initChunkMappings();)
//open our bridge objects
Con::evaluate("$LuaObject=new LuaObject(lua); lua.docode(\"tge=game()\"); ",0,0);
//change dofile function to our tge function so it will print errors to the console
Con::evaluate("dofile = function(s) tge:docode('lua.dofile(\"' ..string.gsub(s,'\', '\\' ) ..'\");' ) end\");" ,0,0);
// Con::evaluate("$LuaObject=new LuaObject(lua); lua.docode(\"tge=game() dofile=function(s) echo('dofile ' ..s) end\");", 0,0);add this to the shutdownLibraries function (about line 191)
lua_gc(L, LUA_GCCOLLECT, 0); // clean any last garbage
lua_close(L);That should do it! It should work with most TGE based product. I use it with TGB. Some issues I came across so far that you should watch for, is calling schedule from lua with docode (it seems not to work). Also returning values from the docode functions may be unreliable. It's better to use the access functions.,
With this you can use Lua scripts like so:
lua.dofile("someluascript.lua"); And from Lua scripts you can run Torque scripts like so:tge:dofile( './'..scriptpath..'sometorquescript.cs')You can also assign value of a TorqueScript variable to an Lua variable with:
etc1=tge:getvar('$etc')Or assign a Lua value to a TorqueScript valueetc2=lua.docode('return something[1]'); The file lua_export.h contains all of the important code and some documentation. During development you should build with LUA_DEBUG and exception handling turned on Let me know if you have problems, patches, or complaints!
Update: (7/28/07) Major fixes to error reporting functions, now errors are printed properly, and should not crash the engine.
Update: (9/17/06) Updates and bugfixes mostly contributed by Zhang Xinli via email.
* Now the engine won't crash when you make a syntax error in your lua code! ( using lua_pcall ).
* Now all docode() calls will return data from valid code statements to and from either language.
* Bugfix for docode() where numbers were not being returned properly unless you tonumber()'ed them.
* Now dofile() will adhere to TGE's directory rule.
Update: (3/5/06) DLL and libraries added for those who prefer dynamic linkage, and changed the archive from .ZIP to tar.gz to get around the GG resource filesize limit...sorry for the inconvenience!
Update: (2/19/06) files updated to Lua 5.1 Final[/b]
Credits go out to John Vanderbeck (Basic Scriptobject), Lenny Palozzi (Lunar.h lua/C++ bindings), Melv May (Scriptobject access functions), Zhang Xinli, and all other testers/users/contributors.
About the author
#2
02/01/2006 (5:08 pm)
Aside from the 'it's used everywhere!!!' argument, is there any benefit to using Lua instead of torquescript?
#3
Um, the number one most amazing brillant result of this is that u can edit the lua script while the server is running.... I think. :)
Thats not easily possible w/ TorqueScript
Vince
02/01/2006 (8:16 pm)
@Simon,Um, the number one most amazing brillant result of this is that u can edit the lua script while the server is running.... I think. :)
Thats not easily possible w/ TorqueScript
Vince
#4
@Simon: Sure. Although you won't actually use Lua "instead" of Torquescript (TS), but with it. Lua has a few things over TS. Now when I say this I'm not bashing TS. It's a good language and I'm sure it's better for talking to the engine. However, for coding tons of game logic I'd much rather use Lua or maybe Python. I'll bullet list what I feel is cool about this resource and about Lua.
* Tables (as in hash tables) that are efficient and useful for OOP type things.
* Coroutines - VERY powerful for AI and such. AFAIK not present in TS.
* More advanced text parsing/regular expression capabilities.
* Ability to define and redefine functions at runtime
* Ability to use any of Lua's addon libraries
* Plenty of documentation (arguably more than TS :O)
* Easier syntax (as in not C++ style) that may leave less room for errors.
* People are using it, so it may be easier to find scripting help. (which was my point behind my "it's used everywhere" statement )
* If you have written Lua code already it can be reused with Torque. For ex, I had tons of code I've been building over the past years for my homebrew engine. I needed to plug that into T2D, and now I can. That was the prime motivation behind this.
Here is a good overview for those who want more info before digging in. en.wikipedia.org/wiki/Lua_programming_language
02/01/2006 (9:43 pm)
@Vince: I haven't tried that yet, but it should work. :D@Simon: Sure. Although you won't actually use Lua "instead" of Torquescript (TS), but with it. Lua has a few things over TS. Now when I say this I'm not bashing TS. It's a good language and I'm sure it's better for talking to the engine. However, for coding tons of game logic I'd much rather use Lua or maybe Python. I'll bullet list what I feel is cool about this resource and about Lua.
* Tables (as in hash tables) that are efficient and useful for OOP type things.
* Coroutines - VERY powerful for AI and such. AFAIK not present in TS.
* More advanced text parsing/regular expression capabilities.
* Ability to define and redefine functions at runtime
* Ability to use any of Lua's addon libraries
* Plenty of documentation (arguably more than TS :O)
* Easier syntax (as in not C++ style) that may leave less room for errors.
* People are using it, so it may be easier to find scripting help. (which was my point behind my "it's used everywhere" statement )
* If you have written Lua code already it can be reused with Torque. For ex, I had tons of code I've been building over the past years for my homebrew engine. I needed to plug that into T2D, and now I can. That was the prime motivation behind this.
Here is a good overview for those who want more info before digging in. en.wikipedia.org/wiki/Lua_programming_language
#5
02/01/2006 (10:32 pm)
Lua is a freaking cool language. Excellent work!
#6
02/02/2006 (9:47 am)
I haven't worked with Lua, so my question is; can lua be "compiled" into a binary format, so players can't get at the scripts?
#7
@Steve, I believe it works much like Torquescript. In the zip you will find the standalone bytecode compiler in the file luac.c. Run that over your scripts before release with a commandline such as "luac -O -o compiled.lua source.lua". If you're more paranoid (like me :)) you can also take your finished scripts and compile them into the EXE as a string buffer and run them from there.
Edit:grammar/clarification.
02/02/2006 (12:35 pm)
@ Josh R, Thank you! I hope it will prove useful.@Steve, I believe it works much like Torquescript. In the zip you will find the standalone bytecode compiler in the file luac.c. Run that over your scripts before release with a commandline such as "luac -O -o compiled.lua source.lua". If you're more paranoid (like me :)) you can also take your finished scripts and compile them into the EXE as a string buffer and run them from there.
Edit:grammar/clarification.
#8
- john
02/02/2006 (2:17 pm)
When I first read this my response was like Simone's, 'whats the point' so to speak of having a scriptlanguage in a script langauge...kind of redundant. But, if you can edit your code at runtime, that is great. So I started thinking of something like when you need some RPG ai where if you use Phil's AI pack he's making, you can hook into lua at some point for things like trigger code. Being able to change your ai during runtime to fix/test it, without exiting, editing, reloading game, testing a hundred times probably will save a lot of time.- john
#9
02/02/2006 (6:00 pm)
It is possible to "hotswap" Lua stuff, but you have to write your code to do it. That is, you have to either constantly check to see if a file has been changed (so that it can be reloaded), or you have to have some command to tell the system to do the checking and reloading. But it is certainly possible. And starting a mission/level/etc over while the game is still running is much easier/faster than halting the program and running it again.
#10
@Smaug: I'm not sure what you mean by having to constantly check files. You may be able to use an Lua metatable for whatever it is you need to achieve. That could be the proverbial command that tells the system to do xyz. Metatables allow Lua to "see" when a variable, function, or object is assigned a new value, and then run a function in response to that change. Of course they can do more...
02/02/2006 (10:41 pm)
@John: Runtime editing is definatly "RAD" :) I haven't done it yet, but I'm sure it's possible. Anyone looking into AI may want to read about Lua coroutines. They are basically self-contained programs or logical "threads" that can accept any input, even dynamic input, then act upon it. You can make one per player or per enemy. I make extensive use of them in my (unfinished, unannounced:) "games". I kind of wish Torquescript had them too.. but maybe you can get similar results using schedule commands? @Smaug: I'm not sure what you mean by having to constantly check files. You may be able to use an Lua metatable for whatever it is you need to achieve. That could be the proverbial command that tells the system to do xyz. Metatables allow Lua to "see" when a variable, function, or object is assigned a new value, and then run a function in response to that change. Of course they can do more...
#11
02/03/2006 (7:22 am)
So does this mean after recompiling TGE with this, we can just stick Lua scripts in our game folder and run them?
#12
The only thing you can't really do a runtime edit on in Torquescript are datablocks.
02/03/2006 (1:09 pm)
I've done "runtime" editing of Torquescripts plenty of times.The only thing you can't really do a runtime edit on in Torquescript are datablocks.
#13
it's easy to edit torque scripts runtime.
i have about 20 scripts which i've created and which i'd like to edit during runtime.
i just make one script called 'reload.cs' or somesuch, and have it exec all 20.
then i add a button to some GUI which i can click to exec reload.
then it's easy - edit a script, click the button.
02/03/2006 (3:55 pm)
To expand on what Harold said,it's easy to edit torque scripts runtime.
i have about 20 scripts which i've created and which i'd like to edit during runtime.
i just make one script called 'reload.cs' or somesuch, and have it exec all 20.
then i add a button to some GUI which i can click to exec reload.
then it's easy - edit a script, click the button.
#14
@Harold: Yeah I realized that whole idea was nothing new last night when I was "runtime editing" in the console.. ah well.
02/03/2006 (3:59 pm)
@Ben: Basically, yes. If you follow the directions you should be able to just type "lua.dofile("pathtoluascript.lua"). The more important feature is being able to pull in values from those Lua scripts and use them in TGE(and vice versa). @Harold: Yeah I realized that whole idea was nothing new last night when I was "runtime editing" in the console.. ah well.
#15
1) is there a way to call torquescript functions directly? i saw how to execute torquescript files and get variable values in the examples above, but didn't see function calls. would these be listed in the bindings themselves? any particular file you can point me to?
2) anyone have a problem tryin to integrate this into the latest T2D 1.1 Beta1?
I get the following errors:
02/05/2006 (1:14 am)
i had a couple questions1) is there a way to call torquescript functions directly? i saw how to execute torquescript files and get variable values in the examples above, but didn't see function calls. would these be listed in the bindings themselves? any particular file you can point me to?
2) anyone have a problem tryin to integrate this into the latest T2D 1.1 Beta1?
I get the following errors:
loadlib.c
c:\TorqueSDK\T2D\engine\lib\lua\src\loadlib.c(120) : error C2664: 'FormatMessageW' : cannot convert parameter 5 from 'char [128]' to 'LPWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\TorqueSDK\T2D\engine\lib\lua\src\loadlib.c(132) : error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
main.cc
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(216) : error C2065: 'ifdef' : undeclared identifier
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(216) : error C2146: syntax error : missing ';' before identifier 'LUA_DEBUG'
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(216) : error C2065: 'LUA_DEBUG' : undeclared identifier
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(216) : error C2144: syntax error : 'int' should be preceded by ';'
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(218) : error C3861: 'panicf': identifier not found, even with argument-dependent lookup
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(223) : error C3861: 'panicf': identifier not found, even with argument-dependent lookup
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(224) : error C3861: 'panicf': identifier not found, even with argument-dependent lookup
c:\TorqueSDK\T2D\engine\lib\lua\lua_export.h(487) : fatal error C1020: unexpected #endif
#17
C:\SphyxGames\DawnOf Men 0.3\lib\lua\lua\src\loadlib.c(120) : error C2664: 'FormatMessageW' : cannot convert parameter 5 from 'char [128]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\SphyxGames\DawnOf Men 0.3\lib\lua\lua\src\loadlib.c(132) : error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
02/05/2006 (2:09 am)
also:C:\SphyxGames\DawnOf Men 0.3\lib\lua\lua\src\loadlib.c(120) : error C2664: 'FormatMessageW' : cannot convert parameter 5 from 'char [128]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\SphyxGames\DawnOf Men 0.3\lib\lua\lua\src\loadlib.c(132) : error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
#18
To call a TGE function you would use the docode function like so:
What compiler are you using? It builds fine for me in MSVC2003, with or without Unicode. Those are unicode related errors. You can try to rename any of those function calls to "FormatMessageA" and "LoadLibraryA". Every windows function have an "A" (ansi) and a "W" (unicode) version. I think Lua needs the "A" versions..
@James, you should just put the zip into your engine\lib directory and unzip it there. Your directory structure should end up looking like engine\lib\lua\lua\src for it to compile.
Edit: Those changes were added to the zip. Download it again and see if it builds.
02/05/2006 (7:06 am)
@lineage, The file lua_export.h contains the important code and documentation. To call a TGE function you would use the docode function like so:
tge:docode('someTGEfunctionorTGEcode')What compiler are you using? It builds fine for me in MSVC2003, with or without Unicode. Those are unicode related errors. You can try to rename any of those function calls to "FormatMessageA" and "LoadLibraryA". Every windows function have an "A" (ansi) and a "W" (unicode) version. I think Lua needs the "A" versions..
@James, you should just put the zip into your engine\lib directory and unzip it there. Your directory structure should end up looking like engine\lib\lua\lua\src for it to compile.
Edit: Those changes were added to the zip. Download it again and see if it builds.
#19
im using VS.NET - any ideas? thanks for the update though
02/05/2006 (12:56 pm)
k i downloaded the latest zip and it looks like i get a bunch of linker errors. i tried to resolve them but couldn't.im using VS.NET - any ideas? thanks for the update though
main.obj : error LNK2019: unresolved external symbol _lua_settop referenced in function "public: void __thiscall LuaObject::dofile(char const *)" (?dofile@LuaObject@@QAEXPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_call referenced in function "public: void __thiscall LuaObject::dofile(char const *)" (?dofile@LuaObject@@QAEXPBD@Z) main.obj : error LNK2019: unresolved external symbol _luaL_loadfile referenced in function "public: void __thiscall LuaObject::dofile(char const *)" (?dofile@LuaObject@@QAEXPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_tolstring referenced in function "public: char const * __thiscall LuaObject::docode(char const *)" (?docode@LuaObject@@QAEPBDPBD@Z) main.obj : error LNK2019: unresolved external symbol _luaL_loadstring referenced in function "public: char const * __thiscall LuaObject::docode(char const *)" (?docode@LuaObject@@QAEPBDPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_toboolean referenced in function "public: bool __thiscall LuaObject::getb(char const *)" (?getb@LuaObject@@QAE_NPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_gettable referenced in function "public: bool __thiscall LuaObject::getb(char const *)" (?getb@LuaObject@@QAE_NPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushstring referenced in function "public: bool __thiscall LuaObject::getb(char const *)" (?getb@LuaObject@@QAE_NPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_tonumber referenced in function "public: unsigned int __thiscall LuaObject::geti(char const *)" (?geti@LuaObject@@QAEIPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_concat referenced in function "public: char const * __thiscall LuaObject::get(char const *)" (?get@LuaObject@@QAEPBDPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_insert referenced in function "public: char const * __thiscall LuaObject::get(char const *)" (?get@LuaObject@@QAEPBDPBD@Z) main.obj : error LNK2019: unresolved external symbol _lua_settable referenced in function "public: void __thiscall LuaObject::set(char const *,char const *)" (?set@LuaObject@@QAEXPBD0@Z) main.obj : error LNK2019: unresolved external symbol _luaL_checknumber referenced in function "public: int __thiscall game::setb(struct lua_State *)" (?setb@game@@QAEHPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushnumber referenced in function "public: int __thiscall game::getb(struct lua_State *)" (?getb@game@@QAEHPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _luaL_openlibs referenced in function "bool __cdecl initLibraries(void)" (?initLibraries@@YA_NXZ) main.obj : error LNK2019: unresolved external symbol _lua_gc referenced in function "bool __cdecl initLibraries(void)" (?initLibraries@@YA_NXZ) main.obj : error LNK2019: unresolved external symbol _luaL_newstate referenced in function "bool __cdecl initLibraries(void)" (?initLibraries@@YA_NXZ) main.obj : error LNK2019: unresolved external symbol _lua_close referenced in function "void __cdecl shutdownLibraries(void)" (?shutdownLibraries@@YAXXZ) main.obj : error LNK2019: unresolved external symbol _lua_pushlightuserdata referenced in function "public: static void __cdecl Lunar<class game>::Register(struct lua_State *)" (?Register@?$Lunar@Vgame@@@@SAXPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_setmetatable referenced in function "public: static void __cdecl Lunar<class game>::Register(struct lua_State *)" (?Register@?$Lunar@Vgame@@@@SAXPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushcclosure referenced in function "public: static void __cdecl Lunar<class game>::Register(struct lua_State *)" (?Register@?$Lunar@Vgame@@@@SAXPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushvalue referenced in function "public: static void __cdecl Lunar<class game>::Register(struct lua_State *)" (?Register@?$Lunar@Vgame@@@@SAXPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _luaL_newmetatable referenced in function "public: static void __cdecl Lunar<class game>::Register(struct lua_State *)" (?Register@?$Lunar@Vgame@@@@SAXPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_gettop referenced in function "public: static void __cdecl Lunar<class game>::Register(struct lua_State *)" (?Register@?$Lunar@Vgame@@@@SAXPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_createtable referenced in function "public: static void __cdecl Lunar<class game>::Register(struct lua_State *)" (?Register@?$Lunar@Vgame@@@@SAXPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_touserdata referenced in function "private: static int __cdecl Lunar<class game>::thunk(struct lua_State *)" (?thunk@?$Lunar@Vgame@@@@CAHPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_remove referenced in function "private: static int __cdecl Lunar<class game>::thunk(struct lua_State *)" (?thunk@?$Lunar@Vgame@@@@CAHPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_type referenced in function "private: static int __cdecl Lunar<class game>::gc_T(struct lua_State *)" (?gc_T@?$Lunar@Vgame@@@@CAHPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _luaL_getmetafield referenced in function "private: static int __cdecl Lunar<class game>::gc_T(struct lua_State *)" (?gc_T@?$Lunar@Vgame@@@@CAHPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushfstring referenced in function "private: static int __cdecl Lunar<class game>::tostring_T(struct lua_State *)" (?tostring_T@?$Lunar@Vgame@@@@CAHPAUlua_State@@@Z) main.obj : error LNK2019: unresolved external symbol _lua_replace referenced in function "public: static int __cdecl Lunar<class game>::push(struct lua_State *,class game *,bool)" (?push@?$Lunar@Vgame@@@@SAHPAUlua_State@@PAVgame@@_N@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushboolean referenced in function "public: static int __cdecl Lunar<class game>::push(struct lua_State *,class game *,bool)" (?push@?$Lunar@Vgame@@@@SAHPAUlua_State@@PAVgame@@_N@Z) main.obj : error LNK2019: unresolved external symbol _lua_checkstack referenced in function "public: static int __cdecl Lunar<class game>::push(struct lua_State *,class game *,bool)" (?push@?$Lunar@Vgame@@@@SAHPAUlua_State@@PAVgame@@_N@Z) main.obj : error LNK2019: unresolved external symbol _luaL_error referenced in function "public: static int __cdecl Lunar<class game>::push(struct lua_State *,class game *,bool)" (?push@?$Lunar@Vgame@@@@SAHPAUlua_State@@PAVgame@@_N@Z) main.obj : error LNK2019: unresolved external symbol _lua_getfield referenced in function "public: static int __cdecl Lunar<class game>::push(struct lua_State *,class game *,bool)" (?push@?$Lunar@Vgame@@@@SAHPAUlua_State@@PAVgame@@_N@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushnil referenced in function "public: static int __cdecl Lunar<class game>::push(struct lua_State *,class game *,bool)" (?push@?$Lunar@Vgame@@@@SAHPAUlua_State@@PAVgame@@_N@Z) main.obj : error LNK2019: unresolved external symbol _luaL_typerror referenced in function "public: static class game * __cdecl Lunar<class game>::check(struct lua_State *,int)" (?check@?$Lunar@Vgame@@@@SAPAVgame@@PAUlua_State@@H@Z) main.obj : error LNK2019: unresolved external symbol _luaL_checkudata referenced in function "public: static class game * __cdecl Lunar<class game>::check(struct lua_State *,int)" (?check@?$Lunar@Vgame@@@@SAPAVgame@@PAUlua_State@@H@Z) main.obj : error LNK2019: unresolved external symbol _lua_newuserdata referenced in function "private: static void * __cdecl Lunar<class game>::pushuserdata(struct lua_State *,void *,unsigned int)" (?pushuserdata@?$Lunar@Vgame@@@@CAPAXPAUlua_State@@PAXI@Z) main.obj : error LNK2019: unresolved external symbol _lua_pushlstring referenced in function "private: static void __cdecl Lunar<class game>::weaktable(struct lua_State *,char const *)" (?weaktable@?$Lunar@Vgame@@@@CAXPAUlua_State@@PBD@Z)../../../Games/T2D_DEBUG.exe : fatal error LNK1120: 40 unresolved externals
#20
02/05/2006 (4:06 pm)
Hmm.. from here that looks like you didn't add the lua files to your project... ? Make sure all the .c files from the src directory are compiled along with the engine, all except for lua.c and luac.c.
Torque Owner Josh Williams
Default Studio Name