PDA

View Full Version : My error, please help.



Maver
10-22-2006, 11:34 AM
Hi, I've had a looky at a couple of tuts on scar today, and have had a bit of look at a few scar scripts and have decided that I should at least try to make my own.

Basically, I'm trying to lead up to being able to make my own script that kills the lesser demon in the wizards tower by searching for its color, left clicking it and using the ClickText('text', co-ord, co-ord, co-ord, co-ord).

Well, I haven't started that, but I have been playing with my noob account in lumby. Just outside of the caslte to the north is a ferm. I have myself standing just near it, and am trying to get it to click it, and then find the text 'examine' in the little list that pops up.

This is my code:

program myFirstScript;
{.include Squig.txt}

procedure click;
begin
Clickmouse(264, 105, true) //right clicks on the leaf
ClickText('Examine', 5, 5, 508, 376) //hopefully it finds the emaine. However, error compiling so unsure.
end;

begin
click;
end.


And this is the error i get

Line 10: [Error] (7124:1): Invalid number of parameters in script C:\Program Files\SCAR 2.03\Scripts\myFirstScript.scar

Chances are that this is a silly little thing, and far to obvious to you. But I've never learnt anything that comes close to this sort of coding.

EDIT: I don't really like making my first post on here asking for help, but I'm lost. Oh well.

Home
10-22-2006, 11:50 AM
program myFirstScript;
{.include Squig.txt}

procedure click;
begin
Clickmouse(264, 105, true) //right clicks on the leaf
ClickText('Examine', 5, 5, 508, 376,True) //hopefully it finds the emaine. However, error compiling so unsure.
end;

begin
SetupSquig;
click;
end.

Maver
10-22-2006, 11:56 AM
Thank you so much! Only thing now is I get another error message.

[Runtime Error] : Exception: Canvas does not allow drawing in line 347 in script C:\Program Files\SCAR 2.03\includes\Squig.txt

I dunno, maybe I wasn't meant to use Squig. I'll go have a look and check. But, if anyone knows and is reading this, please post. I'm not really the best at these sorts of things.

IronTeapot
10-22-2006, 04:38 PM
I get that error all the time. Just drag the cross hairs onto your window again, so that your see the bounding box enclose around it. Easy fix.

lardmaster
10-22-2006, 04:55 PM
well, very good, but i have a few suggestions

you should have it find a color and the click it, because the way you have it, it will just click on a certain spot on the screen. but hey, you may want that.

my other suggestion is instead of including squig, include SRL/SRL.scar. at the begining of your script, type the line "setupsrl". this will setup srl for you ;) lol. then instead of clickmouse, use the command
"mouse(xcoord,ycoord,the randomness in the x direction,rand in y direction, left button?);"
so in your case it would be


program myFirstScript;
{.include srl/srl.scar}

procedure click;
begin
mouse(264, 105, 3,3,true); //right clicks on the leaf, this will click randomly withing a 6 by 6 box.
popup('Examine'); //this is one of many srl option clicking procedures, and it is very simple so that is good for you.

end;

begin
setupsrl;
click;
end.


you can figure out how to find the color of the leaf on your own if you want to, or i can tell you :).

good luck learning scar!

CamHart
10-22-2006, 07:18 PM
Get to know the commands and what their names are and what the names means... I'm always willing to help, though im probably not the best helper around. Just PM me with problems as i dont get on msn much unless if someone asks me to.

Maver
10-22-2006, 11:26 PM
well, very good, but i have a few suggestions

you should have it find a color and the click it, because the way you have it, it will just click on a certain spot on the screen. but hey, you may want that.

my other suggestion is instead of including squig, include SRL/SRL.scar. at the begining of your script, type the line "setupsrl". this will setup srl for you ;) lol. then instead of clickmouse, use the command
"mouse(xcoord,ycoord,the randomness in the x direction,rand in y direction, left button?);"
so in your case it would be


program myFirstScript;
{.include srl/srl.scar}

