SRL Archive - OSR Help

New to pascal and scripting, need a little brain storming.


Khal Drogo

2013-02-25 15:47:32

Hello, I'm trying to create a simple power miner using the unoffical 2007 include and my code is working fine but I have no idea how to prevent the script from clicking a rock if i'm already mining it without being able to detect animations and color bots can't do that well so any ideas?

Also here is my code if that helps you any.

Program test;

{$I SRL/SRL.Simba}
{$I P07Include.Simba}

var cx, cy: integer;

var count: integer;



begin

SetupP07Include;

repeat
if P07_FindObj(cx, cy, 'Mine Rocks', 2305614, 5) then
ClickMouse2(mouse_left);
writeln('Found rocks, clicked them, waiting 1.5s');
wait(1500);
count := 0;
if P07_FindObj(cx, cy, 'Mine Rocks', 2305614, 5) = false then
writeln('cant find rocks');
count := count+1;

until count = 5;

writeln('count was 5, no rocks for 7+ seconds. stopped');

end.

EDIT: Also does the FindObj function return a random part of the object each call? It looks like it does but i'm not sure, I don't know if I need to randomize the pixels to avoid clicking the exact pixel over and over.

Gucci

2013-02-25 16:05:38

There is pixel shift but I'm not sure if it works with 07 or if there is an invcount function in the P07 include then you could have it wait until the invcount increases by one

Khal Drogo

2013-02-25 16:37:27

From: Gucci
There is pixel shift but I'm not sure if it works with 07 or if there is an invcount function in the P07 include then you could have it wait until the invcount increases by one


Ahh so check how many items are in the inventory, save that number in a variable then only click if it's changed since the last check?

If I'm wrong could you write some pseudo code I could look at?

Kevin

2013-02-25 16:40:13

You have it fairly well right with your idea on how to check your inventory.

I do (think) PixelShift will work in 07, and (hopefully) IsMoving can be a backup in case someone ended up mining your rock before you and you don't end up waiting for your set time.

Gucci

2013-02-25 19:05:51

From: Khal Drogo
Ahh so check how many items are in the inventory, save that number in a variable then only click if it's changed since the last check?

If I'm wrong could you write some pseudo code I could look at?


That's right.

1. Get an initial count of the inventory.
2. Repeat checking the inventory.
3. Have the it repeat checking until the count increases by one.