SRL Archive - Help

Help with script logic.


Noob King

2012-05-30 21:32:44

Hello, I am new to making scripts for simba, so bare with me. I can't seem to get my script to click on the logs. The first thing I did when I was making this script after reading every tutorial I could find, was a method to click on a maple log, then click add to bonfire. That was working, but after adding my other methods it doesn't want to do it any more. Im assuming the logic of how I put everything together doesn't quite work. Also please forgive me if my script isn't up to the syntax standards.

Here's the script:
program HouseBonfire;
//{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}


Var
X, Y: Integer;
MapleLogs, AddToFire, Butler, NotedMapleLogs, UnNote, ButlerPayment, PayButler: Integer;

Procedure Antiban; //AnitBan By Solidone40
Begin

Case Random(100) Of
1: HoverSkill('firemaking', False);
2: HoverSkill('random', False);
3: Boredhuman;
4: Wait(2500 + random(4500));
5: HoverSkill('magic', False);
6: PickUpMouse;
7: RandomMovement;
8: RandomRClick;
end;
end;

Procedure MiniBreak;
Begin

Case Random (160) Of
1: Wait(40000 + random(7400));
2: Wait(25500 + random(8550));
3: Wait(60040 + random(6759));
4: Wait(20400 + random(2549));
end;
end;