procedure click;
begin
mouse(264, 105, 3,3,true); //right clicks on the leaf, this will click randomly withing a 6 by 6 box.
popup('Examine'); //this is one of many srl option clicking procedures, and it is very simple so that is good for you.

end;

begin
setupsrl;
click;
end.


you can figure out how to find the color of the leaf on your own if you want to, or i can tell you :).

good luck learning scar!


Thank you very much! I was going to use SRL includes, but I couldn't really find any tutorials that cover it.

However, I've actually started to make a new program called lesserStomper! It simply clicks the spell book to open the list of spells, clicks windstrike and then finds the lesser. It's supposed to click on it, but i'm having trouble doing it. I think it might be because of so many people were attacking it yesterday, so we had lots of red and blue splashes.

I'm considering making two procedures, one for getting up to the part of clicking windstrike (or whatever spells....) and then another for finding the lesser. Just to make the code a bit neater.

Here's what I have coded so far.

program lesserStomper;
{.include squig.txt}

procedure initiatespell;
var x,y : integer;
var x1,y1 : integer;
begin
if(Findcolortolerance(x,y,3901099,730,174,754,202, 5))Then{color of book to
open spell list}
wait(1000+random(200))
clickmouse(x,y,true) {opens spell list}
wait (150+random(400))
if(Findcolortolerance(x,y,1907996, 580,218,599,232, 5))then {finds wind
strike}
wait(599+random(386))
movemousesmooth(x,y)
wait(1000+random(400))
clickmouse(x,y,true) {clicks windstrike}
Findcolortolerance(x1,y1,2359,274, 123, 283, 290, 20) {supposed to look for lesser.}
movemousesmooth(x1,y1)
clickmouse(x1,y1,true) {supposed to click lesser}
end;


begin
Setupsquig;
initiatespell;
end.


Also, i'll try to change it all so I can use SRL.

I Pick Axes
10-22-2006, 11:53 PM
Replace squig with SRL. Replace SetupSquig with SetupSRL. Replace Clickmouse with Mouse. It's that simple =P.

Maver
10-23-2006, 06:15 AM
Alright. Now my code runs flawlessly... Up untill where it is supposed to find the lesser, het the cords and then click on it.

Instead of looking for the lesser after it has clicked on wind strike, it just floats up into the very top left corner of the runescape window.

Findcolortolerance(x1,y1,2359,274, 123, 283, 290, 20) {supposed to look for lesser.}
mouse(x1,y1,5,5,true); {supposed to click lesser}

EDIT: I just noticed. I have the second set of the x/y values stuffed up and it wasn't search in the cage for him.

Is there a function in SRL where it clicks on the colour, rather then returning the x,y, value of the colour, then clicking there? Because this lesser moved just before, and it missed it by.... not even half a cm.

Thank you for all of your help so far. Hopefully I'll be able to do the same soon!

PS, I finally got around to using the SRL mouse click. Also, i've been looking through the SRl scripters manual -it's huge!

Boreas
10-23-2006, 06:22 AM
Could you post a screen shot of the demon?

Maver
10-23-2006, 06:45 AM
heres a picture of the lesser, and it also says where to stand. note the compas direction (pretty much east) and that you're completely zoomed out. http://img246.imageshack.us/img246/3650/lesserud3.gif (http://imageshack.us)

Is there anyway in SRL to make it do that? make it face east and zoom right out? Also, do you think it would be worth making a bitmap for the lesser? Would that help with recognizing it when there are a heap of splashes?

Also, could someone just generally comment on this script so far. How detectable would it be(ignore the fact it has no randoms)? Is there better ways to code it? Should I add something?

EDIT: Here is my code so far. I'm going to add some antiban features soon, and then fix up the program so it attacks him every time he pops up, untill a random comes or something... Or untill a user specified amount of spells has been cast.


program lesserStomper;

{.include SRL/SRL.scar}

