hedgewars/uScript.pas
changeset 10615 e3dcb235a354
parent 10613 f2597a21f562
child 10617 457730f03c47
equal deleted inserted replaced
10613:f2597a21f562 10615:e3dcb235a354
    98     ScriptAmmoProbability : shortstring;
    98     ScriptAmmoProbability : shortstring;
    99     ScriptAmmoDelay : shortstring;
    99     ScriptAmmoDelay : shortstring;
   100     ScriptAmmoReinforcement : shortstring;
   100     ScriptAmmoReinforcement : shortstring;
   101     ScriptLoaded : boolean;
   101     ScriptLoaded : boolean;
   102     mapDims : boolean;
   102     mapDims : boolean;
   103     PointsBuffer: shortString;
   103     PointsBuffer: shortstring;
   104 
   104 
   105 procedure ScriptPrepareAmmoStore; forward;
   105 procedure ScriptPrepareAmmoStore; forward;
   106 procedure ScriptApplyAmmoStore; forward;
   106 procedure ScriptApplyAmmoStore; forward;
   107 procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward;
   107 procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward;
   108 procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: Byte); forward;
   108 procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: Byte); forward;
  2287         param:= lua_tointeger(L,2);
  2287         param:= lua_tointeger(L,2);
  2288         PointsBuffer:= PointsBuffer + char((param and $FF00) shr 8);
  2288         PointsBuffer:= PointsBuffer + char((param and $FF00) shr 8);
  2289         PointsBuffer:= PointsBuffer + char((param and $FF));
  2289         PointsBuffer:= PointsBuffer + char((param and $FF));
  2290         // width
  2290         // width
  2291         if np > 2 then
  2291         if np > 2 then
  2292             param:= lua_tointeger(L,3)
  2292             begin
  2293         else
  2293             param:= lua_tointeger(L,3);
  2294             param:= 0;
       
  2295 
       
  2296         if param <> 0 then
       
  2297             begin
       
  2298             param:= (param or $80);
  2294             param:= (param or $80);
  2299             // erase
  2295             // erase
  2300             if (np > 3) and lua_toboolean(L, 4) then
  2296             if (np > 3) and lua_toboolean(L, 4) then
  2301                 param:= (param or $40);
  2297                 param:= (param or $40);
  2302             PointsBuffer:= PointsBuffer + char(param);
  2298             PointsBuffer:= PointsBuffer + char(param);
  2303             end
  2299             end
  2304         // width is 0
  2300         // no width defined
  2305         else
  2301         else
  2306             PointsBuffer:= PointsBuffer + char(0);
  2302             PointsBuffer:= PointsBuffer + char(0);
  2307 
  2303 
  2308         // flush before shortstring limit length is reached
  2304         // flush before shortstring limit length is reached
  2309         if length(PointsBuffer) > 245 then
  2305         if length(PointsBuffer) > 245 then
  2314 
  2310 
  2315 
  2311 
  2316 function lc_flushPoints(L : Plua_State) : LongInt; Cdecl;
  2312 function lc_flushPoints(L : Plua_State) : LongInt; Cdecl;
  2317 begin
  2313 begin
  2318     if CheckLuaParamCount(L, 0, 'FlushPoints', '') then
  2314     if CheckLuaParamCount(L, 0, 'FlushPoints', '') then
  2319         ScriptFlushPoints();
  2315         if length(PointsBuffer) > 0 then
       
  2316             ScriptFlushPoints();
  2320     lc_flushPoints:= 0
  2317     lc_flushPoints:= 0
  2321 end;
  2318 end;
  2322 
  2319 
  2323 // stuff for testing the lua API
  2320 // stuff for testing the lua API
  2324 function lc_endluatest(L : Plua_State) : LongInt; Cdecl;
  2321 function lc_endluatest(L : Plua_State) : LongInt; Cdecl;