SRL Archive - OSR Outdated Tutorials

Help with DTMs, OSRS


Timba

2014-01-22 01:48:21

Hi, I was following YoHoJo's video on DTMs but an error comes up: Exception in Script: File "SRL\SRL.simba" not found at line 3, column 5

Do I use Lape or PascalScript.. and Do I use srl\srl.simba or osr-srl\srl.simba ?

This is the script


Program DTMTest;

{$I SRL\SRL.simba}

var
WizardRobe, X, Y: Integer;




Begin

SetupSRL;

WizardRobe := DTMFromString('mwQAAAHic42RgYHBigmBHIPYDYh8gNgdiMyC2AGJfIH4EVPcGiG8C8WMgfgfE74H4KRDfgWI+7wIgyYiCDRQU0MQIA0YiMBwAAHhZC7o=');

if FindDTM(WizardRobe, X, Y, MIX1, MIX2, MSY1, MSY2) then
begin
WriteLn('You found the item!');
MoveMouse(X, Y, 7, 7);
If IsUpText('ard') then
Mouse(X, X, 0, 0, true);
end;

FreeDTM(WizardRobe);

End.




When I include {$I SRL-OSR\SRL.simba} instead of SRL\SRL.simba get this error: [Error] C:\Simba\Scripts\DTMTest.simba(21:26): Invalid number of parameters at line 21.

Line 21: If IsUpText('ard') then


Help please!

EDITED: All is working fine minus the clicking.

Justin

2014-01-22 01:51:06

Try this:


program DTMTest;
{$I SRL-OSR\SRL.simba}

var
WizardRobe, X, Y: Integer;
begin
SetupSRL;
WizardRobe := DTMFromString('mwQAAAHic42RgYHBigmBHIPYDYh8gNgdiMy C2AGJfIH4EVPcGiG8C8WMgfgfE74H4KRDfgWI+7wIgyYiCDRQU 0MQIA0YiMBwAAHhZC7o=');
if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin
WriteLn('You found the item!');
MMouse(X, Y, 7, 7);
if IsUpText('ard') then
Mouse(X, X, 0, 0, true);
end;
FreeDTM(WizardRobe);
end

Changes:
{$I SRL\SRL.simba} -> {$I SRL-OSR\SRL.simba}
if FindDTM(WizardRobe, X, Y, MIX1, MIX2, MSY1, MSY2) then -> if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then
MoveMouse(X, Y, 7, 7); -> MMouse(X, Y, 7, 7);

Timba

2014-01-22 15:04:56

Hi, thanks for replying. I got a strange error this time..

After starting your script I got this error.

[Error] (1:1): period ('.') expected at line 1
Compiling failed.


so I added a period after end (the last line). After starting the script I got this:

Error: Exception: FindDTMs: DTM[] is not valid. at line 9
The following DTMs were not freed: [SRL - Lamp bitmap, SRL - Book of Knowledge, 2]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Minimap Mask bitmap]

Timba

2014-01-22 17:02:58

Bump still looking for some help :confused:

Sjoe

2014-01-22 17:07:39

From: Timba
Bump still looking for some help :confused:


there's a space in the dtm's string

Timba

2014-01-22 17:15:56

From: Sjoe
there's a space in the dtm's string


Hi, thanks for your help. I backspaced that part in the DTM string but I'm still getting this error

Error: Exception: FindDTMs: DTM[] is not valid. at line 9
The following DTMs were not freed: [SRL - Lamp bitmap, SRL - Book of Knowledge, 2]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Minimap Mask bitmap]


The script compiles.. it just gives me the error when I run it.

Sjoe

2014-01-22 17:16:58

From: Timba
Hi, thanks for your help. I backspaced that part in the DTM string but I'm still getting this error

Error: Exception: FindDTMs: DTM[] is not valid. at line 9
The following DTMs were not freed: [SRL - Lamp bitmap, SRL - Book of Knowledge, 2]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Minimap Mask bitmap]


The script compiles.. it just gives me the error when I run it.


yh sorry, didn't see the second one :) (there were 2 spaces)

Kevin

2014-01-22 17:22:13

