SRL Archive - OSR Help

How can I detect that an action has finished?


maky369

2013-04-08 07:25:19

Hey everyone, I've been trying to write my first script, and needless to say it is HARD. I've come up against a wall in trying to detect whether the character has completed an action - how can I do this? The script I am working on is to cut trees, then burn them, but I'm having trouble getting the bot to not take action until the tree has been cut down. My idea was to get this working by repeating a wait command until the tree has been cut down, but how can I detect this?

dzpliu

2013-04-08 07:26:12

From: maky369
Hey everyone, I've been trying to write my first script, and needless to say it is HARD. I've come up against a wall in trying to detect whether the character has completed an action - how can I do this? The script I am working on is to cut trees, then burn them, but I'm having trouble getting the bot to not take action until the tree has been cut down. My idea was to get this working by repeating a wait command until the tree has been cut down, but how can I detect this?


use ismoving.

rj

2013-04-08 07:31:12

You mean like to see if it stopped cutting?

http://villavu.com/forum/showthread.php?t=74090

or you can use invcount

Pixel shift function:

Function IsCutting: Boolean;
begin
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 250, 500) > 400);
end;
end;

    PBox := IntToBox(245, 130, 285, 195);

Is were it is looking for moving pixels

    Result := (AveragePixelShift(PBox, 250, 500) > 400);

This:

(PBox, 250, 500) > 400);
means it returns true if there are more then 400 pixels moving in that area.

so to detect when you could stop chopping you could do something like

while IsCutting do
wait(100)

dzpliu

2013-04-08 07:33:32

From: RJJ95
You mean like to see if it stopped cutting?

http://villavu.com/forum/showthread.php?t=74090


that is more accurate but ismoving function is enough for this case.

Flight

2013-04-08 07:35:40

From: dzpliu
use ismoving.


IsMoving refers to the player walking as it monitors pixelshift in the minimap. Needless to say this won't do you any good for player animating.

As RJJ95 said above me you could detect your player animating through pixelshift. You can also watch your inventory for either a change in item count or a change in log count directly.

dzpliu

2013-04-08 07:38:21

From: Flight
IsMoving refers to the player walking as it monitors pixelshift in the minimap. Needless to say this won't do you any good for player animating.

As RJJ95 said above me you could detect your player animating through pixelshift. You can also watch your inventory for either a change in item count or a change in log count directly.


oh i forgot…haha…cos in my script i declared ismoving to pixelshifts near my char body..my bad

t4q

2013-04-08 08:14:40

Pixelshift is best for you..

Ian

2013-04-08 08:46:18

You can also look in the chatbox for a message to say you chopped the tree. Another way is looking for the stump color, and when you find it in the place you were chopping that means the tree is gone.

maky369

2013-04-08 09:44:40

Cool, thanks for the help everyone.