Procedure GetLogs;
begin
UnNote := DTMFromString('mrAAAAHic42BgYFjExMCQDsSPmCDs+UA8GYp3AvF/RgaGf1DMBuR/B9K/gZgRyGYC4hMnTjAEOekzBDsbMKioqjJY29qBxWCYEGAkgGEAAKexFjo='); //DTM For Option To UnNote Logs
ButlerPayment := DTMFromString('mggAAAHicY2NgYFjGxMDQCcQngXg5EDdC2a5ALA/EilDsAcTOQPz//3+grgY4Xr16NcOlS5cYcAFGHBgCAJHqDjM='); //DTM For Butler Asking For Payment
PayButler := DTMFromString('mwQAAAHic42RgYJjGAAH6jBB2PxDfAuIbQMwNxFxAzAbE7FAMAgJQOQ4gZoaqEZBSYNjpKg7G1rZ2DI3pXgwnTpxAwcQARiIwHAAAzIERxQ=='); //DTM For Pressing Pay Butler
if FindDTM(NotedMapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //Detects Noted Maple Logs And Clicks On Them
begin
Mouse(X, Y, 8, 8, True);
Writeln('Found Noted Maple Logs'); //Debugging
if FindColor(x, y, 1516629, MSX1, MSY1, MSX2, MSY2) then // Detects Demon Butler
MMouse(x, y, 4, 4);
Writeln('Found Demon Butler');
if IsUpText('emon') then
Mouse(X, Y, 4, 4, True);
wait(500 + random(100));
if FindDTM(ButlerPayment, X, Y, MCX1, MCY1, MCX2, MCY2) then //Detects Demon Butler Needing Payment
begin
MMouse(X, Y, 5, 5);
if IsUpText('tinue') then
Mouse(X, Y, 0, 0, True);
wait(1000);
if FindDTM(PayButler, X, Y, MCX1, MCY1, MCX2, MCY2) then // Detects Pay Butler Option
MMouse(X, Y, 5, 5);
if IsUpText('tinue') then
wait(500);
end else;
if FindDTM(UnNote, X, Y, MCX1, MCY1, MCX2, MCY2) then // Detects Option To UnNote Logs
begin
MMouse(X, Y, 5,5);
if IsUpText('tinue') then
Mouse(X, Y, 0, 0, True);
Wait(400 + random(200));
TypeSend('26'); //Types 26 in the chatbox for the amount of logs the demon needs to get
MiniBreak; //Waits While Butler Retrives The Logs
end;
end;
end;
Procedure Burn;
begin
MapleLogs := DTMFromString('mlwAAAHicY2dgYMhmYmAoBuIKIE4C4gQgLmeCiPMwMjD8AaoRANJCQMwCxIxA/B8oFm3DCySZcGDcgBEPhgIAxE8F+g=='); //DTM For UnNoted Maple Logs
AddToFire := DTMFromString('mrAAAAHic42BgYEhgZGBwAGInILYD4iAgrgXiLiC2AOKlQLwDiPdDcR8UrwLixUDsZaHA8H+GPBybaQiBsZ4CJ4OTqTIDIcBIAMMAAO8TD6s='); //DTM For Add To Fire Option In The Chat Box

if FindDTM(MapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //If Maple Logs Are Found Left Click Them
begin
Mouse(X, Y, 7, 7, True);
Writeln('Found Maple Logs'); //Debugging
Wait(700 + random(100));
If FindDTM(AddToFire, X, Y, MCX1, MCY1, MCX2, MCY2) then //Detects Add To Bonfire Option And Clicks It
begin
Mouse(X, Y, 15, 15, True);
Writeln('Found Add To Fire Option'); //Debugging
end;
if not FindDTM(MapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //If There Are No Maple Logs Then GOTO GetLogs;
begin
GetLogs;
Writeln('No Maple Logs Found'); //Debugging
end;
end;
end;
begin
SetupSRL;
repeat
Burn;
until not loggedin;
FreeDTM(MapleLogs);
FreeDTM(AddToFire);
//FreeDTM(UnNote);
//FreeDTM(ButlerPayment);
//FreeDTM(PayButler);
end.

Edit: It now will just keep clicking on the maple logs.

bolshak25

2012-05-30 21:39:28

well first off,
UnNote := DTMFromString('mrAAAAHic42BgYFjExMCQDsSPmCDs+UA8GYp3AvF/RgaGf1DMBuR/B9K/gZgRyGYC4hMnTjAEOekzBDsbMKioqjJY29qBxWCYEGAkgGEAAKexFjo='); //DTM For Option To UnNote Logs
ButlerPayment := DTMFromString('mggAAAHicY2NgYFjGxMDQCcQngXg5EDdC2a5ALA/EilDsAcTOQPz//3+grgY4Xr16NcOlS5cYcAFGHBgCAJHqDjM='); //DTM For Butler Asking For Payment
PayButler := DTMFromString('mwQAAAHic42RgYJjGAAH6jBB2PxDfAuIbQMwNxFxAzAbE7FAMAgJQOQ4gZoaqEZBSYNjpKg7G1rZ2DI3pXgwnTpxAwcQARiIwHAAAzIERxQ=='); //DTM For Pressing Pay Butler

if FindDTM(NotedMapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //Detects Noted Maple Logs And Clicks On Them

i dont see you declaring the NotedMapleLogs anywhere, so it wont find them.

Also you keep calling
UnNote := DTMFromString('mrAAAAHic42BgYFjExMCQDsSPmCDs+UA8GYp3AvF/RgaGf1DMBuR/B9K/gZgRyGYC4hMnTjAEOekzBDsbMKioqjJY29qBxWCYEGAkgGEAAKexFjo='); //DTM For Option To UnNote Logs

and many others, but you dont free them until the end of the script. If you call it each time in the procedure, you have to clear it in the procedure or youll build up the memory. So either call them all at the beginning and free them at the end, or call and free them in each procedure

YoHoJo

2012-05-30 21:40:00

First thing you do right now if fix your standards.
It will make it easier for you as well as other to read and understand your code.

After each begin, put 2 spaces for every line, until you reach the end for that begin.MAkes everything A LOT easier to read.


E:
And yeah you should have ONE procedure that loads all of your dtms ONE time and call it only once.
You are calling DTMs over and over without freeing which will cause memory build up and stuff.

bolshak25

2012-05-30 21:46:53

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


Var
X, Y: Integer;
MapleLogs, AddToFire, Butler, NotedMapleLogs, UnNote, ButlerPayment, PayButler: Integer;

Procedure Antiban; //AnitBan By Solidone40
Begin

Case Random(100) Of
1: HoverSkill('firemaking', False);
2: HoverSkill('random', False);
3: Boredhuman;
4: Wait(2500 + random(4500));
5: HoverSkill('magic', False);
6: PickUpMouse;
7: RandomMovement;
8: RandomRClick;
end;
end;

Procedure MiniBreak;
Begin

Case Random (160) Of
1: Wait(40000 + random(7400));
2: Wait(25500 + random(8550));
3: Wait(60040 + random(6759));
4: Wait(20400 + random(2549));
end;
end;

Procedure GetLogs;
begin
UnNote := DTMFromString('mrAAAAHic42BgYFjExMCQDsSPmCDs+UA8GYp3AvF/RgaGf1DMBuR/B9K/gZgRyGYC4hMnTjAEOekzBDsbMKioqjJY29qBxWCYEGAkgGEAAKexFjo='); //DTM For Option To UnNote Logs
ButlerPayment := DTMFromString('mggAAAHicY2NgYFjGxMDQCcQngXg5EDdC2a5ALA/EilDsAcTOQPz//3+grgY4Xr16NcOlS5cYcAFGHBgCAJHqDjM='); //DTM For Butler Asking For Payment
PayButler := DTMFromString('mwQAAAHic42RgYJjGAAH6jBB2PxDfAuIbQMwNxFxAzAbE7FAMAgJQOQ4gZoaqEZBSYNjpKg7G1rZ2DI3pXgwnTpxAwcQARiIwHAAAzIERxQ=='); //DTM For Pressing Pay Butler
if FindDTM(NotedMapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //Detects Noted Maple Logs And Clicks On Them
begin
Mouse(X, Y, 8, 8, True);
Writeln('Found Noted Maple Logs'); //Debugging
if FindColor(x, y, 1516629, MSX1, MSY1, MSX2, MSY2) then // Detects Demon Butler
MMouse(x, y, 4, 4);
Writeln('Found Demon Butler');
if IsUpText('emon') then
Mouse(X, Y, 4, 4, True);
wait(500 + random(100));
if FindDTM(ButlerPayment, X, Y, MCX1, MCY1, MCX2, MCY2) then //Detects Demon Butler Needing Payment
begin
MMouse(X, Y, 5, 5);
if IsUpText('tinue') then
Mouse(X, Y, 0, 0, True);
wait(1000);
if FindDTM(PayButler, X, Y, MCX1, MCY1, MCX2, MCY2) then // Detects Pay Butler Option
MMouse(X, Y, 5, 5);
if IsUpText('tinue') then
wait(500);
end else;
if FindDTM(UnNote, X, Y, MCX1, MCY1, MCX2, MCY2) then // Detects Option To UnNote Logs
begin
MMouse(X, Y, 5,5);
if IsUpText('tinue') then
Mouse(X, Y, 0, 0, True);
Wait(400 + random(200));
TypeSend('26'); //Types 26 in the chatbox for the amount of logs the demon needs to get
MiniBreak; //Waits While Butler Retrives The Logs
end;
end;
end;
Procedure Burn;
begin
MapleLogs := DTMFromString('mlwAAAHicY2dgYMhmYmAoBuIKIE4C4gQgLmeCiPMwMjD8AaoRANJCQMwCxIxA/B8oFm3DCySZcGDcgBEPhgIAxE8F+g=='); //DTM For UnNoted Maple Logs
AddToFire := DTMFromString('mrAAAAHic42BgYEhgZGBwAGInILYD4iAgrgXiLiC2AOKlQLwDiPdDcR8UrwLixUDsZaHA8H+GPBybaQiBsZ4CJ4OTqTIDIcBIAMMAAO8TD6s='); //DTM For Add To Fire Option In The Chat Box

if FindDTM(MapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //If Maple Logs Are Found Left Click Them
begin
Mouse(X, Y, 7, 7, True);
Writeln('Found Maple Logs'); //Debugging
Wait(700 + random(100));
If FindDTM(AddToFire, X, Y, MCX1, MCY1, MCX2, MCY2) then //Detects Add To Bonfire Option And Clicks It
begin
Mouse(X, Y, 15, 15, True);
Writeln('Found Add To Fire Option'); //Debugging
end;
if not FindDTM(MapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //If There Are No Maple Logs Then GOTO GetLogs;
begin
GetLogs;
Writeln('No Maple Logs Found'); //Debugging
end;
end;
end;
begin
SetupSRL;
repeat
Burn;
until not loggedin;
FreeDTM(MapleLogs);
FreeDTM(AddToFire);
//FreeDTM(UnNote);
//FreeDTM(ButlerPayment);
//FreeDTM(PayButler);
end.

fixed the standards, now you should be able to see what is happening.
as you can see, each indent is the new begin line, or what will happen if your if statements are true. you need begins and ends after each if then statement if you want to do 2 things if the statement is true

Noob King

2012-05-30 22:10:27

From: bolshak25
well first off,
UnNote := DTMFromString('mrAAAAHic42BgYFjExMCQDsSPmCDs+UA8GYp3AvF/RgaGf1DMBuR/B9K/gZgRyGYC4hMnTjAEOekzBDsbMKioqjJY29qBxWCYEGAkgGEAAKexFjo='); //DTM For Option To UnNote Logs
ButlerPayment := DTMFromString('mggAAAHicY2NgYFjGxMDQCcQngXg5EDdC2a5ALA/EilDsAcTOQPz//3+grgY4Xr16NcOlS5cYcAFGHBgCAJHqDjM='); //DTM For Butler Asking For Payment
PayButler := DTMFromString('mwQAAAHic42RgYJjGAAH6jBB2PxDfAuIbQMwNxFxAzAbE7FAMAgJQOQ4gZoaqEZBSYNjpKg7G1rZ2DI3pXgwnTpxAwcQARiIwHAAAzIERxQ=='); //DTM For Pressing Pay Butler

if FindDTM(NotedMapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //Detects Noted Maple Logs And Clicks On Them

i dont see you declaring the NotedMapleLogs anywhere, so it wont find them.

Also you keep calling
UnNote := DTMFromString('mrAAAAHic42BgYFjExMCQDsSPmCDs+UA8GYp3AvF/RgaGf1DMBuR/B9K/gZgRyGYC4hMnTjAEOekzBDsbMKioqjJY29qBxWCYEGAkgGEAAKexFjo='); //DTM For Option To UnNote Logs

and many others, but you dont free them until the end of the script. If you call it each time in the procedure, you have to clear it in the procedure or youll build up the memory. So either call them all at the beginning and free them at the end, or call and free them in each procedure


Yeah I didn't add the noted one yet because I was trying to get it to burn logs first, maybe that is my problem.

From: YoHoJo
First thing you do right now if fix your standards.
It will make it easier for you as well as other to read and understand your code.

After each begin, put 2 spaces for every line, until you reach the end for that begin.MAkes everything A LOT easier to read.


E:
And yeah you should have ONE procedure that loads all of your dtms ONE time and call it only once.
You are calling DTMs over and over without freeing which will cause memory build up and stuff.


will do, thankyou.


fixed the standards, now you should be able to see what is happening.
as you can see, each indent is the new begin line, or what will happen if your if statements are true. you need begins and ends after each if then statement if you want to do 2 things if the statement is true


Thank you very much.

Noob King

2012-05-30 22:38:53

Now I have a new problem. It burns logs and everything just fine now, but now when I try to get it to use the noted logs on the butler it just spam clicks the noted logs. I've tried for 2 hours to fix it, but nothing seems to work.

Here is my method for using the noted maple logs on the butler:

function ButlerColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.12, 1.61);

FindColorsSpiralTolerance(MSCX, MSCY, arP, 1845847, MSX1, MSY1, MSX2, MSY2, 12);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;

arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);

for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);

if (X >= 1.52) and (X <= 10.95) and (Y >= 1.16) and (Y <= 8.84) and (Z >= 0.39) and (Z <= 4.16) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;


Procedure GetLogs;
Var
TPA: TPointArray;
CTS, i, Retry: Integer;
begin
if FindDTM(NotedMapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //Detects Noted Maple Logs And Clicks On Them
MMouse(X, Y, 8, 8);
if IsUpText('se') then
Mouse(X, Y, 0, 0, True);
Writeln('Found Noted Maple Logs'); //Debugging
begin
if FindObjTPA(X, Y, ButlerColor, 5, 1, 15, 60, 600, ['Demo']) then // Detects Demon Butler
MMouse(X, Y, 4, 4);
Writeln('Found Demon Butler');
Mouse(X, Y, 0, 0, True);

Noob King

2012-05-31 10:50:44

3 more hours of trying to fix this and I still can't find a solution. Can anyone help me please?

riwu

2012-05-31 10:55:08

Solution:
Procedure GetLogs;
Var
TPA: TPointArray;
CTS, i, Retry: Integer;
begin
if FindDTM(NotedMapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //Detects Noted Maple Logs And Clicks On Them
begin //add a begin since u r performing multiple actions
MMouse(X, Y, 8, 8);
if WaitUpText('se',2000) then //always use waituptext since text dont instantly appear
Mouse(X, Y, 0, 0, True);
Writeln('Found Noted Maple Logs'); //Debugging
end;
//begin //what is this begin for?
if FindObjTPA(X, Y, ButlerColor, 5, 1, 15, 60, 600, ['Demo']) then // Detects Demon Butler
begin
MMouse(X, Y, 4, 4);
Writeln('Found Demon Butler');
Mouse(X, Y, 0, 0, True);
end;
end;

Noob King

2012-05-31 12:27:10

From: riwu
Solution:
Procedure GetLogs;
Var
TPA: TPointArray;
CTS, i, Retry: Integer;
begin
if FindDTM(NotedMapleLogs, X, Y, MIX1, MIY1, MIX2, MIY2) then //Detects Noted Maple Logs And Clicks On Them
begin //add a begin since u r performing multiple actions
MMouse(X, Y, 8, 8);
if WaitUpText('se',2000) then //always use waituptext since text dont instantly appear
Mouse(X, Y, 0, 0, True);
Writeln('Found Noted Maple Logs'); //Debugging
end;
//begin //what is this begin for?
if FindObjTPA(X, Y, ButlerColor, 5, 1, 15, 60, 600, ['Demo']) then // Detects Demon Butler
begin
MMouse(X, Y, 4, 4);
Writeln('Found Demon Butler');
Mouse(X, Y, 0, 0, True);
end;
end;

I will give that a try, thank-you.