Oh I see the issue. There needs to be a '.' at the end of the script.

program DTMTest;
{$I SRL-OSR\SRL.simba}

var
WizardRobe, X, Y: Integer;
begin
SetupSRL;
WizardRobe := DTMFromString('mwQAAAHic42RgYHBigmBHIPYDYh8gNgdiMy C2AGJfIH4EVPcGiG8C8WMgfgfE74H4KRDfgWI+7wIgyYiCDRQU 0MQIA0YiMBwAAHhZC7o=');
if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin
WriteLn('You found the item!');
MMouse(X, Y, 7, 7);
if IsUpText('ard') then
Mouse(X, X, 0, 0, true);
end;
FreeDTM(WizardRobe);
end.


edit: @Sjoe pointed out i was dumb and slow on this issue. gimme a minute.

edit edit: Did you get rid of every space in the dtm string, or just the one?

Timba

2014-01-22 17:33:38

From: Kevin
Oh I see the issue. There needs to be a '.' at the end of the script.

program DTMTest;
{$I SRL-OSR\SRL.simba}

var
WizardRobe, X, Y: Integer;
begin
SetupSRL;
WizardRobe := DTMFromString('mwQAAAHic42RgYHBigmBHIPYDYh8gNgdiMy C2AGJfIH4EVPcGiG8C8WMgfgfE74H4KRDfgWI+7wIgyYiCDRQU 0MQIA0YiMBwAAHhZC7o=');
if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin
WriteLn('You found the item!');
MMouse(X, Y, 7, 7);
if IsUpText('ard') then
Mouse(X, X, 0, 0, true);
end;
FreeDTM(WizardRobe);
end.


edit: @Sjoe pointed out i was dumb and slow on this issue. gimme a minute.

edit edit: Did you get rid of every space in the dtm string, or just the one?



Hi, I got rid of every space and still get the error. I started messing around with the spacing but I'm not sure if that is the issue.
This line is underlined in Orange if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then

Timba

2014-01-22 17:36:47

I think I fixed the DTM error; it is working fine written like this
WizardRobe: =DTMFromString('mwQAAAHic42RgYHBigmBHIPYDYh8gNgdiMy C2AGJfIH4EVPcGiG8C8WMgfgfE74H4KRDfgWI+7wIgyYiCDRQU 0MQIA0YiMBwAAHhZC7o=');

Now I'm getting a new error

