hedgewars/uScript.pas
changeset 13752 f1c66a34f2fe
parent 13750 110d6c1e817f
child 13764 c46998ecd8fa
equal deleted inserted replaced
13751:5985ee7a4922 13752:f1c66a34f2fe
    38 procedure ScriptOnPreviewInit;
    38 procedure ScriptOnPreviewInit;
    39 procedure ScriptOnGameInit;
    39 procedure ScriptOnGameInit;
    40 procedure ScriptOnScreenResize;
    40 procedure ScriptOnScreenResize;
    41 procedure ScriptSetInteger(name : shortstring; value : LongInt);
    41 procedure ScriptSetInteger(name : shortstring; value : LongInt);
    42 procedure ScriptSetString(name : shortstring; value : shortstring);
    42 procedure ScriptSetString(name : shortstring; value : shortstring);
       
    43 procedure ScriptSetMapGlobals;
    43 
    44 
    44 procedure ScriptCall(fname : shortstring);
    45 procedure ScriptCall(fname : shortstring);
    45 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
    46 function ScriptCall(fname : shortstring; par1: LongInt) : LongInt;
    46 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt;
    47 function ScriptCall(fname : shortstring; par1, par2: LongInt) : LongInt;
    47 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
    48 function ScriptCall(fname : shortstring; par1, par2, par3: LongInt) : LongInt;
    97     ScriptAmmoLoadout : shortstring;
    98     ScriptAmmoLoadout : shortstring;
    98     ScriptAmmoProbability : shortstring;
    99     ScriptAmmoProbability : shortstring;
    99     ScriptAmmoDelay : shortstring;
   100     ScriptAmmoDelay : shortstring;
   100     ScriptAmmoReinforcement : shortstring;
   101     ScriptAmmoReinforcement : shortstring;
   101     ScriptLoaded : boolean;
   102     ScriptLoaded : boolean;
   102     mapDims : boolean;
       
   103     PointsBuffer: shortstring;
   103     PointsBuffer: shortstring;
   104     PrevCursorX, PrevCursorY: LongInt;
   104     PrevCursorX, PrevCursorY: LongInt;
   105     PendingTurnTimeLeft, PendingReadyTimeLeft: LongWord;
   105     PendingTurnTimeLeft, PendingReadyTimeLeft: LongWord;
   106     isPendingTurnTimeLeft, isPendingReadyTimeLeft: boolean;
   106     isPendingTurnTimeLeft, isPendingReadyTimeLeft: boolean;
   107 
   107 
  3538     ScriptApplyAmmoStore
  3538     ScriptApplyAmmoStore
  3539     end;
  3539     end;
  3540 
  3540 
  3541 ScriptSetInteger('ClansCount', ClansCount);
  3541 ScriptSetInteger('ClansCount', ClansCount);
  3542 ScriptSetInteger('TeamsCount', TeamsCount);
  3542 ScriptSetInteger('TeamsCount', TeamsCount);
  3543 mapDims:= false
       
  3544 end;
  3543 end;
  3545 
  3544 
  3546 
  3545 
  3547 // Update values of screen dimensions and allow script to react to resolution change
  3546 // Update values of screen dimensions and allow script to react to resolution change
  3548 procedure ScriptOnScreenResize();
  3547 procedure ScriptOnScreenResize();
  3707     ScriptSetInteger('CursorY', NoPointX);
  3706     ScriptSetInteger('CursorY', NoPointX);
  3708     PrevCursorX:= NoPointX;
  3707     PrevCursorX:= NoPointX;
  3709     PrevCursorY:= NoPointX
  3708     PrevCursorY:= NoPointX
  3710     end;
  3709     end;
  3711 
  3710 
  3712 if not mapDims then
       
  3713     begin
       
  3714     mapDims:= true;
       
  3715     ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
       
  3716     ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
       
  3717     ScriptSetInteger('LeftX', leftX);
       
  3718     ScriptSetInteger('RightX', rightX);
       
  3719     ScriptSetInteger('TopY', topY)
       
  3720     end;
       
  3721 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then
  3711 if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then
  3722     ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID)
  3712     ScriptSetInteger('CurrentHedgehog', CurrentHedgehog^.Gear^.UID)
  3723 else
  3713 else
  3724     ScriptSetNil('CurrentHedgehog');
  3714     ScriptSetNil('CurrentHedgehog');
       
  3715 end;
       
  3716 
       
  3717 procedure ScriptSetMapGlobals;
       
  3718 begin
       
  3719 ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
       
  3720 ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
       
  3721 ScriptSetInteger('LeftX', leftX);
       
  3722 ScriptSetInteger('RightX', rightX);
       
  3723 ScriptSetInteger('TopY', topY);
  3725 end;
  3724 end;
  3726 
  3725 
  3727 procedure GetGlobals;
  3726 procedure GetGlobals;
  3728 var currentTTL, currentRTL, newTTL, newRTL: LongInt;
  3727 var currentTTL, currentRTL, newTTL, newRTL: LongInt;
  3729 begin
  3728 begin
  4380 begin
  4379 begin
  4381 end;
  4380 end;
  4382 
  4381 
  4383 procedure initModule;
  4382 procedure initModule;
  4384 begin
  4383 begin
  4385 mapDims:= false;
       
  4386 PointsBuffer:= '';
  4384 PointsBuffer:= '';
  4387 PrevCursorX:= NoPointX;
  4385 PrevCursorX:= NoPointX;
  4388 PrevCursorY:= NoPointX;
  4386 PrevCursorY:= NoPointX;
  4389 isPendingTurnTimeLeft:= false;
  4387 isPendingTurnTimeLeft:= false;
  4390 isPendingReadyTimeLeft:= false;
  4388 isPendingReadyTimeLeft:= false;