SRL Archive - First Scripts

First Script, First Post, Can't figure out what is wrong. It almost works...


evenesence21

2014-09-21 23:29:25

:fiery:

program MonsterWarlord;

{$I SRL-6/SRL.Simba}

procedure Heal;

var
HforHealth:Integer;

begin

SetupSRL;

HforHealth := DTMFromString('mggAAAHicY2NgYGABYk4o5mBAAHYozQtl80L5T58+ZXB0dGSIjIxk+PTpE0NtbS2Dt7c3Ay7AiANDAACyfwn+');

If FindDTM(HforHealth) then

begin;

WriteLN ('Yay We Found It!');
Mouse (320, 460, 7, 7, True);

FreeDTM(HforHealth);

end;

end;







begin
MoveMouse (78, 423);
Wait (600);
HoldMouse (78, 423, 1);
Wait (500);
ReleaseMouse (78, 423, 1);
Wait(4000);
MoveMouse (355, 370);
Wait (500);
HoldMouse (355, 370, 1);
Wait(500);
ReleaseMouse (355, 370, 1);
Wait(1000);
MoveMouse (372, 496);
Wait (3000);
HoldMouse (371, 496, 1);
Wait (500);
ReleaseMouse (371, 496, 1);
Wait (1500);

Heal;


end;



—————————-



Please no negative comments, I've spent almost 16 hours learning, reading, and writing this. Thank you, hopefully, someone can help.

Thank you,

Michelle

Turpinator

2014-09-21 23:36:24

What doesnt work?

Clarity

2014-09-21 23:36:51

Could you explain what you are trying to do in this script, and what is going wrong when you try to run it?

Also, you can use
 tags to surround simba code to make it easier to read:

[simba]program MonsterWarlord;

{$I SRL-6/SRL.Simba}

procedure Heal;

var
HforHealth:Integer;

begin

SetupSRL;

HforHealth := DTMFromString('mggAAAHicY2NgYGABYk4o5mBAAHYozQtl80 L5T58+ZXB0dGSIjIxk+PTpE0NtbS2Dt7c3Ay7AiANDAACyfwn+ ');

If FindDTM(HforHealth) then

begin;

WriteLN ('Yay We Found It!');
Mouse (320, 460, 7, 7, True);

FreeDTM(HforHealth);

end;

end;







begin
MoveMouse (78, 423);
Wait (600);
HoldMouse (78, 423, 1);
Wait (500);
ReleaseMouse (78, 423, 1);
Wait(4000);
MoveMouse (355, 370);
Wait (500);
HoldMouse (355, 370, 1);
Wait(500);
ReleaseMouse (355, 370, 1);
Wait(1000);
MoveMouse (372, 496);
Wait (3000);
HoldMouse (371, 496, 1);
Wait (500);
ReleaseMouse (371, 496, 1);
Wait (1500);

Heal;


end;

evenesence21

2014-09-21 23:43:21

I play a game called Monster Warlord. I'm making this so it can click to "Battle". But a Heal Screen "pops up" when your health gets too low. (Why I can't only click and repeat the east part of the script.

I decided to write into the script a DTM, that would allow the script to realize when the health screen has popped up. DTM works perfect. Once it realizes that the DTM is there, I used the Mouse (320, 460, 7, 7) so that it can click the health box.

The error I am getting when I compile is:

Exception in Script: Don't know which overloaded method to call with params (Int32) at line 15, column 6

Clarity

2014-09-21 23:50:06

I don't know the protocol for using SRL-6 with non-Runescape games, but SRL-6 is designed specifically for RuneScape and you may have to tweak things to use it with other games. Other members will elaborate no doubt.

Anyways, with your error, you need to specify the area to search in the FindDTM() function.

The correct parameters for findDTM are findDTM(DTM you want to find, x, y, area to search);

x and y are integers (leave as x and y), and area to search is a TBox. After findDTM runs and finds the DTM, the coordinate location will be saved to x and y.

If you simply want to know if the DTM is present without the x and y, you can use DTMExists(); which returns true or false.

Hope that helps, good luck! :)

evenesence21

2014-09-21 23:55:02

DTM Exist ! Omg that's amazing! That makes it so much easier! That's exactly what I want. :D

I just want the script to know if the DTM is present. I guess I can throw DTM Exist into an If, Then, Statement. If DTM exist, Mouse(coordinates).

Yayyy. :D

For the SRL, I am unsure of what to put of if I need it at all. I have trouble following as it seems there are many different things to type there. :/

Clarity

2014-09-21 23:56:47

From: evenesence21
DTM Exist ! Omg that's amazing! That makes it so much easier! That's exactly what I want. :D

I just want the script to know if the DTM is present. I guess I can throw DTM Exist into an If, Then, Statement. If DTM exist, Mouse(coordinates).

Yayyy. :D

For the SRL, I am unsure of what to put of if I need it at all. I have trouble following as it seems there are many different things to type there. :/


reformatted with new procedure:

program MonsterWarlord;
{$I SRL-6/SRL.Simba}

procedure Heal;
var
HforHealth: Integer;
begin
SetupSRL;
HforHealth := DTMFromString('mggAAAHicY2NgYGABYk4o5mBAAHYozQtl80 L5T58+ZXB0dGSIjIxk+PTpE0NtbS2Dt7c3Ay7AiANDAACyfwn+ ');
if dtmExists(HforHealth) then
begin
WriteLN('Yay We Found It!');
Mouse(320, 460, 7, 7, True);
FreeDTM(HforHealth);
end;
end;