procedure initiatespell;
var x,y : integer;
var x1,y1 : integer;
begin
if(Findcolortolerance(x,y,3901099,730,174,754,202, 5))
Then{color of book to
open spell list}
wait(1000+random(200))
mouse(x,y,5,5,true); {opens spell list}
wait (150+random(400))
if(Findcolortolerance(x,y,1907996, 580,219,598,233, 5))
then {finds windstrike}
wait(599+random(386))
movemousesmooth(x,y)
wait(1000+random(400))
mouse(x,y,5,5,true) {clicks windstrike}
Findcolortolerance(x1,y1,1715311,1, 1, 402, 246, 20) {supposed to look for lesser.}
mouse(x1,y1,5,5,true); {supposed to click lesser}
end;
begin //main loop
SetupSRL
initiatespell;

end.

Also, how would I make it if it doesn't find the lesser, it continues searching for it untill it pops up?
in pseudo code, it'd look something like this

if lesser found, attack
else, wait(3000) and search again
(loop)



That might not be too clear, but I hope someone knows what I'm on about.

I find scar scripting so much more enjoyable to learn then, say, Python or Java. It's so much easier and you get instant gratification.

Boreas
10-23-2006, 01:21 PM
To face east, MakeCompass('e')
To zoom out, HighestAngle

A bitmap for the demon, probably not. I wrote a movement detection thing that worked for dragons, I'll take about that later.

Yes you should break up into more procedures.

To look until you find:

repeat
wait(sometime);
until lesserfound;

//then click xy

That will check every sometime if the lesser is there. Make lesserfound a function that checks if the lesser is there, and if it is it returns true and makes x,y where it found the lesser.

For finding the lesser:
I wouldn't suggest bitmaps, dtms, or colors on something that moves and turns like that, unless you had really good ones.

Since it is in a small area, and is the only thing moving in that area besides drops appearing and the spells attacking from other players (which are on him anyway), it's worth giving motion detection a try. Attached you will find my motion detector. To use it, save it in your includes folder and use {.include Prometheus.scar}. Then put in your procedures section function FindColorChangeGridEx(xposex,yposex,which:integer) :boolean;
begin
case which of
//This is for when you want no exceptions in the box //
1: //
begin //
if (xposex = xposex) and (yposex=yposex) then //
result:=true; //
end; //
2: //
begin //
if (xposex = xposex) and (yposex=yposex) then //
result:=true; //
end;


//add more exceptions here

else writeln('Error in detector exceptions');
end;
end;
Except change the 2 part to something that moves the mouse to xposex,yposex and checks if the uptext is lesser or whatever. If it is, then result=true.

Then use FCCG to find the lesser
FindColorChangeGrid(x1, y1, x2, y2, d, giveuptime, whichex: integer);
x1,y1 x2,y2 is the area the lesser could be in.
make d smaller to check in more places. it sets up a grid of points d apart
x x x
x x x
x x x
So make sure they are close enough together that the lesser will definitely hit at least one of them.
Giveuptime is how long to look for before making FCCGfound false and giving up
whichex is which exception(s) to use, so put 2

To make it keep checking like I said before, use

marktime(mark);
repeat
tallywacker:=tallywacker+1;
FindColorChangeGrid(x1, y1, x2, y2, d, giveuptime, whichex: integer);
wait(sometime);
until( FCCGfound) or (TimeFromMark(Mark)>(someothertime));

if not(fccgfound) then
begin
writeln('could not find lesser after '+inttostr(tallywacker)+' times');
//do something here like
end;

if fccgfound then
begin
writeln('found lesser after '+inttostr(tallywacker)+' times');
//click it at x,y
end;

//then click xy

Maver
10-24-2006, 09:34 AM
Wouza... Thank you very much!

I'm now creating a new script which kills cows, buries the bones and then cooks the meat when it has a full load. I'll definately think about using some of those things you told me about.

Boreas
10-24-2006, 05:32 PM
Np. That sounds cool, pm if you need anything else.