PDA

View Full Version : Help with my script



America19
09-09-2014, 01:35 AM
So I am creating my first script which will be private and when it's supposed to collect an item it does it only once then just stops I was following the mayors scripting tutorial.

The Mayor
09-09-2014, 01:40 AM
So I am creating my first script which will be private and when it's supposed to collect an item it does it only once then just stops I was following the mayors scripting tutorial.

Post your code so we can see what you did wrong.

America19
09-09-2014, 02:04 AM
I'm on my phone atm but can I send it too you in a pm because it's supposed to be private but once I get this one fully working I will create a public script

Brandon
09-09-2014, 02:26 AM
I'm on my phone arm bUT can I send it too you in a pm because it's supposed to be private but once I get this one fully working I will create a public script

I will not post crucial code that you have PM'd me but I'll post parts of it that will give you problems.. I have to clean my villavu inbox..


Anyway, you have:

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);

if isMouseOverText(['....'], 500) then
begin
fastClick(MOUSE_RIGHT);
chooseOption.select(['....']);

if(tabBackpack.count() = 28) then //do you see the problem here? if ... then.. do what?
//should be doing something here.. otherwise remove the if-then statement.

end;
end;



Next you have:


procedure loadDTMs();
var
someDTM: integer; //I changed the names here so no one will know what your actual code is..
anotherDTM: integer;
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');
end; //outside of this function, you cannot access any of the DTM's inside of it.



Do you see the problem there? You have a memory leak. Why? Because those DTM's are local to that function. That means that as soon as the "end;" statement is reached, you won't be able to access those DTM's.. You won't be able to free them either..


You have two choices here:


1. Make them global variables:


var
someDTM: integer;
anotherDTM: integer;

procedure loadDTMs();
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');
end;

procedure freeDTMs();
begin
FreeDTM(someDTM);
FreeDTM(anotherDTM);
end;

begin
SetupSRL;
//do other stuff..
LoadDTMs(); //call only once.

AddOnTerminate('FreeDTMs'); //right before your script terminates, run the FreeDTMs function.
end.



OR

2. Return them or use a global Array..



var
DTMs: TIntegerArray;

Function loadDTMs(): TIntegerArray;
var
someDTM, anotherDTM: Integer;
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');

Result := [someDTM, anotherDTM];
end;

procedure freeDTMs();
var
I: Integer;
begin
For I := 0 To High(DTMs) do
FreeDTM(DTMs[I]);
end;

begin
SetupSRL;
//do other stuff..
DTMs := LoadDTMs(); //call only once.

AddOnTerminate('FreeDTMs'); //right before your script terminates, run the FreeDTMs function.
end.



I'd stick to option 1 for now.. when you get better, use option 2 (global array). I did not compile or test your script. That's just what I saw from taking a quick glance at it.


EDIT:

Another thing I noticed is that you have:


findColorsSpiralTolerance(..., colorSetting(2, 0.28, 2.13));


Where did you get those numbers? I hope they aren't random and that you used ACA to get them. If those numbers work for you, ignore what I said about them.


Next you have:


repeat
somefunc();//repeat until we have 27 ..stuff..
if tabBackPack.isFull() then
begin
runToBank();
findBank();
depositstuff();
end;
until(false);


I'm only mentioning this because of the comment that says repeat until 27.. That's not what that loop says. It says repeat infinitely so the comment is misleading but the code is correct.

America19
09-09-2014, 03:52 AM
I will not post crucial code that you have PM'd me but I'll post parts of it that will give you problems.. I have to clean my villavu inbox..


Anyway, you have:

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);

if isMouseOverText(['....'], 500) then
begin
fastClick(MOUSE_RIGHT);
chooseOption.select(['....']);

if(tabBackpack.count() = 28) then //do you see the problem here? if ... then.. do what?
//should be doing something here.. otherwise remove the if-then statement.

end;
end;



Next you have:


procedure loadDTMs();
var
someDTM: integer; //I changed the names here so no one will know what your actual code is..
anotherDTM: integer;
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');
end; //outside of this function, you cannot access any of the DTM's inside of it.



Do you see the problem there? You have a memory leak. Why? Because those DTM's are local to that function. That means that as soon as the "end;" statement is reached, you won't be able to access those DTM's.. You won't be able to free them either..


You have two choices here:


1. Make them global variables:


var
someDTM: integer;
anotherDTM: integer;

procedure loadDTMs();
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');
end;

procedure freeDTMs();
begin
FreeDTM(someDTM);
FreeDTM(anotherDTM);
end;

begin
SetupSRL;
//do other stuff..
LoadDTMs(); //call only once.

AddOnTerminate('FreeDTMs'); //right before your script terminates, run the FreeDTMs function.
end.



OR

2. Return them or use a global Array..



var
DTMs: TIntegerArray;

