hedgewars/uScript.pas
changeset 5243 f2e31a7f953a
parent 5238 46ddaf14509d
child 5245 ce407084728f
--- 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) + ')');