putonajonny
2012-01-01 09:17:25
Date: 01/01/2012
Public/Development:
Revision #:
Debug Text: n/a
File Involved (if known): GrandExchange.scar
Screen Shots (if applicable): (not really) In my script I use the line:
GEFindFreeSpot(i);
Repeat
GEBuyAt(i);
Until(GEBuyMenu);(The lines are actually much longer with failsafes in case it isn't actually in the GE etc. but that is the basis of it. The problem with the GEBuyAt function is that it has the lines: if IsUpText('Buy') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;It is not recognising the UpText properly, The uptext says "Make Buy Offer" however if I insert a line in: WriteLn(GetUpText)
if IsUpText('Buy') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;It outputs:Make Bu^^ff^ ~ -. ..
coords: 41, 164
Make Bu^^ff^ ~ -. ..
coords: 41, 164
Make Bu^^ff^ ~ -. ..
coords: 41, 164
Make Bu^^ff^ ~ - ..
coords: 41, 164
Make Bu^^^^ t . .Showing that it isn't able to read the uptext. I think the problem is currently the snowey background in the GE but a better way of recognising that it is at the right point would be better.
Here is my proposed solution:
When you mouse over one of the boxes you get this popping up in the exact same location every time:
If you run WriteLn(GetTextAt( 52, 120, 0, 100, 10, 4305653, 5, 5, 'SmallCharsNS')) It outputs:BuySo therefore if we can use this to detect if the mouse is in the right place.My proposed solution:
We swap:
if IsUpText('Buy') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end; for:if(GetTextAt( TB.x1 + 20, TB.y1 + 38, 0, 100, 10, 4305653, 5, 5, 'SmallCharsNS') = 'Buy') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;The fill code for that function would then be:
function GEBuyAt(spot: integer): boolean;
var
TB: TBox;
x, y: integer;
begin
if not InGE then exit;
if not GEIsSpotFree(spot) then
begin
writeln('space is not free!');
exit;
end;
TB := GESpotToTBox(spot);
MouseBox(TB.x1 + 35, TB.y1 + 50, TB.x1 + 65, TB.y1 + 80, 3);
wait(150+Random(75));
WriteLn(GetUpText)
if(GetTextAt( TB.x1 + 20, TB.y1 + 38, 0, 100, 10, 4305653, 5, 5, 'SmallCharsNS') = 'Buy') then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
for x:= 0 to 9 do
begin
wait(100);
if GEBuyMenu then break;
end;
Result := GEBuyMenu;
end;Test of my solution:
for i := 1 to 2 do
begin
WriteLn('i = '+IntToStr(i));
TB := GESpotToTBox(i)
MouseBox(TB.x1 + 35, TB.y1 + 50, TB.x1 + 65, TB.y1 + 80, 3);
Wait(1000+Random(200))
WriteLn(GetTextAt( TB.x1 + 20, TB.y1 + 38, 0, 100, 10, 4305653, 5, 5, 'SmallCharsNS'))
If(GetTextAt( TB.x1 + 20, TB.y1 + 38, 0, 100, 10, 4305653, 5, 5, 'SmallCharsNS') = 'Buy') then
WriteLn('It Worked');
WriteLn(GESpotToTBox(i))
Wait(100+Random(50))
WriteLn('')
WriteLn('')
end;Output:
i = 1
Buy
It Worked
(32, 82, 172, 194)
i = 2
Buy
(188, 82, 328, 194)
Successfully executed.