Function loadDTMs(): TIntegerArray;
var
someDTM, anotherDTM: Integer;
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');

Result := [someDTM, anotherDTM];
end;

procedure freeDTMs();
var
I: Integer;
begin
For I := 0 To High(DTMs) do
FreeDTM(DTMs[I]);
end;

begin
SetupSRL;
//do other stuff..
DTMs := LoadDTMs(); //call only once.

AddOnTerminate('FreeDTMs'); //right before your script terminates, run the FreeDTMs function.
end.



I'd stick to option 1 for now.. when you get better, use option 2 (global array). I did not compile or test your script. That's just what I saw from taking a quick glance at it.


EDIT:

Another thing I noticed is that you have:


findColorsSpiralTolerance(..., colorSetting(2, 0.28, 2.13));


Where did you get those numbers? I hope they aren't random and that you used ACA to get them. If those numbers work for you, ignore what I said about them.


Next you have:


repeat
somefunc();//repeat until we have 27 ..stuff..
if tabBackPack.isFull() then
begin
runToBank();
findBank();
depositstuff();
end;
until(false);


I'm only mentioning this because of the comment that says repeat until 27.. That's not what that loop says. It says repeat infinitely so the comment is misleading but the code is correct.
Thanks and i tried fixing the DTM stuff but i keep on getting duplicate entry so idk but its late ima go to bed but maybe tomorrow can we talk?

The Mayor
09-09-2014, 06:09 AM
I'm on my phone atm but can I send it too you in a pm because it's supposed to be private but once I get this one fully working I will create a public script

I don't think anyone is going to take a not-even-working script out of the help section and run it on 50 accounts :p It's good to post scripting questions in public so others can also learn, and you can get feedback from more than one person.

America19
09-09-2014, 09:22 PM
I will not post crucial code that you have PM'd me but I'll post parts of it that will give you problems.. I have to clean my villavu inbox..


Anyway, you have:

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);

if isMouseOverText(['....'], 500) then
begin
fastClick(MOUSE_RIGHT);
chooseOption.select(['....']);

if(tabBackpack.count() = 28) then //do you see the problem here? if ... then.. do what?
//should be doing something here.. otherwise remove the if-then statement.

end;
end;



Next you have:


procedure loadDTMs();
var
someDTM: integer; //I changed the names here so no one will know what your actual code is..
anotherDTM: integer;
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');
end; //outside of this function, you cannot access any of the DTM's inside of it.



Do you see the problem there? You have a memory leak. Why? Because those DTM's are local to that function. That means that as soon as the "end;" statement is reached, you won't be able to access those DTM's.. You won't be able to free them either..


You have two choices here:


1. Make them global variables:


var
someDTM: integer;
anotherDTM: integer;

procedure loadDTMs();
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');
end;

procedure freeDTMs();
begin
FreeDTM(someDTM);
FreeDTM(anotherDTM);
end;

begin
SetupSRL;
//do other stuff..
LoadDTMs(); //call only once.

AddOnTerminate('FreeDTMs'); //right before your script terminates, run the FreeDTMs function.
end.



OR

2. Return them or use a global Array..



var
DTMs: TIntegerArray;

Function loadDTMs(): TIntegerArray;
var
someDTM, anotherDTM: Integer;
begin
someDTM := DTMFromString('....');
anotherDTM := DTMFromString('....');

Result := [someDTM, anotherDTM];
end;

procedure freeDTMs();
var
I: Integer;
begin
For I := 0 To High(DTMs) do
FreeDTM(DTMs[I]);
end;

begin
SetupSRL;
//do other stuff..
DTMs := LoadDTMs(); //call only once.

AddOnTerminate('FreeDTMs'); //right before your script terminates, run the FreeDTMs function.
end.



I'd stick to option 1 for now.. when you get better, use option 2 (global array). I did not compile or test your script. That's just what I saw from taking a quick glance at it.


EDIT:

Another thing I noticed is that you have:


findColorsSpiralTolerance(..., colorSetting(2, 0.28, 2.13));


Where did you get those numbers? I hope they aren't random and that you used ACA to get them. If those numbers work for you, ignore what I said about them.


Next you have:


repeat
somefunc();//repeat until we have 27 ..stuff..
if tabBackPack.isFull() then
begin
runToBank();
findBank();
depositstuff();
end;
until(false);


I'm only mentioning this because of the comment that says repeat until 27.. That's not what that loop says. It says repeat infinitely so the comment is misleading but the code is correct.

The first part with the then statement if i remove that i get this error Error: Found unexpected token "end", expected "Then" at line 74
Secondly when it runs half way through i get this ---- TRSGameTab.__initTabs(): Setup gametab properties then after that it does nothing

The Mayor
09-09-2014, 09:28 PM
If only you posted your code :p

America19
09-09-2014, 09:33 PM
i can probabaly figure out the first error but idk what could possibly cause the second one