SRL Archive - OSR Help

Pixel Shift


Leyser

2012-05-22 11:41:13

Could someone please explain in detail what Pixel Shift does and how to use Pixel Shift?

I have used it in my script but it doesent quite work?
What im using:

function IsWoodcutting: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 250, 500) > 750);
end;

~Leyser

putonajonny

2012-05-22 11:47:36

It remembers what colour all the pixels are in a specified box, then X seconds later it returns how many have changed, it is used to see if you are animating

function IsWoodcutting: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195); //this is the box that it is going to check
Result := (AveragePixelShift(PBox, 250{it checks the box every 250 ms}, 500{it stops checking after this long}) > 750);
end;

Abu

2012-05-22 11:50:26

Above explains what it does.

Below explains how to use it:
while IsWoodcutting do
Wait(20);

So while it woodcuts, it will wait.

You put this at the bottom of your procedure so it only starts to woodcut again after it has stopped moving.

iBlank

2012-05-22 11:51:45

Here is a little script you can use to see what the average pixel shift is when you are animating. The script will print what your characters average pixel shift is in the debug box. It is very useful when you are writing a script with pixel shift! I got it from Flight's tutorial on pixel shift.


Program PrintMyPixels;
{$i SRL/srl.simba}

Procedure DebugShiftCount;
Var
PBox: TBox;

Begin
PBox := IntToBox(245, 130, 285, 195);
Writeln(IntToStr(AveragePixelShift(PBox, 250, 500)));
End;

Begin;
SetupSRL();
Repeat
DebugShiftCount;
Until(False);
End.

Leyser

2012-05-22 12:07:22

Where would I put it?
(The: While (IsWoodcutting) do
Wait(20);)?


begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
repeat
ChopTree;
until(False)
end.

iBlank

2012-05-22 12:13:17

From: Leyser
Where would I put it?
(The: While (IsWoodcutting) do
Wait(20);)?


begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
repeat
ChopTree;
until(False)
end.


Put it before your chop tree procedure, then use it in the chop tree procedure. In your code where you click and start chopping the tree, put the below after it.


While IsWoodcutting Do Wait(200+Random(50));

Then, it will check for pixel shift every 200-250 milliseconds and if you are still cutting it will wait. If you are not cutting then it will proceed to locate another tree and chop it.

Leyser

2012-05-22 12:27:36

From: alevere4
Put it before your chop tree procedure, then use it in the chop tree procedure. In your code where you click and start chopping the tree, put the below after it.


While IsWoodcutting Do Wait(200+Random(50));

Then, it will check for pixel shift every 200-250 milliseconds and if you are still cutting it will wait. If you are not cutting then it will proceed to locate another tree and chop it.


Thanks so much!

:D