hedgewars/uScript.pas
changeset 10978 54a49174dbec
parent 10903 c9a0cdee4267
child 10989 0ea100eefae7
equal deleted inserted replaced
10976:56f07b52213a 10978:54a49174dbec
    85     uLandGraphics,
    85     uLandGraphics,
    86     SysUtils,
    86     SysUtils,
    87     uIO,
    87     uIO,
    88     uVisualGearsList,
    88     uVisualGearsList,
    89     uGearsHandlersMess,
    89     uGearsHandlersMess,
    90     uPhysFSLayer
    90     uPhysFSLayer,
       
    91     SDLh
    91 {$IFNDEF PAS2C}
    92 {$IFNDEF PAS2C}
    92     , typinfo
    93     , typinfo
    93 {$ENDIF}
    94 {$ENDIF}
    94     ;
    95     ;
    95 
    96 
    99     ScriptAmmoDelay : shortstring;
   100     ScriptAmmoDelay : shortstring;
   100     ScriptAmmoReinforcement : shortstring;
   101     ScriptAmmoReinforcement : shortstring;
   101     ScriptLoaded : boolean;
   102     ScriptLoaded : boolean;
   102     mapDims : boolean;
   103     mapDims : boolean;
   103     PointsBuffer: shortstring;
   104     PointsBuffer: shortstring;
       
   105     prevCursorPoint: TPoint;  // why is tpoint still in sdlh...
   104 
   106 
   105 procedure ScriptPrepareAmmoStore; forward;
   107 procedure ScriptPrepareAmmoStore; forward;
   106 procedure ScriptApplyAmmoStore; forward;
   108 procedure ScriptApplyAmmoStore; forward;
   107 procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward;
   109 procedure ScriptSetAmmo(ammo : TAmmoType; count, probability, delay, reinforcement: Byte); forward;
   108 procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: Byte); forward;
   110 procedure ScriptSetAmmoDelay(ammo : TAmmoType; delay: Byte); forward;
  2613 // not required if there is no script to run
  2615 // not required if there is no script to run
  2614 if not ScriptLoaded then
  2616 if not ScriptLoaded then
  2615     exit;
  2617     exit;
  2616 
  2618 
  2617 // push game variables so they may be modified by the script
  2619 // push game variables so they may be modified by the script
       
  2620 ScriptSetInteger('CursorX', CursorPoint.X);
       
  2621 ScriptSetInteger('CursorY', CursorPoint.Y);
  2618 ScriptSetInteger('BorderColor', ExplosionBorderColor);
  2622 ScriptSetInteger('BorderColor', ExplosionBorderColor);
  2619 ScriptSetInteger('GameFlags', GameFlags);
  2623 ScriptSetInteger('GameFlags', GameFlags);
  2620 ScriptSetString('Seed', cSeed);
  2624 ScriptSetString('Seed', cSeed);
  2621 ScriptSetInteger('TemplateFilter', cTemplateFilter);
  2625 ScriptSetInteger('TemplateFilter', cTemplateFilter);
  2622 ScriptSetInteger('TemplateNumber', LuaTemplateNumber);
  2626 ScriptSetInteger('TemplateNumber', LuaTemplateNumber);
  2771 begin
  2775 begin
  2772 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
  2776 ScriptSetInteger('TurnTimeLeft', TurnTimeLeft);
  2773 ScriptSetInteger('GameTime', GameTicks);
  2777 ScriptSetInteger('GameTime', GameTicks);
  2774 ScriptSetInteger('TotalRounds', TotalRounds);
  2778 ScriptSetInteger('TotalRounds', TotalRounds);
  2775 ScriptSetInteger('WaterLine', cWaterLine);
  2779 ScriptSetInteger('WaterLine', cWaterLine);
       
  2780 if isCursorVisible and (not bShowAmmoMenu) then
       
  2781     if (prevCursorPoint.X <> CursorPoint.X) or 
       
  2782        (prevCursorPoint.Y <> CursorPoint.Y) then
       
  2783         begin
       
  2784         ScriptSetInteger('CursorX', CursorPoint.X - WorldDx);
       
  2785         ScriptSetInteger('CursorY', cScreenHeight - CursorPoint.Y- WorldDy);
       
  2786         prevCursorPoint.X:= CursorPoint.X;
       
  2787         prevCursorPoint.Y:= CursorPoint.Y;
       
  2788         end
       
  2789 else
       
  2790     begin
       
  2791     ScriptSetInteger('CursorX', NoPointX);
       
  2792     ScriptSetInteger('CursorY', NoPointX);
       
  2793     prevCursorPoint.X:= NoPointX;
       
  2794     prevCursorPoint.Y:= NoPointX
       
  2795     end;
       
  2796 
  2776 if not mapDims then
  2797 if not mapDims then
  2777     begin
  2798     begin
  2778     mapDims:= true;
  2799     mapDims:= true;
  2779     ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
  2800     ScriptSetInteger('LAND_WIDTH', LAND_WIDTH);
  2780     ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
  2801     ScriptSetInteger('LAND_HEIGHT', LAND_HEIGHT);
  3327 
  3348 
  3328 procedure initModule;
  3349 procedure initModule;
  3329 begin
  3350 begin
  3330 mapDims:= false;
  3351 mapDims:= false;
  3331 PointsBuffer:= '';
  3352 PointsBuffer:= '';
       
  3353 prevCursorPoint.X:= NoPointX;
       
  3354 prevCursorPoint.Y:= 0;
  3332 end;
  3355 end;
  3333 
  3356 
  3334 procedure freeModule;
  3357 procedure freeModule;
  3335 begin
  3358 begin
  3336 end;
  3359 end;