check alternate script loading path
authornemo
Tue, 14 Jun 2011 16:50:41 -0400
changeset 5243 f2e31a7f953a
parent 5242 e4f6aa3250eb
child 5244 1b408b965c01
child 5245 ce407084728f
child 5246 bc80445549e0
check alternate script loading path
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Tue Jun 14 16:44:51 2011 -0400
+++ b/hedgewars/uScript.pas	Tue Jun 14 16:50:41 2011 -0400
@@ -72,7 +72,8 @@
     uRenderUtils,
     uTextures,
     uLandGraphics,
-    SDLh; 
+    SDLh,
+    sysutils; 
 
 var luaState : Plua_State;
     ScriptAmmoLoadout : shortstring;
@@ -1436,8 +1437,11 @@
 
 procedure ScriptLoad(name : shortstring);
 var ret : LongInt;
+      s : shortstring;
 begin
-ret:= luaL_loadfile(luaState, Str2PChar(Pathz[ptData] + '/' + name));
+s:= UserPathz[ptData] + '/' + name;
+if not FileExists(s) then s:= Pathz[ptData] + '/' + name;
+ret:= luaL_loadfile(luaState, Str2PChar(s));
 if ret <> 0 then
     begin
     LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');