SRL Archive - First Scripts

Herb cleaner (Doesn't work, need help.)


Powerfrog

2012-03-03 17:39:30

Hi this is my first script and I've created it by following tutorials.

Sadly it doesn't seem to do what i want it to, and I'm not sure why.

program DeclarePlayers;
{$DEFINE SMART}
{$i srl/srl.simba}

{$IFDEF SMART}
{$i srl/srl/misc/paintsmart.simba}
{$ENDIF}


procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; // Username
Players[0].Pass := ''; // Password
Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
Players[0].Active := True; // Set to true if you want to use Player 0
Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
end;


procedure FindAndClean();
var
DTM, x, y : Integer;
begin
DTM := DTMFromString('mlwAAAHicY2dgYAgB4iAgTgDiaCD2B2IXIPYBYjUglgJiBSDWgWJVIJYFYmsDKQYuLx4gi4nBy0aRgS9RgIEngg8qhhsw4sFQAAB+FwYo'); // Grimy guam
if(FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
Mouse(x, y, 5, 5, mouse_Left);
Wait(RandomRange(20, 100));
end;
FreeDTM(DTM);
end;
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
end.

It loads SMART and logs in fine. But it doesn't do anything after that even though i (think i) told look for the grimy herbs and left click them.

Can anyone see where i went wrong?

Failure

2012-03-03 18:06:02

You never called your procedure in your main loop?

begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
end.

begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
FindAndClean; //This is your cleaning Procedure
end.

Striken

2012-03-03 18:21:08

What do you mean? You have to call your procedure as 'Failure' said above.

Getdropped

2012-03-03 19:02:22

In useing functions and procedures you need to call then to the main program bascially. The main program looks like this:

program cleanthoseherbs;

this is where you put the procedures and functions that you plan to call below
It will skip this part until the things inside of here are called


begin <—– it jumps down to here when you run teh script so you need to call the things ^
loop and all the functions and procedures in here along with the defining smart etc.
You need to add the FindAndClean; in here
end.

hope that helps clear some things up just add your procedure in here

the flea

2012-03-03 19:19:37

ok if this code is all yours then its not such a bad start well done to you.

the reason your script doesn't do anything is because in your main loop you haven't told it to do anything.

your main loop is this section here
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
end.
what you have done is correct in terms of setting up the script however after this you need to add in a loop of tasks that your script will repeat. to do this you use

repeat
//stuff here
until();

in your case you will want it to look like this:
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
repeat
FindandClean;
until(false);
end.

the until(false); means it will repeat the FindandClean procedure an infinate amount of times. This is obviously not a recommended practice. Perhaps you should read through this thread it explains basic scripting pretty nicely http://villavu.com/forum/showthread.php?t=58935

Getdropped

2012-03-03 19:24:18

From: the flea
ok if this code is all yours then its not such a bad start well done to you.

the reason your script doesn't do anything is because in your main loop you haven't told it to do anything.

your main loop is this section here
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
end.
what you have done is correct in terms of setting up the script however after this you need to add in a loop of tasks that your script will repeat. to do this you use

repeat
//stuff here
until();

in your case you will want it to look like this:
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
repeat
FindandClean;
until(false);
end.

the until(false); means it will repeat the FindandClean procedure an infinate amount of times. This is obviously not a recommended practice. Perhaps you should read through this thread it explains basic scripting pretty nicely http://villavu.com/forum/showthread.php?t=58935


Ya basically what I said he just used more actual code I was just trying to give the the basic concepts ;) hopes these help you I like the effort that you gave in trying to learn code. Best of luck.

Powerfrog

2012-03-03 21:39:12

From: the flea
ok if this code is all yours then its not such a bad start well done to you.

the reason your script doesn't do anything is because in your main loop you haven't told it to do anything.

your main loop is this section here
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
end.
what you have done is correct in terms of setting up the script however after this you need to add in a loop of tasks that your script will repeat. to do this you use

repeat
//stuff here
until();

in your case you will want it to look like this:
begin
{$IFDEF SMART}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
repeat
FindandClean;
until(false);
end.

the until(false); means it will repeat the FindandClean procedure an infinate amount of times. This is obviously not a recommended practice. Perhaps you should read through this thread it explains basic scripting pretty nicely http://villavu.com/forum/showthread.php?t=58935


Thank you, and everyone else that helped. (Gosh, this forum is a LOT more helpful than other ones I've used in the past. I expected 'GTFO NOOB LOLZ')

"code is all yours" I actually hi-jacked most of it and re-purposed it from the very thread you linked me! :D I read it all first of course and thought i had the idea, but i didn't seem to catch the part about calling my procedure into action.

It's late so I'll be sure to try that tomorrow morning, and then i get onto the banking, other herbs and possibly even buying/selling GE if I'm feeling adventurous. Should be fun. :)

While i have your attention, can i ask if creating an intractable paint is possible in Simba? For the user to select their herbs they wish to clean. I know the alternative is to just make them select which they want in the actual code, but I'd like to be flashy. :)

Thanks in advance!