hedgewars/uScript.pas
changeset 5243 f2e31a7f953a
parent 5238 46ddaf14509d
child 5245 ce407084728f
equal deleted inserted replaced
5242:e4f6aa3250eb 5243:f2e31a7f953a
    70     uDebug,
    70     uDebug,
    71     uCollisions,
    71     uCollisions,
    72     uRenderUtils,
    72     uRenderUtils,
    73     uTextures,
    73     uTextures,
    74     uLandGraphics,
    74     uLandGraphics,
    75     SDLh; 
    75     SDLh,
       
    76     sysutils; 
    76 
    77 
    77 var luaState : Plua_State;
    78 var luaState : Plua_State;
    78     ScriptAmmoLoadout : shortstring;
    79     ScriptAmmoLoadout : shortstring;
    79     ScriptAmmoProbability : shortstring;
    80     ScriptAmmoProbability : shortstring;
    80     ScriptAmmoDelay : shortstring;
    81     ScriptAmmoDelay : shortstring;
  1434 ScriptSetInteger('TeamsCount', TeamsCount)
  1435 ScriptSetInteger('TeamsCount', TeamsCount)
  1435 end;
  1436 end;
  1436 
  1437 
  1437 procedure ScriptLoad(name : shortstring);
  1438 procedure ScriptLoad(name : shortstring);
  1438 var ret : LongInt;
  1439 var ret : LongInt;
  1439 begin
  1440       s : shortstring;
  1440 ret:= luaL_loadfile(luaState, Str2PChar(Pathz[ptData] + '/' + name));
  1441 begin
       
  1442 s:= UserPathz[ptData] + '/' + name;
       
  1443 if not FileExists(s) then s:= Pathz[ptData] + '/' + name;
       
  1444 ret:= luaL_loadfile(luaState, Str2PChar(s));
  1441 if ret <> 0 then
  1445 if ret <> 0 then
  1442     begin
  1446     begin
  1443     LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
  1447     LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
  1444     LuaError('Lua: ' + lua_tostring(luaState, -1));
  1448     LuaError('Lua: ' + lua_tostring(luaState, -1));
  1445     end
  1449     end