Log in

View Full Version : Basic questions



sickle
05-24-2012, 12:06 AM
So I'm now dabbling with the idea of making scripts as a total newbie.

I have simple questions. If you would rather direct me to a place where I can look things up, please do. I just didn't find it in my search.

1. Getting it to recognize where it is and start an appropriate action. How do you get it to recognize where it is? Right now, it only recognizes the end places, but not the places on the way.

2. Adding failsafe.

So I am trying to say, if you fail this, then try another. What would be the basic syntax structure for this? Right now I'm trying,

begin
end else
begin
end;

Sorry if they are too simple, but hey I'm just starting to learn now!:stirthepot:

Runaway
05-24-2012, 12:30 AM
1. Getting it to recognize where it is and start an appropriate action. How do you get it to recognize where it is? Right now, it only recognizes the end places, but not the places on the way.

This is a tad vague, so I'll cover a few things.

In most cases with at-bank scripts (gem cutter, fletcher, etc.) you can use inventory functions to find out where you are, or where you want to be. The InvFull function will return true if your inventory is full, or you can use CountItem() and monitors the size of an item stack. If you want to check for a color-change, you can use FindColorTolerance() to search for a specific color in a specific place. All of those will tell you when one piece of the script has ended, and it's time to start with the next.

For walking it's harder to do checks like these, but you can employ color-finding methods to figure out where you are. There is no "real-time" way of analyzing the screen.



2. Adding failsafe.

There are a few efficient ways to do a proper failsafe, but here are my two favorites:


var
i: Integer;
...

for i := 0 to 4 do
begin
// This will go through the same loop 5 times, as each time it hits end;
// it will increase the value of i by 1.
end;

repeat
// This does the same as the above, but uses the Inc() procedure to
// manually add a value of 1 to the integer i.
Inc(i);
until(i > 4);


You can use those in conjunction with if..then..else to make some pretty reliable failsafes.

Hope that helps :)

sickle
05-24-2012, 01:32 AM
Thanks for the prompt reply.

For the recognition of where it is, would you add that under SetUpPlayers procedure?

For the failsafe, how about this? I am trying to say, try it 4 times. In each try, try A, and if that doesn't work try B.
A is the left clicking method
B is the right clicking method

for i := 0 to 3 do

begin
Mouse(x,y,2,2,mouse_Left);
end else
begin
Mouse(x,y,2,2,mouse_right);
ChooseOption('limb');
Inc (i);
end;

Runaway
05-24-2012, 01:36 AM
Thanks for the prompt reply.

So how about this? I am trying to say, try it 4 times. In each try, try A, and if that doesn't work try B.
A is the left clicking
B is the right clicking

for i := 0 to 3 do

begin
Mouse(x,y,2,2,mouse_Left);
end else
begin
Mouse(x,y,2,2,mouse_right);
ChooseOption('limb');
Inc (i);
end;

Yes, that will work properly; although you do not need the Inc(i) in a for..to..do loop as reaching the end will automatically add 1 to i.

sickle
05-24-2012, 01:42 AM
1. So for...to...do loop will include all the way down to both A and B methods?
2. What's the command to make it logout if it fails all 4 times?
3. For the recognition of where it is, would you add that under SetUpPlayers procedure?

Runaway
05-24-2012, 01:52 AM
Oops, I didn't notice that you used an else without an if. After a for..to..do you need a begin and then you close it with an end.


for i := 0 to 3 do
begin
if WaitUptext('rossbow', 1000) then
begin
Mouse(x,y,2,2,mouse_Left);
end else
begin
Mouse(x,y,2,2,mouse_right);
WaitOption('limb', 1000);
end;
end;




1. So for...to...do loop will include all the way down to both A and B methods?
2. What's the command to make it logout if it fails all 4 times?
3. For the recognition of where it is, would you add that under SetUpPlayers procedure?

1) After that fix it will :p
2) the procedure Logout will do the trick.
3) Erm... what do you mean by this?

sickle
05-24-2012, 02:00 AM
How about this then?

for i := 0 to 3 do
begin
if WaitUptext('down', 1000) then
begin
Mouse(x,y,2,2,mouse_Left);
end else
begin
Mouse(x,y,2,2,mouse_right);
WaitOption('limb', 1000);
end;
end;

if (i >= 3) then
Logout;


Will this be failsafe with trying both methods A and B as well as logging out if 4 repeated attempts fail?


For my other question, so basically there are 2 additional locations I want this to recognize, beside the end points (bank and mine). This is because I find that often it gets stuck at these locations, and to make it compatible with SMARTmanager, it will have to be able to start at these places.
So, would I include InvFull and FindColorTolerance methods inside procedure SetUpPlayers? which btw looks like this for me right now:



procedure SetUpPlayers;
begin
if(not(LoggedIn)) then
LoginPlayer;
Wait(2000+Random(1000));
SetAngle(SRL_ANGLE_HIGH);

// maybe add here to recognize the location?


MarkTime(TimePlayer);
end;

Runaway
05-24-2012, 02:12 AM
You can add those in wherever they are needed. Inside or outside of SetupPlayers, just make sure you are logged in and give it a little bit of time to accommodate for any lag that might occur.

sickle
05-24-2012, 02:16 AM
Sorry I keep editing my post to improve my questions, without realizing that you are already working hard to answer my questions at the same time :)

How about this then?

for i := 0 to 3 do
begin
if WaitUptext('down', 1000) then
begin
Mouse(x,y,2,2,mouse_Left);
end else
begin
Mouse(x,y,2,2,mouse_right);
WaitOption('limb', 1000);
end;
end;

if (i >= 3) then
Logout;


Will this be failsafe with trying both methods A and B as well as logging out if 4 repeated attempts fail?

EDIT: I am noticing that the script tries the method A, but never gets to method B, and just fails. Any suggestions?
EDIT2: Why did you choose WaitOption over ChooseOption??