[Error] (9:13): Assignment expected at line 9
Line 9: if FindDTM (WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then

EDITED.

Sjoe

2014-01-22 17:36:54

From: Timba
Hi, I got rid of every space and still get the error. I started messing around with the spacing but I'm not sure if that is the issue.
This line is underlined in Orange if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then


Yeah shouldn't have any spaces, try re-making your dtm

Timba

2014-01-22 17:51:34

Thanks for the help so far guys. I fixed/updated the DTM and it does everything it needs to do, except it doesn't click the item. Any ideas?

Sjoe

2014-01-22 19:34:32

From: Timba
Thanks for the help so far guys. I fixed/updated the DTM and it does everything it needs to do, except it doesn't click the item. Any ideas?


tolerance on your mainpoint? Use something like 15
Use the black of the inventory item for your subpoints, since that color is static u can leave tolerance 0 .

Timba

2014-01-22 20:56:16

From: Sjoe
tolerance on your mainpoint? Use something like 15
Use the black of the inventory item for your subpoints, since that color is static u can leave tolerance 0 .


Did just that, and added 15 tolerance to the main point. I used the outline of the item as sub-points but still I'm seeing it doesn't click on the robe.. :s

Kyle

2014-01-22 21:14:03

From: Timba
Did just that, and added 15 tolerance to the main point. I used the outline of the item as sub-points but still I'm seeing it doesn't click on the robe.. :s


Is it moving the mouse to it? Because if it is, then your DTM is fine, probably just a problem with the uptext…

Timba

2014-01-22 21:56:11

From: elfyyy
Is it moving the mouse to it? Because if it is, then your DTM is fine, probably just a problem with the uptext…


Yeah. It moves to the item, then Simba tells me it found it, and then sometimes moves the mouse way down but never clicks.

Sjoe

2014-01-23 09:06:09

From: Timba
Yeah. It moves to the item, then Simba tells me it found it, and then sometimes moves the mouse way down but never clicks.


instead of

if IsUpText('ard') then

use this:

if WaitUptext('ard', 300) then

It could be that you're not giving simba enough time to read the uptext.

Flight

2014-01-23 09:37:16

From: Sjoe
instead of If

IsUpText('ard') then

use this:

if WaitUptext('ard', 300) then

It could be that you're not giving simba enough time to read the uptext.


That's good advice. One of the methods I actively use for determining which part in a piece of code isn't working correctly is step-by-step printing to indicate exactly which stage as been reached. It's hard to explain so I'll use Justin's piece of code as an example.

program DTMTest;
{$I SRL-OSR\SRL.simba}

var
WizardRobe, X, Y: Integer;
begin
SetupSRL;
WizardRobe := DTMFromString('mwQAAAHic42RgYHBigmBHIPYDYh8gNgdiMy C2AGJfIH4EVPcGiG8C8WMgfgfE74H4KRDfgWI+7wIgyYiCDRQU 0MQIA0YiMBwAAHhZC7o=');
if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('A'); // The DTM was found, moving on
MMouse(X, Y, 7, 7);
Writeln('B'); // Mouse was moved to the DTM's X/Y coordinate
if IsUpText('ard') then
begin
Writeln('C'); // Uptext was found
Mouse(X, X, 0, 0, true);
end;
end;
FreeDTM(WizardRobe);
end.

If Simba writes 'A' in the debug then we know the DTM-finding part was successful, if 'B' is written we know the mouse was successfully moved to that coordinate, and if 'C' was written then it's certain the UpText-finding was also successful. If any of these are not printed then we know exactly which part was unsuccessful. Actively debugging is essential when first making a procedure/function.

Edit:
Oh yeah, if UpText is your problem I suggest you take a look at Warpie's OCR Engine for a much more accurate way of reading UpText.

Timba

2014-01-23 17:43:19

From: Flight
That's good advice. One of the methods I actively use for determining which part in a piece of code isn't working correctly is step-by-step printing to indicate exactly which stage as been reached. It's hard to explain so I'll use Justin's piece of code as an example.

program DTMTest;
{$I SRL-OSR\SRL.simba}

var
WizardRobe, X, Y: Integer;
begin
SetupSRL;
WizardRobe := DTMFromString('mwQAAAHic42RgYHBigmBHIPYDYh8gNgdiMy C2AGJfIH4EVPcGiG8C8WMgfgfE74H4KRDfgWI+7wIgyYiCDRQU 0MQIA0YiMBwAAHhZC7o=');
if FindDTM(WizardRobe, X, Y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('A'); // The DTM was found, moving on
MMouse(X, Y, 7, 7);
Writeln('B'); // Mouse was moved to the DTM's X/Y coordinate
if IsUpText('ard') then
begin
Writeln('C'); // Uptext was found
Mouse(X, X, 0, 0, true);
end;
end;
FreeDTM(WizardRobe);
end.

If Simba writes 'A' in the debug then we know the DTM-finding part was successful, if 'B' is written we know the mouse was successfully moved to that coordinate, and if 'C' was written then it's certain the UpText-finding was also successful. If any of these are not printed then we know exactly which part was unsuccessful. Actively debugging is essential when first making a procedure/function.

Edit:
Oh yeah, if UpText is your problem I suggest you take a look at Warpie's OCR Engine for a much more accurate way of reading UpText.







Just read your post Flight, thanks for your help looking into this now.

A, B, and C came out in the log but still didn't click the robe. o_O

Krazy_Meerkat

2014-01-30 02:41:12

You've used the X variable in place of the Y, it's in all of the code posted on this page. This is the line in question:
Mouse(X, X, 0, 0, true);

The Mayor

2014-01-30 05:57:15

From: Krazy_Meerkat
You've used the X variable in place of the Y, it's in all of the code posted on this page. This is the line in question:
Mouse(X, X, 0, 0, true);


Wow, can't believe nobody saw that. Even I didn't see it when I looked at this thread a few days back :(