SRL Archive - OSR Help

Why ISN'T IT running


Mort

2010-03-12 19:23:30

Hi Guys 'n Girls,

Made these simple SendArrowWait script to solve a maze where the price can be put at 4 spots. You can't see where it is from start and sorta have to try find it by checking all the spots. Anyway, I made the scripts go to the spots and they work decently, with a few failures from time to time as the maze moves JUST a tiny bit sometimes. I can live with that for now though.

My problem is when I'm trying to combine my procedures it run the Fail and Profit procedures even though the colors in the given sqaure aint 'TRUE'. I will link my script:



begin
UpperLeft
if(FindColor(x, y, 255, 509, 147, 533, 168))then;
Begin
Fail
end;
if(FindColor(x, y, 3895377, 747, 188, 792, 247))then;
Begin
Profit
end;
UpperRight
end.

Any suggestions?

TRiLeZ

2010-03-12 19:28:14

There shouldn't be any semi-colons after "then".
However, there should be semicolons after profit, fail and UpperLeft.

Fix:

begin
UpperLeft;
if(FindColor(x, y, 255, 509, 147, 533, 168))then
Begin
Fail;
end;
if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
Begin
Profit;
end;
UpperRight;
end.

x[Warrior]x3500

2010-03-12 19:30:09

also, please read up on the coding "standards" that SRL has.

i luffs yeww

2010-03-12 20:47:05

And for single actions after an if..then statement, no begin..end is needed. ;)

Nava2

2010-03-12 23:41:25

From: i luffs yeww
And for single actions after an if..then statement, no begin..end is needed. ;)


But depending who you ask, and how far into development you are, some would suggest putting begin and end on at all times. :rolleyes:

Mort

2010-03-13 07:12:36

I started scripting 4 weeks ago, so I'm still quite fresh. But thanks for the quick respons. Been reading alot of beginner guides, but seems I ain't done with that yet.

Thanks for the help it works now. Gonna go spend alot of time perfecting it now. :)

+rep TRiLeZ

Mort

2010-03-13 07:41:29

Just a small extra question if you guys don't mind. :-)

If it runs the Profit command I would like it to start the whole script over, but if it doesn't profit after running UpperLeft, UpperRight and Lowers (which means it failed due to hitting an obstacle or something like that) it should only repeat these scripts. So far my combined procedures looks like this:


begin
EnterMaze
UpperLeft;
if(FindColor(x, y, 255, 509, 147, 533, 168))then
Begin
Fail;
end;
if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
Begin
Profit;
end;
wait(500+Random(50));
UpperRight;
if(FindColor(x, y, 255, 509, 147, 533, 168))then
Begin
Fail;
end;
if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
Begin
Profit;
end;
wait(500+Random(50));
Lowers;
if(FindColor(x, y, 255, 509, 147, 533, 168))then
Begin
Fail;
end;
if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
Begin
Profit;
end;
wait(500+Random(50));
end.

Don't know if this is asking too much, but would be nice if you elitists at Scar could at least point me in the right direction! ;-)

i luffs yeww

2010-03-13 07:46:01

You COULD use a goto.. x] haha but I'm pretty sure those are frowned upon. I dunno.

Other than that, you could just do..


if(FindColor(blahblahblah))then
begin
Profit;
EnterMaze;
end;

(That's assuming EnterMaze is the start procedure. :p) Sorry if that's not what you want at all, I'm pretty tired right now.

Mort

2010-03-13 08:02:24

EnterMaze is just the first script to run, which is needed to be run after Profit, so I'll get a loop going. If that made any sense xD

@i luffs yeww: Np mate! :P

i luffs yeww

2010-03-13 08:03:13

Can you post the whole script? :p

Naum

2010-03-13 08:25:24

Maybe try using a label and goto?

http://villavu.com/forum/showthread.php?t=54339&highlight=Label+GoTo

Mort

2010-03-13 09:46:47

I made a minor modification to the script so EnterMaze will only run if a color is present and then run the EnterMaze after each 'go-to' scripts and have the entire script repeat infinite. Thanks for the help through it all though guys :)