The script was pretty simple because I was just trying to get this working before stepping into the whole thing:
In eliminatio.lua:
dofile("gamecycle.lua");
function Think()
TestFunc();
end
In gamecycle.lua:
function TestFunc();
ClientPrintAll(HUD_PRINTCENTER, "TEST");
end
Shit, looks like you'll have to wait for BETA 4 in order to implement your module system properly. I had to add the "Package Library" to the LUA environment in order to get the 'require' function.
By the way, the proper way to set the path for "require" and not have an environment variable for it is to set:
package.path = "C:/Program Files/Steam/steamapps/SourceMods/gesource_svn/scripts/gameplay/?.lua";
Where package is the global table that comes from the "Package Library."
So this is working wonderfully in Beta 4 now. Sorry that it won't work out for B3.1.4.
(C++)
// Define our path
char fullpath[ 512 ] = { 0 };
filesystem->RelativePathToFullPath( "scripts/gameplay", "MOD", fullpath, sizeof(fullpath) );
Q_strncat( fullpath, "\\?.lua", sizeof(fullpath) );
lua_getglobal(GetLua(), "package");
if (LUA_TTABLE != lua_type(GetLua(), 1))
return;
lua_pushlstring(GetLua(), fullpath, Q_strlen(fullpath) );
lua_setfield(GetLua(), 1, "path"); /* package.path = fullpath */
(LUA)
testfunc.lua
function TestFunc()
ClientPrintAll(HUD_PRINTTALK, "TEST FUNC!");
end
deathmatch.lua
require( "testfunc" );
function PlayerKilled( victim, killer )
TestFunc();
end