SRL Archive - OSR Help

First Script Problems(InvCount)


Total

2012-03-22 19:08:27

Ok, so I have just begun to try and write my first script with the help of YoHoJo's video tutorial but am having trouble, specifically with the InvCount function. From my understanding it takes the amount of items in your inventory and allows you to store it as a variable, but for me it seems to just be clicking on my inventory. Here is my procedure and where it is going wrong.

Procedure ClickOre;
Var
X, Y, PlusOne, RockCounter: Integer;
Begin
PlusOne:= InvCount + 1;
X:= MSCX;
Y:= MSCY;
Writeln('Looking for ore.');
If FindObjTPA(X, Y, OreColor, 5, 1, 10, 10, 1, ['Mi', 'ine']) Then
Begin
GetMousePos(X, Y);
Writeln('Clicking on ore.');
Mouse(X, Y, 5, 5, True);
End;
Repeat
MarkTime(RockCounter)
If InvCount=PlusOne Then
Writeln('Got dat ore.');
Until (InvCount=Plusone) Or (TimeFromMark(RockCounter) > 5000)
End;

If I run it like above, It will just click on my inventory tab and not do anything. If I remove "PlusOne:= InvCount + 1;" it will work up until the loop. Is this a problem with my loop or what am I doing wrong?

Also, is there any other way to check if you have completed an action like mining an ore?

Abu

2012-03-22 19:18:26

I'm not sure what you're doing wrong but obviously something. Go over YoHoJo's tutorial and make sure you are doing everything correctly

And for:
From: TotalKillz

Also, is there any other way to check if you have completed an action like mining an ore?


You can use Pixelshift

Total

2012-03-22 20:34:31

Oh, well I got the pixelshift to work but still don't know whats wrong with my old way. I guess it doesn't really matter because I assume pixelshift is faster anyway. Thanks.

Wyn

2012-03-22 20:41:25

program new;
{$i srl/srl.simba}
var i :integer;
begin
SetupSRL;
ActivateClient;
for i := 1 to 28 do
if ExistsItem(i) then Writeln(''+ ToStr(i) );
end.

How I usually check the inventory for changes.

Total

2012-03-22 21:15:08

Is there any way you can go into a bit more detail? I see the it checks which invy slot has items in it but how can you make it so that it goes to the next rock when the invy slot fills?

NKN

2012-03-23 13:36:53

    Repeat
MarkTime(RockCounter)
If(InvCount > 0) Then
Writeln('Got dat ore.');
Until (InvCount > 0) Or (TimeFromMark(RockCounter) > 5000)
End;
Checks if inventory has anything in it, is that what you needed?

Abu

2012-03-23 13:42:25

I think you need to change this line:
  If InvCount=PlusOne Then
To this:
  If PlusOne Then

Because you have already defined PlusOne as having one more item in your inventory.


I think so anyway….

Total

2012-03-23 14:51:38

I found out that the reason the original code wasn't working is because I wasn't running in SMART. Once I ran it in SMART it worked perfectly. Does anyone know why? In the video tutorial he was running it in a browser so not sure what was wrong.

Thanks for all the help also, you might see a lot of questions coming from me because I feel the need to script. :p

putonajonny

2012-03-23 14:52:18

Procedure ClickOre;
Var
X, Y, PlusOne, RockCounter: Integer;
Begin
PlusOne:= InvCount + 1;
X:= MSCX;
Y:= MSCY;
Writeln('Looking for ore.');
If FindObjTPA(X, Y, OreColor, 5, 1, 10, 10, 1, ['Mi', 'ine']) Then
Begin
GetMousePos(X, Y);
Writeln('Clicking on ore.');
Mouse(X, Y, 5, 5, True);
End
Else
begin //This is a failsafe incase it doesn't click a rock, might fix things
WriteLn('could not find a rock');
Exit;
end;
Repeat
MarkTime(RockCounter)
If InvCount=PlusOne Then
Writeln('Got dat ore.');
Until (InvCount=Plusone) Or (TimeFromMark(RockCounter) > 5000)
End;


edit: just saw your post lol

NKN

2012-03-23 15:03:46

You forgot to drag the crosshairs over the browser?

Total

2012-03-23 16:27:18

From: nkn
You forgot to drag the crosshairs over the browser?


Nope, I set it to the client. Dunno, but now I got another problem lol. Trying to get it to bank but the stairs in lumby castle are the same color as the whole castle pretty much, so I can't use ACA. Should I make a DTM for the stairs or what can I do?

Kyle Undefined

2012-03-23 16:35:31

The stairs are brown, and the castle is grey, right? Are you using the correct graphic settings?

Total

2012-03-23 16:54:57

The stairs have a brown railing, but the railing matches the wood panel on the side of the castle, and I'm on safe mode with max brightness/low settings. Here is a pic.
http://gyazo.com/4dacbe0555fc13ddeb95de9901461a86

Kyle Undefined

2012-03-23 16:56:34

Using a good ACA color will be able to handle this :) Silents spinner script works perfectly fine :)

Total

2012-03-23 16:59:46

Ah ok thanks. Will keep trying to find the right color. Should I try a light brown or what?

Kyle Undefined

2012-03-23 17:25:30

Yeah, use the brown railing for the stairs :)

mitch10513

2012-09-16 10:28:21

Well I know this is sort of gravedigging, but I know what the problem is. You need to be in a browser for it to work. Your code was fine, it was just that you were running it in a client.

I had the same problem.

J J

2012-09-17 16:00:28

From: mitch10513
Well I know this is sort of gravedigging, but I know what the problem is. You need to be in a browser for it to work. Your code was fine, it was just that you were running it in a client.

I had the same problem.

Don't bump topics that are 6 months old :P Big gravedig. I'm pretty sure he has realised the mistake as he has become a SRL Member now :)

KeepBotting

2012-09-20 20:52:50

From: J J
Don't bump topics that are 6 months old :P Big gravedig. I'm pretty sure he has realised the mistake as he has become a SRL Member now :)

Thought the same thing. However I'll throw this in: use DidRedClick to make sure you've clicked on the rock in the first place, in addition to checking when/if you've mined it.