--- a/hedgewars/uScript.pas Fri Dec 10 22:39:20 2010 +0100
+++ b/hedgewars/uScript.pas Fri Dec 10 23:58:15 2010 +0100
@@ -1028,6 +1028,18 @@
end;
lc_setwind:= 0
end;
+
+function lc_getdatapath(L : Plua_State) : LongInt; Cdecl;
+begin
+ if lua_gettop(L) <> 0 then
+ begin
+ LuaError('Lua: Wrong number of parameters passed to GetDataPath!');
+ lua_pushnil(L);
+ end
+ else
+ lua_pushstring(L, str2pchar(Pathz[ptData]));
+ lc_getdatapath:= 1
+end;
///////////////////
procedure ScriptPrintStack;
@@ -1082,7 +1094,6 @@
end;
procedure ScriptOnGameInit;
-var s, t : ansistring;
begin
// not required if there is no script to run
if not ScriptLoaded then
@@ -1108,12 +1119,6 @@
ScriptSetString('Map', '');
ScriptSetString('Theme', '');
-// import locale
-s:= cLocaleFName;
-t:= '';
-SplitByChar(s, t, '.');
-ScriptSetString('L', s);
-
ScriptCall('onGameInit');
// pop game variables
@@ -1295,6 +1300,7 @@
am : TAmmoType;
st : TSound;
he: THogEffect;
+ s, t : ansistring;
begin
// initialize lua
luaState:= lua_open;
@@ -1310,6 +1316,12 @@
ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
+// import locale
+s:= cLocaleFName;
+t:= '';
+SplitByChar(s, t, '.');
+ScriptSetString('L', s);
+
// import game flags
ScriptSetInteger('gfForts', gfForts);
ScriptSetInteger('gfMultiWeapon', gfMultiWeapon);
@@ -1434,6 +1446,7 @@
lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
lua_register(luaState, 'GetRandom', @lc_getrandom);
lua_register(luaState, 'SetWind', @lc_setwind);
+lua_register(luaState, 'GetDataPath', @lc_getdatapath);
ScriptClearStack; // just to be sure stack is empty