Advertisement
Guest User

Untitled

a guest
Dec 14th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.41 KB | None | 0 0
  1. (*
  2. chooseTool
  3. ==========
  4.  
  5. The production file holds functions and procedures that are used in the
  6. Runescape production screen.
  7.  
  8. The source for this file can be found `here <https://github.com/SRL/SRL-6/blob/master/lib/interfaces/toolsceen.simba>`_.
  9.  
  10. *)
  11.  
  12. {$f-}
  13.  
  14. {$include_once interfaces.simba}
  15.  
  16. (*
  17. type TRSToolScreen
  18. ~~~~~~~~~~~~~~~~~~~~~~~~
  19.  
  20. A type that stores the production interface properties.
  21. *)
  22. type
  23.   TRSToolScreen = type TRSInterface;
  24.  
  25. (*
  26. var productionScreen
  27. ~~~~~~~~~~~~~~~~~~~~
  28.  
  29. Variable that stores functions and properties of the Runescape production interface.
  30.  
  31. Example:
  32.  
  33. .. code-block:: pascal
  34.  
  35.     if (toolScreen.isOpen() then
  36.       writeln('Tool screen is open!');
  37. *)
  38. var
  39.   toolScreen: TRSToolScreen;
  40.  
  41. {*
  42. TRSToolScreen.__init
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  44.  
  45. .. code-block:: pascal
  46.  
  47.     procedure TRSToolScreen.__init();
  48.  
  49. Initializes the TRSProductionSceen.
  50.  
  51. .. note::
  52.  
  53.     - by footballjds
  54.     - Last Updated: 14 December 2013 by footballjds
  55.  
  56. Example:
  57.  
  58. .. code-block:: pascal
  59.  
  60.     toolScreen.__init();
  61. *}
  62. {$IFNDEF CODEINSIGHT}
  63. procedure TRSToolScreen.__init();
  64. begin
  65.   with (self) do
  66.   begin
  67.     name := 'RS Choose Tool Screen';
  68.     ID := ID_INTERFACE_TOOL;
  69.     parentID := -1;
  70.     static := false;
  71.     setBounds([92, 93, 483, 298]);
  72.   end;
  73. end;
  74. {$ENDIF}
  75.  
  76. (*
  77. TRSToolScreen.isOpen
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  79.  
  80. .. code-block:: pascal
  81.  
  82.     function TRSProductionScreen.isOpen(waitTime: integer = 0): boolean;
  83.  
  84. Returns true if the production screen is open, includes a optional parameter
  85. 'waitTime' (default 0) which will search for the production screen until
  86. 'waitTime' is reached.
  87.  
  88. .. note::
  89.  
  90.     - by footballjds
  91.     - Last Updated: 14 December 2013 by footballjds
  92.  
  93. Example:
  94.  
  95. .. code-block:: pascal
  96.  
  97.     if (productionScreen.isOpen()) then
  98.       writeln('it''s open!');
  99. *)
  100. function TRSToolScreen.isOpen(waitTime: integer = 0): boolean;
  101. const
  102.   BORDER_COLOR = 1388125;
  103. var
  104.   t: integer;
  105.   borderTPA: TPointArray;
  106.   borders: TIntegerArray;
  107. begin
  108.   t := (getSystemTime() + waitTime);
  109.   borderTPA := tpaFromBox(intToBox(self.x + 31, self.y + 55, self.x + 361, self.y + 55));
  110.   repeat
  111.     borders := getColors(borderTPA, true);
  112.     if length(borders) = 1 then if borders[0] = BORDER_COLOR then exit(True);
  113.   until (getSystemTime() >= t);
  114.  
  115. end;
  116.  
  117. (*
  118. TRSToolScreen.select
  119. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  120.  
  121. .. code-block:: pascal
  122.  
  123.     function TRSToolScreen.select(tool: string): boolean;
  124.  
  125. Attempts to select the tool, returns if succesfull or not.
  126.  
  127. .. note::
  128.  
  129.     - by footballjds
  130.     - Last Updated: 14 December 2013 by footballjds
  131.  
  132. Example:
  133.  
  134. .. code-block:: pascal
  135.  
  136.     if (toolScreen.select('Knife')) then
  137.       writeln('We started making something!');
  138. *)
  139. function TRSToolScreen.select(tool: String): boolean;
  140. const
  141.   TEXT_COLOR = 2070783;
  142. var
  143.   b, txtB: TBox;
  144.   i: integer;
  145. begin
  146.   result := false;
  147.  
  148.   b := [self.x+65, self.y+84, self.x + 121, self.y + 140];
  149.   txtB := [b.x1 - 15, self.y + 62, b.x2 + 15, self.y + 75];
  150.   if (self.isOpen()) then
  151.   begin
  152.     for i := 0 to 2 do
  153.     begin
  154.       if pos(tool, getTextAtEx(txtB, 0, 50, 30 , TEXT_COLOR, 0, 'StatChars')) > 0 then
  155.       begin
  156.         mouseBox(b, MOUSE_LEFT);
  157.         exit(true);
  158.       end;
  159.       txtB.edit(102, 0, 102, 0);
  160.       b.edit(102, 0, 102, 0);
  161.     end;
  162.   end;
  163.  
  164.   print('TRSToolScreen.select(): result = ' + lowercase(boolToStr(result)), TDebug.SUB);
  165. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement