hedgewars/uScript.pas
changeset 4484 b7a098f2649a
parent 4483 ad1524a177bd
child 4496 ba5da3388110
equal deleted inserted replaced
4483:ad1524a177bd 4484:b7a098f2649a
   197         lua_pushnil(L);
   197         lua_pushnil(L);
   198     end
   198     end
   199     else begin
   199     else begin
   200         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   200         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   201             HealthCrate, 0);
   201             HealthCrate, 0);
   202         lua_pushnumber(L, gear^.uid);
   202         lua_pushinteger(L, gear^.uid);
   203     end;
   203     end;
   204     lc_spawnhealthcrate := 1;        
   204     lc_spawnhealthcrate := 1;        
   205 end;
   205 end;
   206 
   206 
   207 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl;
   207 function lc_spawnammocrate(L: PLua_State): LongInt; Cdecl;
   212         lua_pushnil(L);
   212         lua_pushnil(L);
   213     end
   213     end
   214     else begin
   214     else begin
   215         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   215         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   216             AmmoCrate, lua_tointeger(L, 3));
   216             AmmoCrate, lua_tointeger(L, 3));
   217         lua_pushnumber(L, gear^.uid);
   217         lua_pushinteger(L, gear^.uid);
   218     end;
   218     end;
   219     lc_spawnammocrate := 1;
   219     lc_spawnammocrate := 1;
   220 end;
   220 end;
   221 
   221 
   222 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl;
   222 function lc_spawnutilitycrate(L: PLua_State): LongInt; Cdecl;
   227         lua_pushnil(L);
   227         lua_pushnil(L);
   228     end
   228     end
   229     else begin  
   229     else begin  
   230         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   230         gear := SpawnCustomCrateAt(lua_tointeger(L, 1), lua_tointeger(L, 2),
   231             UtilityCrate, lua_tointeger(L, 3));
   231             UtilityCrate, lua_tointeger(L, 3));
   232         lua_pushnumber(L, gear^.uid);
   232         lua_pushinteger(L, gear^.uid);
   233     end;
   233     end;
   234     lc_spawnutilitycrate := 1;
   234     lc_spawnutilitycrate := 1;
   235 end;
   235 end;
   236 
   236 
   237 function lc_addgear(L : Plua_State) : LongInt; Cdecl;
   237 function lc_addgear(L : Plua_State) : LongInt; Cdecl;
   254         dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000;
   254         dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000;
   255         dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000;
   255         dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000;
   256         t:= lua_tointeger(L, 7);
   256         t:= lua_tointeger(L, 7);
   257 
   257 
   258         gear:= AddGear(x, y, gt, s, dx, dy, t);
   258         gear:= AddGear(x, y, gt, s, dx, dy, t);
   259         lua_pushnumber(L, gear^.uid)
   259         lua_pushinteger(L, gear^.uid)
   260         end;
   260         end;
   261     lc_addgear:= 1; // 1 return value
   261     lc_addgear:= 1; // 1 return value
   262 end;
   262 end;
   263 
   263 
   264 function lc_deletegear(L : Plua_State) : LongInt; Cdecl;
   264 function lc_deletegear(L : Plua_State) : LongInt; Cdecl;
   294         vgt:= TVisualGearType(lua_tointeger(L, 3));
   294         vgt:= TVisualGearType(lua_tointeger(L, 3));
   295         s:= lua_tointeger(L, 4);
   295         s:= lua_tointeger(L, 4);
   296         c:= lua_toboolean(L, 5);
   296         c:= lua_toboolean(L, 5);
   297 
   297 
   298         vg:= AddVisualGear(x, y, vgt, s, c); 
   298         vg:= AddVisualGear(x, y, vgt, s, c); 
   299         if vg <> nil then lua_pushnumber(L, vg^.uid)
   299         if vg <> nil then lua_pushinteger(L, vg^.uid)
   300         else lua_pushnumber(L, 0)
   300         else lua_pushinteger(L, 0)
   301         end;
   301         end;
   302     lc_addvisualgear:= 1; // 1 return value
   302     lc_addvisualgear:= 1; // 1 return value
   303 end;
   303 end;
   304 
   304 
   305 function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl;
   305 function lc_deletevisualgear(L : Plua_State) : LongInt; Cdecl;
   383         end
   383         end
   384     else
   384     else
   385         if FollowGear = nil then
   385         if FollowGear = nil then
   386             lua_pushnil(L)
   386             lua_pushnil(L)
   387         else
   387         else
   388             lua_pushnumber(L, FollowGear^.uid);
   388             lua_pushinteger(L, FollowGear^.uid);
   389     lc_getfollowgear:= 1; // 1 return value
   389     lc_getfollowgear:= 1; // 1 return value
   390 end;
   390 end;
   391 
   391 
   392 function lc_getgeartype(L : Plua_State) : LongInt; Cdecl;
   392 function lc_getgeartype(L : Plua_State) : LongInt; Cdecl;
   393 var gear : PGear;
   393 var gear : PGear;
   529         end
   529         end
   530     else
   530     else
   531         begin
   531         begin
   532         gear:= GearByUID(lua_tointeger(L, 1));
   532         gear:= GearByUID(lua_tointeger(L, 1));
   533         if gear <> nil then
   533         if gear <> nil then
   534             lua_pushnumber(L, gear^.Timer)
   534             lua_pushinteger(L, gear^.Timer)
   535         else
   535         else
   536             lua_pushnil(L);
   536             lua_pushnil(L);
   537         end;
   537         end;
   538     lc_gettimer:= 1
   538     lc_gettimer:= 1
   539 end;
   539 end;
   548         end
   548         end
   549     else
   549     else
   550         begin
   550         begin
   551         gear:= GearByUID(lua_tointeger(L, 1));
   551         gear:= GearByUID(lua_tointeger(L, 1));
   552         if gear <> nil then
   552         if gear <> nil then
   553             lua_pushnumber(L, gear^.Health)
   553             lua_pushinteger(L, gear^.Health)
   554         else
   554         else
   555             lua_pushnil(L);
   555             lua_pushnil(L);
   556         end;
   556         end;
   557     lc_gethealth:= 1
   557     lc_gethealth:= 1
   558 end;
   558 end;
   567         end
   567         end
   568     else
   568     else
   569         begin
   569         begin
   570         gear:= GearByUID(lua_tointeger(L, 1));
   570         gear:= GearByUID(lua_tointeger(L, 1));
   571         if gear <> nil then
   571         if gear <> nil then
   572             lua_pushnumber(L, hwRound(gear^.X))
   572             lua_pushinteger(L, hwRound(gear^.X))
   573         else
   573         else
   574             lua_pushnil(L);
   574             lua_pushnil(L);
   575         end;
   575         end;
   576     lc_getx:= 1
   576     lc_getx:= 1
   577 end;
   577 end;
   586         end
   586         end
   587     else
   587     else
   588         begin
   588         begin
   589         gear:= GearByUID(lua_tointeger(L, 1));
   589         gear:= GearByUID(lua_tointeger(L, 1));
   590         if gear <> nil then
   590         if gear <> nil then
   591             lua_pushnumber(L, hwRound(gear^.Y))
   591             lua_pushinteger(L, hwRound(gear^.Y))
   592         else
   592         else
   593             lua_pushnil(L);
   593             lua_pushnil(L);
   594         end;
   594         end;
   595     lc_gety:= 1
   595     lc_gety:= 1
   596 end;
   596 end;