begin
MoveMouse(78, 423);
Wait(600);
HoldMouse(78, 423, 1);
Wait(500);
ReleaseMouse(78, 423, 1);
Wait(4000);
MoveMouse(355, 370);
Wait(500);
HoldMouse(355, 370, 1);
Wait(500);
ReleaseMouse(355, 370, 1);
Wait(1000);
MoveMouse(372, 496);
Wait(3000);
HoldMouse(371, 496, 1);
Wait(500);
ReleaseMouse(371, 496, 1);
Wait(1500);
Heal;
end;

When posting other code, it's generally nice to have it adhere to proper standards. If you don't want to do this yourself, you can use the formatter.sex extension available in View -> Extensions. Then enable the extension, then select Parser -> Format Script. Note that this deletes commented code.

evenesence21

2014-09-22 00:03:52

I tried my hardest to make the code look pretty(standard). :D

This is my first one. :)

I have to add a lot more to it, but this is a great start.

I learned a lot from YouTube, only trouble is that the video's are old and a lot of the code has changed, so it's difficult to memorize and then have to relearn it. :/

:D

Clarity

2014-09-22 00:05:10

From: evenesence21
I tried my hardest to make the code look pretty(standard). :D

This is my first one. :)

I have to add a lot more to it, but this is a great start.

I learned a lot from YouTube, only trouble is that the video's are old and a lot of the code has changed, so it's difficult to memorize and then have to relearn it. :/

:D


A good idea, eventually I want to come out with a new set of video tutorials that are more current :)
Good luck with your first script, feel free to post with any more questions!

evenesence21

2014-09-22 00:50:05

Thank you, you are very nice. :)

I will try plugging this new code in now. :D

Clarity

2014-09-22 01:51:30

Actually, I was wrong about DTMExists. I've now found that "exists" doesn't mean if it can find it onscreen, but means if it has been loaded into memory. So it will always return true.
Use "if findDTM(HForHealth, x, y, desiredAreaHere) then" and specify a specific area to look in as I mentioned above.

Sorry about the mixup!

evenesence21

2014-09-22 02:02:02

Haha. :)

Funny you should mention that.
I've been running it, scrathching my head, wondering why it always runs! Hahaha. Oh, this is so much fun! :D I wish I would of started learning script long ago! :D

Clarity

2014-09-22 02:18:48

From: evenesence21
Haha. :)

Funny you should mention that.
I've been running it, scrathching my head, wondering why it always runs! Hahaha. Oh, this is so much fun! :D I wish I would of started learning script long ago! :D

It's never too late :) Looking forward to seeing more of you around!

evenesence21

2014-09-22 02:25:34

Yes of course :D
I'm going to make a basic script for this game for now. Then I'm going to see what other more complicated stuff I can do! :D
The only thing is I don't know what else I can use script for. :o

evenesence21

2014-09-22 02:28:36

From: Clarity
Actually, I was wrong about DTMExists. I've now found that "exists" doesn't mean if it can find it onscreen, but means if it has been loaded into memory. So it will always return true.
Use "if findDTM(HForHealth, x, y, desiredAreaHere) then" and specify a specific area to look in as I mentioned above.

Sorry about the mixup!


I don't understand. :x

why do I have to have x and y? And by desired area, you mean the coordinates at which it finds the DMT?

Clarity

2014-09-22 02:38:59

From: evenesence21
I don't understand. :x

why do I have to have x and y? And by desired area, you mean the coordinates at which it finds the DMT?

findDTM(dtm, x, y, area);

dtm: the DTM you want to find
x and y: if the find function finds the DTM, it will assign the x and y coordinates of the found DTM to x and y.
area: the area that you want the function to search inside for the DTM. This is declared using a TBox variable.

SRL-6 has predefined areas such as mainscreen.getBounds(). If you are not playing RuneScape, you will need to set your own area, like so:
IntToBox(X1, Y1, X2, Y2)

evenesence21

2014-09-22 02:51:43

This DTM thing is going to kill me. xD

It's the most complicated thing I've tried to learn so far.

I'll figure it out eventually haha. :P

I'm a visual learner, so trying to understand by reading is like teaching a fish to breathe with out water LOL. xD
Grrr…

Thank you. :)

Oh and I took out the SRL from the script it didn't seem to be needed.

evenesence21

2014-09-22 03:10:11

Line 11: if findDTM(HforHealth x, y, 100, 460, 140, 480) then

—Exception in Script: Operator expected at line 11, column 25


>:o
so frustrating


edit: I was missing a "," after HforHealth!!!!
Small mistakes are always the hardest to find.
Now time to see if it works hahahah

Clarity

2014-09-22 03:38:21

From: evenesence21
Line 11: if findDTM(HforHealth x, y, 100, 460, 140, 480) then

—Exception in Script: Operator expected at line 11, column 25


>:o
so frustrating


edit: I was missing a "," after HforHealth!!!!
Small mistakes are always the hardest to find.
Now time to see if it works hahahah


Should be findDTM(HforHealth, x, y, IntToBox(100, 460, 140, 480))

bonsai

2014-09-22 05:40:10

From: evenesence21
This DTM thing is going to kill me. xD

It's the most complicated thing I've tried to learn so far.


Yohojo video

evenesence21

2014-09-22 17:22:32

From: Clarity
Should be findDTM(HforHealth, x, y, IntToBox(100, 460, 140, 480))


I'll try that now :)

evenesence21

2014-09-22 17:23:51

From: bonsai
Yohojo video


That's actually the video I got the idea from in the first place. The SRL doesn't work with my game.
I don't know what should be put there instead. :/
That's was the original problem. :)