hedgewars/uScript.pas
branchhedgeroid
changeset 6224 42b256eca362
parent 6023 a28be05b20bc
parent 6131 4e8816cf9459
child 6328 d14adf1c7721
equal deleted inserted replaced
6055:88cfcd9161d3 6224:42b256eca362
   958             if ammo^.AmmoType = amNothing then lua_pushinteger(L, 0)
   958             if ammo^.AmmoType = amNothing then lua_pushinteger(L, 0)
   959             else lua_pushinteger(L, ammo^.Count)
   959             else lua_pushinteger(L, ammo^.Count)
   960             end
   960             end
   961         else lua_pushinteger(L, 0)
   961         else lua_pushinteger(L, 0)
   962         end
   962         end
   963     else LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!');
   963     else 
   964     lc_getammocount:= 0
   964         begin
       
   965         LuaError('Lua: Wrong number of parameters passed to GetAmmoCount!');
       
   966         lua_pushnil(L)
       
   967         end;
       
   968     lc_getammocount:= 1
   965 end;
   969 end;
   966 
   970 
   967 function lc_sethealth(L : Plua_State) : LongInt; Cdecl;
   971 function lc_sethealth(L : Plua_State) : LongInt; Cdecl;
   968 var gear : PGear;
   972 var gear : PGear;
   969 begin
   973 begin
  1592 // not required if there is no script to run
  1596 // not required if there is no script to run
  1593 if not ScriptLoaded then
  1597 if not ScriptLoaded then
  1594     exit;
  1598     exit;
  1595 
  1599 
  1596 // push game variables so they may be modified by the script
  1600 // push game variables so they may be modified by the script
       
  1601 ScriptSetInteger('BorderColor', cExplosionBorderColor);
  1597 ScriptSetInteger('GameFlags', GameFlags);
  1602 ScriptSetInteger('GameFlags', GameFlags);
  1598 ScriptSetString('Seed', cSeed);
  1603 ScriptSetString('Seed', cSeed);
  1599 ScriptSetInteger('TemplateFilter', cTemplateFilter);
  1604 ScriptSetInteger('TemplateFilter', cTemplateFilter);
  1600 ScriptSetInteger('MapGen', cMapGen);
  1605 ScriptSetInteger('MapGen', cMapGen);
  1601 ScriptSetInteger('ScreenHeight', cScreenHeight);
  1606 ScriptSetInteger('ScreenHeight', cScreenHeight);
  1670 var ret : LongInt;
  1675 var ret : LongInt;
  1671       s : shortstring;
  1676       s : shortstring;
  1672 begin
  1677 begin
  1673 s:= UserPathz[ptData] + '/' + name;
  1678 s:= UserPathz[ptData] + '/' + name;
  1674 if not FileExists(s) then s:= Pathz[ptData] + '/' + name;
  1679 if not FileExists(s) then s:= Pathz[ptData] + '/' + name;
       
  1680 if not FileExists(s) then exit;
       
  1681 
  1675 ret:= luaL_loadfile(luaState, Str2PChar(s));
  1682 ret:= luaL_loadfile(luaState, Str2PChar(s));
  1676 if ret <> 0 then
  1683 if ret <> 0 then
  1677     begin
  1684     begin
  1678     LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
  1685     LuaError('Lua: Failed to load ' + name + '(error ' + IntToStr(ret) + ')');
  1679     LuaError('Lua: ' + lua_tostring(luaState, -1));
  1686     LuaError('Lua: ' + lua_tostring(luaState, -1));