SRL Archive - OSR Help

Ore Counting Cont.


Dynamite

2010-01-31 07:03:50

Well once again my Ore Counting continues to fail :duh:

function WaitUntilMined(Rock: TOre): Boolean;
var
GetAnimationTime, T, CX, CY, IC, P, First, Second: Integer;
begin
Status('Walking to Rock');
MarkTime(t);
SetColorspeed2Modifiers(Rock.Hue, Rock.Sat);
repeat
Wait(10);
if (TimeFromMark(t) >= 6000) then Exit;
until (not FlagPresent) and FindBlackChatMessage('u swi') and
(FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol));
Status('Mining Rock');
IC := InvCount;
MarkTime(t);
repeat
Wait(10);
if (TimeFromMark(t) >= 12000) then Exit;
if (not FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol)) or
(GetAnimation <= 0) then
begin
if (IC = InvCount) then
begin
Second := InvCount;
if (Second > First) then
Begin
Inc(Mined);
Inc(Players[CurrentPlayer].Integers[10]);
Inc(Stats_CustomVars[1]);
case Players[CurrentPlayer].Strings[1] Of
'copper' : Inc(Stats_CustomVars[6]);
'tin' : Inc(Stats_CustomVars[7]);
'iron' : Inc(Stats_CustomVars[8]);
'coal' : Inc(Stats_CustomVars[11]);
'mith' : Inc(Stats_CustomVars[12]);
End;
End;
Wait(750); //was 500
if ClickContinue(false, false) then
begin
Inc(Stats_CustomVars[13]);
TakePic;
end;
Exit
end else
Break;
end;
until (not IC = InvCount) and (GetAnimation <= 0);
Result := True;
end;

and then my MineOre

Function MineOre(which: TOre): boolean;
var x, y, T:integer;
begin
if not LoggedIn then Exit;
Result := true;
FindNormalRandoms;
wait(random(500));
T := GetSystemTime;
while (not FindOre(which, x, y)) do
begin
AntiRandoms;
Case Random(2) Of
0: Wait(200 + Random(500));
1: SleepAndMoveMouse(400 + Random(1000));
End;
If (GetSystemTime - T > 60000) Then
begin
writeln('couldn''t find ore?'); //lol lol lol lol
Result := false;
exit;
end;
end;
if FindOre(which, x, y) then
begin
case Random(10) of
0..8: Mouse(x, y, 0, 0, True);
9:
begin
Mouse(x, y, 0, 0, False);
if (not WaitOption('ine R', 250)) then Exit;
end;
end;
First := InvCount;
WaitUntilMined(which);
end;
Status('Finding Rocks');
end;

The First and Second InvCount are the ones trying to count the ores.
so I have:
if (Second > First) then
Inc(Ores)

So why is that counting too many??
Ores Mined: 180 |
| Loads: 4
…

Cheers for any help again guys.
T~M

WT-Fakawi

2010-01-31 07:20:05

try making a temp var for Stats_CustomVars. Incing Stats_CustomVars is what is going wrong. No idea why though… I recall bumping into exactly the same kind of problem.

Dynamite

2010-01-31 07:22:34

Wait so Inc(Players[CurrentPlayer].Integers[10]);
is getting effected by Inc(Stats_CustomVars[1]);

Weird, cheers Fawk.
Btw, what you mean by Temp var?

WT-Fakawi

2010-01-31 08:08:09

What I recall doing was:
Temp := 0 (local var)
Temp := Stats_CustomVars;
Inc Temp;
Stats_CustomVars := Temp;

Dunno why, but it worked. Drove me insane, that I remember.

Dynamite

2010-01-31 08:56:08

So, Temp:= 0 is set at the beginning of the script
then the other bits are in WaitUntilMined?
Correct?

WT-Fakawi

2010-01-31 11:49:31

nah, Temp := 0 is just to indicate I use a Local Variable for swap.

YoHoJo

2010-01-31 14:23:43

Why do you first have

  IC := InvCount;
if (IC = InvCount) then
begin
Second := InvCount;
if (Second > First) then
Just be simple.
Before you click the rock:

IC:=InvCount;
//AnitBan/ Whatever You Want
//Waits
If InvCount>IC Then True




message is too short

Dynamite

2010-02-02 14:50:37

Sadly it isn't to do with Stats :(
I have tried the way YoHoJo does it in his script but still no luck.
I am now giving the person who fixes and tests to make sure it totally works, $5.

Script is attached.

Cheers
T~M

Blumblebee

2010-02-02 16:42:50

I don't understand how you think that it would count the ore. you have

if Second = PlusOne then

before you count and you set PlusOne as…

First+1

and you never set first so PlusOne = 1 and InvCount = anywhere from 1 to 28.

