SRL Archive - OSR Help

Help finding Coal


Alek000

2010-09-01 12:12:25

Well, I'm slowly getting the hang of scripting. I made a simple script to see if I could find Coal in either the bank or in the inventory. I tried both and it couldn't find the Coal. I made 4 different DTMs of the Coal and it could not find it… If someone could look and maybe I messed up something in the script could you give me a hint.

program New;
{.include SRL/SRL.scar}

procedure LoadDTM;
var
Coal: Integer;

begin
Coal := DTMFromString('78DA63D4666260F8CEC8800C14E42518FE036' +
'990E87F20603401AA6160624005103E4C27A32590FF8911BF1A7D' +
'20FF0D01351A40FE2B026A6480FCDF4498C386DFCD001C7E0B77');
end;

procedure FindCoal;
var
X, Y, Coal: Integer;
begin
if FindDTM(Coal, X, Y, MSX1, MSY1, MSX2, MSY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Coal!');
FreeDTM(Coal);
end;

procedure MainLoop;
begin
LoadDTM;
FindCoal;
end;

begin
ClearDebug;
SetupSRL;
MainLoop;
end.

Naum

2010-09-01 12:26:52

Firstly, you need to make Coal a global variable. Right now you have two separate variables, you call the one with nothing loaded.
Secondly, you specified the mainscreen, try the inventory.
Therefore, try this:

program New;
{.include SRL/SRL.scar}

var
Coal: Integer;


procedure LoadDTM;
begin
Coal := DTMFromString('78DA63D4666260F8CEC8800C14E42518FE036' +
'990E87F20603401AA6160624005103E4C27A32590FF8911BF1A7D' +
'20FF0D01351A40FE2B026A6480FCDF4498C386DFCD001C7E0B77');
end;

procedure FindCoal;
var
X, Y : Integer;
begin
if FindDTM(Coal, X, Y, MIX1, MIY1, MIX2, MIY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Coal!');

FreeDTM(Coal);
end;

procedure MainLoop;
begin
LoadDTM;
FindCoal;
end;

begin
ClearDebug;
SetupSRL;
MainLoop;
end.

Alek000

2010-09-01 12:32:05

Hey that worked, thanks Naum. And the reason I had it looking on the main screen was because I tried looking for it in the bank right before I posted on here.

3Garrett3

2010-09-01 13:57:26

From: Alek000
Hey that worked, thanks Naum. And the reason I had it looking on the main screen was because I tried looking for it in the bank right before I posted on here.


If I'm not mistaken there is a MB for bank, but I'm not guaranteeing you anything.

i luffs yeww

2010-09-01 14:34:30

Yes.

Alek000

2010-09-01 14:51:58

Well that worked for the Coal, now I am trying to get it to find Coal, Iron, and Mithril Ore but it just stays on the Coal and says it found the other ore…

program New;
{.include SRL/SRL.scar}

var
Coal, Iron, Mithril: Integer;

procedure LoadDTM;
begin
Coal := DTMFromString('78DA63D4666260F8CEC8800C14E42518FE036' +
'990E87F20603401AA6160624005103E4C27A32590FF8911BF1A7D' +
'20FF0D01351A40FE2B026A6480FCDF4498C386DFCD001C7E0B77');

Iron := DTMFromString('78DA6364606260F8C1C8800C2C9524C1344C9' +
'49103A806A40E0530A1AAE105F23F31E257C30CE4BF21A0E60F90' +
'F58A809A0F8C186EC66A0E1B7E370300161E0861');

Mithril := DTMFromString('78DA635CC1C4C0600AC448C0C22284E13F906' +
'604E2FF40C0B801286F8DAA868101C26784F218B702F9BA04D4AC' +
'06F2D509A85902E4AB12503303C83723C21C47FC6A006F860BEE');
end;

procedure FindOre;
var
X, Y : Integer;

begin
if FindDTM(Coal, X, Y, MSX1, MSY1, MSX2, MSY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Coal!');
FreeDTM(Coal);
Wait(1000 + Random(1000));

if FindDTM(Iron, X, Y, MSX1, MSY1, MSX2, MSY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Iron!');
FreeDTM(Iron);
Wait(1000 + Random(1000));

if FindDTM(Mithril, X, Y, MSX1, MSY1, MSX2, MSY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Mithril!');
FreeDTM(Mithril);
Wait(1000 + Random(1000));
end;

procedure MainLoop;

begin
LoadDTM;
FindOre;
end;

begin
ClearDebug;
SetupSRL;
MainLoop;
end.

Sorry for all of the noobish questions… I have a weird way of learning lol

Frement

2010-09-01 14:59:27

Why are you using DTMs to find them?

Just use TPAs etc, I think theres a good tutorial on this, let me find it.

EDIT: Here http://villavu.com/forum/showthread.php?t=49067

Alek000

2010-09-01 15:10:12

From: Frement
Why are you using DTMs to find them?

Just use TPAs etc, I think theres a good tutorial on this, let me find it.

EDIT: Here http://villavu.com/forum/showthread.php?t=49067


Frankly it's because I'm afraid to get into TPAs right now. As you can see, I'm having trouble with DTMs let alone understanding TPAs

3Garrett3

2010-09-01 15:20:54

You should add a wait after the MMouse, that might do something. But it should move the mouse if it isn't finding the DTM

Alek000

2010-09-01 15:22:50

It's barely moving the mouse, it will move barely but still stay on the Coal and it shows that it is finding the correct DTMs.

3Garrett3

2010-09-01 15:24:48

There is probably too much tolerance on the main points of the ores.

Rich

2010-09-01 16:07:54

When I use DTMs I usually have a tolerance of around 15.

Alek000

2010-09-01 16:41:57

Yep that's what did it, thank you all for helping :)

Naum

2010-09-01 16:44:50

From: Alek000
Yep that's what did it, thank you all for helping :)


If you need to ask questions or anything - add me on msn. Or PM me

Alek000

2010-09-01 16:55:44

Added Naum

3Garrett3

2010-09-01 18:48:17

From: Alek000
Added Naum


You have me too, don't hesitate :)

lordsaturn

2010-09-01 22:12:53

Oh yeah me 4

Bebe

2010-09-02 03:26:39

From: Alek000
Well that worked for the Coal, now I am trying to get it to find Coal, Iron, and Mithril Ore but it just stays on the Coal and says it found the other ore…

program New;
{.include SRL/SRL.scar}

var
Coal, Iron, Mithril: Integer;

procedure LoadDTM;
begin
Coal := DTMFromString('78DA63D4666260F8CEC8800C14E42518FE036' +
'990E87F20603401AA6160624005103E4C27A32590FF8911BF1A7D' +
'20FF0D01351A40FE2B026A6480FCDF4498C386DFCD001C7E0B77');

Iron := DTMFromString('78DA6364606260F8C1C8800C2C9524C1344C9' +
'49103A806A40E0530A1AAE105F23F31E257C30CE4BF21A0E60F90' +
'F58A809A0F8C186EC66A0E1B7E370300161E0861');

Mithril := DTMFromString('78DA635CC1C4C0600AC448C0C22284E13F906' +
'604E2FF40C0B801286F8DAA868101C26784F218B702F9BA04D4AC' +
'06F2D509A85902E4AB12503303C83723C21C47FC6A006F860BEE');
end;

procedure FindOre;
var
X, Y : Integer;

begin
if FindDTM(Coal, X, Y, MSX1, MSY1, MSX2, MSY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Coal!');
FreeDTM(Coal);
Wait(1000 + Random(1000));

if FindDTM(Iron, X, Y, MSX1, MSY1, MSX2, MSY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Iron!');
FreeDTM(Iron);
Wait(1000 + Random(1000));

if FindDTM(Mithril, X, Y, MSX1, MSY1, MSX2, MSY2) then
MMouse(X, Y, 3, 3)
else
Writeln('Could not find Mithril!');
FreeDTM(Mithril);
Wait(1000 + Random(1000));
end;

procedure MainLoop;

begin
LoadDTM;
FindOre;
end;

begin
ClearDebug;
SetupSRL;
MainLoop;
end.

Sorry for all of the noobish questions… I have a weird way of learning lol


You need "end else" and I believe a "begin"…"end;" between each

Alek000

2010-09-02 11:49:19

From: Bebe
You need "end else" and I believe a "begin"…"end;" between each


It works now, idk what putting a "end else' or "begin"…"end" would do. I can give it a try though.


Anyone know a good way to use SuperHeat without using anything from Magic.scar? I don't really want to use that, I kind of want to make my own functions/procedures because that's how I learn. By doing it instead of just taking what I need from other places like includes. I'm in the process of trying to learn TPAs btw.

Bebe

2010-09-02 11:57:19

You answered your own question… TPAs :)

Alek000

2010-09-02 12:11:43

From: Bebe
You answered your own question… TPAs :)


I was afraid you were going to say that lol

i luffs yeww

2010-09-02 13:55:53

If you do the end else and what not, you have to add Free(DTM); if it finds it as well. How you have it is fine, your standards are just off.


program New;
{.include SRL/SRL.scar}

var
Coal, Iron, Mithril: Integer;

procedure LoadDTM;
begin
Coal := DTMFromString('78DA63D4666260F8CEC8800C14E42518FE036' +
'990E87F20603401AA6160624005103E4C27A32590FF8911BF1A7D' +
'20FF0D01351A40FE2B026A6480FCDF4498C386DFCD001C7E0B77');

Iron := DTMFromString('78DA6364606260F8C1C8800C2C9524C1344C9' +
'49103A806A40E0530A1AAE105F23F31E257C30CE4BF21A0E60F90' +
'F58A809A0F8C186EC66A0E1B7E370300161E0861');

Mithril := DTMFromString('78DA635CC1C4C0600AC448C0C22284E13F906' +
'604E2FF40C0B801286F8DAA868101C26784F218B702F9BA04D4AC' +
'06F2D509A85902E4AB12503303C83723C21C47FC6A006F860BEE');
end;

procedure FindOre;
var
x, y: Integer;
begin
if(FindDTM(Coal, x, y, MSX1, MSY1, MSX2, MSY2))then
MMouse(x, y, 3, 3)
else
Writeln('Could not find Coal!');
FreeDTM(Coal);
Wait(1000 + Random(1000));
if(FindDTM(Iron, x, y, MSX1, MSY1, MSX2, MSY2))then
MMouse(x, y, 3, 3)
else
Writeln('Could not find Iron!');
FreeDTM(Iron);
Wait(1000 + Random(1000));
if(FindDTM(Mithril, x, y, MSX1, MSY1, MSX2, MSY2))then
MMouse(x, y, 3, 3)
else
Writeln('Could not find Mithril!');
FreeDTM(Mithril);
Wait(1000 + Random(1000));
end;

procedure MainLoop;
begin
LoadDTM;
FindOre;
end;

begin
ClearDebug;
SetupSRL;
MainLoop;
end.

Not anything big, but it makes the nests more understandable at a first glance. If you were to use begin..end..end..else's, it wouldn't free the DTMs if they were found. How it is now is fine.