try this:
function WaitUntilMined(Rock: TOre): Boolean;
var
GetAnimationTime, T, CX, CY, IC, P, Temp: Integer;
TempC, C: Byte;
begin
TempC := InvCount();
Status('Walking to Rock');
MarkTime(t);
SetColorspeed2Modifiers(Rock.Hue, Rock.Sat);
repeat
Wait(10);
if (TimeFromMark(t) >= 6000) then Exit;
until (not FlagPresent) and FindBlackChatMessage('u swi') and
(FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol));
Status('Mining Rock');
MarkTime(t);
repeat
Wait(10);
if (TimeFromMark(t) >= 12000) then Exit;
C := InvCount();
if (C <> tempC) then
Begin
Inc(Mined);
Writeln(Mined);
Inc(Players[CurrentPlayer].Integers[10]);
Inc(Stats_CustomVars[1]);
case Players[CurrentPlayer].Strings[1] Of
'copper' : Inc(Stats_CustomVars[6]);
'tin' : Inc(Stats_CustomVars[7]);
'iron' : Inc(Stats_CustomVars[8]);
'coal' : Inc(Stats_CustomVars[11]);
'mith' : Inc(Stats_CustomVars[12]);
End;
break;
End;
Wait(750); //was 500
if ClickContinue(false, false) then
begin
Inc(Stats_CustomVars[13]);
TakePic;
end;
Exit
end else
Break;
until (GetAnimation <= 0);
Result := True;
end;

you had some stuff really badly done. It is hard to fix what you had without completely rewriting it, but I hope that works now. I don't understand your logic on a lot of what you did. The repeat can be more easily done as a while..do loop and you increasing of variables would be smarter if done with a set constant at the start instead of a case statement everytime.

Dynamite

2010-02-02 16:47:01

I do set First in MineOre btw.
But cheers, I will test now.

Blumblebee

2010-02-02 16:47:55

From: The Man
I do set First in MineOre btw.
But cheers, I will test now.


you declare first locally though…

edit: you have like 8 unused variables in your script too…

Dynamite

2010-02-02 16:48:46

{Global Vars}
Var
PicN, g, Z, AxeDTM, OreDTM, Loads, RestTime, Switched, StartTime, i, Mined,
First, ReportMark : Integer;

Blumblebee

2010-02-02 16:50:59

"
function WaitUntilMined(Rock: TOre): Boolean;
var
GetAnimationTime, T, CX, CY, IC, P, First, Second, // <-----------------------------------
Temp, PlusOne: Integer;
begin
PlusOne := First+1;

thus PlusOne = 1 everytime. ;)

Dynamite

2010-02-02 16:54:10

Omg, I am such an idiot! :s
btw I keep getting:
Line 694: [Error] (24875:1): Identifier expected
begin
Inc(Stats_CustomVars[13]);
TakePic;
end;
Exit;
end else // line 694
Break;
until (GetAnimation <= 0);

Frement

2010-02-02 16:56:12

Missing begin? Paste the whole function.

Blumblebee

2010-02-02 16:56:40

From: The Man
Omg, I am such an idiot! :s
btw I keep getting:
Line 694: [Error] (24875:1): Identifier expected
begin
Inc(Stats_CustomVars[13]);
TakePic;
end;
Exit;
end else // line 694
Break;
until (GetAnimation <= 0);


your standards were off and I didn't notice it, my bad. I think this should compile:

function WaitUntilMined(Rock: TOre): Boolean;
var
GetAnimationTime, T, CX, CY, IC, P, Temp: Integer;
TempC, C: Byte;
begin
TempC := InvCount();
Status('Walking to Rock');
MarkTime(t);
SetColorspeed2Modifiers(Rock.Hue, Rock.Sat);
repeat
Wait(10);
if (TimeFromMark(t) >= 6000) then Exit;
until (not FlagPresent) and FindBlackChatMessage('u swi') and
(FindColorTolerance(cx, cy, Rock.Color, MSCX-65, MSCY-65, MSCX+65, MSCY+65, Rock.Tol));
Status('Mining Rock');
MarkTime(t);
repeat
Wait(10);
if (TimeFromMark(t) >= 12000) then Exit;
C := InvCount();
if (C <> tempC) then
Begin
Inc(Mined);
Writeln(Mined);
Inc(Players[CurrentPlayer].Integers[10]);
Inc(Stats_CustomVars[1]);
case Players[CurrentPlayer].Strings[1] Of
'copper' : Inc(Stats_CustomVars[6]);
'tin' : Inc(Stats_CustomVars[7]);
'iron' : Inc(Stats_CustomVars[8]);
'coal' : Inc(Stats_CustomVars[11]);
'mith' : Inc(Stats_CustomVars[12]);
End;
break;
End;
Wait(750); //was 500
if ClickContinue(false, false) then
begin
Inc(Stats_CustomVars[13]);
TakePic;
end;
until (GetAnimation <= 0);
Result := True;
end;

I just removed the end else and your initial if..then statement.

NCDS

2010-02-02 16:57:17

Take out the 'end' above the 'Exit'.

Dynamite

2010-02-02 17:06:09

Blumblebee, it didn't work :(

Blumblebee

2010-02-02 17:08:51

pm me an account to test and ill fix it.