SRL Archive - First Scripts

Need help with my first script


jamesayo

2015-04-08 13:55:32

I decided to start learning Simba by attempting to make a power chopper and fletcher.
The woodcutting part works decently enough, but I can't get the fletching part to run, whenever it gets to that part in the debug it says '—- TRSGameTab.__initTabs(): Setup gametab properties' and will just sit there til I exit the script. Any help is appreciated.
Here's the fletching portion:
procedure fletchLogs();
var
logsDTM, x, y: integer;

begin
if not isLoggedIn() then
exit;

logsDTM := DTMFromString('mrAAAAHic42BgYGBhYmD4w8jAwA+k2YGYF4gZgFgAiP8DxScB8WQo7gHiWUA8E4h7gbgPiL0sFBmqk80Y4t21GGLcNIGaGRlasqwYfK2UwDQhwEgAwwAAvWUNNw==');

if findDTM(logsDTM, x, y, tabBackPack.getBounds()) then
begin
mouse(x, y, 3, 3, MOUSE_MOVE);
if isMouseOverText(['raft', 'ogs']) then
fastClick(MOUSE_LEFT);

if toolScreen.isOpen(3000) then
toolScreen.select('Knife');

if productionScreen.isOpen(5000) then
productionScreen.selectBox(1);
productionScreen.clickStart();

if progressScreen.isOpen(5000) then
begin
repeat
antiPattern();
wait(1000);
until (not progressScreen.isOpen());
end;
end;
end;

and here's the entire script:
Program ayoPowerFletcher;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //change this
password := ''; //and this
isActive := true;
isMember := false;
end
currentPlayer := 0;
end;

procedure antiPattern();
begin
if (not isLoggedIn()) then
exit;

case random(300) of
1: hoverSkill(SKILL_WOODCUTTING);
2: sleepAndMoveMouse(5000 + random(1000));
3: smallRandomMouse();
4: randomRClickItem();
5: pickUpMouse();
6: boredHuman();
7: mouseOffClient(OFF_CLIENT_RANDOM);
8: hoverRandomSkill();
9:
end;
end;

procedure clickTree();
var
x, y: integer;
begin
if (not isLoggedIn()) then
exit;
if (tabBackPack.isFull()) then
exit;
if mainscreen.findObject(x, y, 925721, 11, ['vergreen'], MOUSE_RIGHT) then
begin
chooseOption.select(['verg', 'gree']);
tabBackPack.waitForShift(5000);
end;
end;

procedure fletchLogs();
var
logsDTM, x, y: integer;

begin
if not isLoggedIn() then
exit;

logsDTM := DTMFromString('mrAAAAHic42BgYGBhYmD4w8jAwA+k2YGYF4gZgFgAiP8DxScB8WQo7gHiWUA8E4h7gbgPiL0sFBmqk80Y4t21GGLcNIGaGRlasqwYfK2UwDQhwEgAwwAAvWUNNw==');

if findDTM(logsDTM, x, y, tabBackPack.getBounds()) then
begin
mouse(x, y, 3, 3, MOUSE_MOVE);
if isMouseOverText(['craft', 'ogs']) then
fastClick(MOUSE_LEFT);

if toolScreen.isOpen(3000) then
toolScreen.select('Knife');

if productionScreen.isOpen(5000) then
productionScreen.selectBox(1);
productionScreen.clickStart();

if progressScreen.isOpen(5000) then
begin
repeat
antiPattern();
wait(1000);
until (not progressSCreen.isOpen());
end;
end;
end;




// main loop
begin
clearDebug(); // Clear the debug box
smartEnableDrawing := true; // So we can draw on SMART
setupSRL(); // Load the SRL include files
declarePlayers(); // Set up your username/pass

if not isLoggedIn() then // If player isn't logged in then
begin
players[currentPlayer].login(); // Log them in
wait(randomRange(2000, 6000));
minimap.setAngle(MM_DIRECTION_NORTH); // Make compass north and angle high
mainScreen.setAngle(MS_ANGLE_HIGH);
exitTreasure(); // Exit treasure hunter
end;
repeat
repeat
clickTree();
until tabBackPack.isFull();
fletchLogs();
until false;



end.

3Garrett3

2015-04-08 14:05:23

It sounds like it isn't finding the logDTM in your inventory. I always set the logs to action bar "1" and then you only need to press 1 to open the fletching menu. Try that and see if the rest of your code will work with it?

jamesayo

2015-04-08 17:10:36

Thanks, that fixed it!
Do you think my DTM values are off or why it couldn't find it in my invy?

3Garrett3

2015-04-08 17:14:20

From: jamesayo
Thanks, that fixed it!
Do you think my DTM values are off or why it couldn't find it in my invy?


It sounds to me like either the DTM didn't work properly or SRL didn't properly open your backpack tab. Something was keeping it from getting past the "if FindDTM" part though. I'm glad changing it up a bit worked. It should still work with a DTM though if you want to keep trying. You can add a few "writeln('Found DTM');" etc through that part though if you want to be sure what is happening. That's what I do in my scripts when I'm trying to figure out why something is broken.

jamesayo

2015-04-08 20:36:55

I tried updating the DTM and adding in writeLns.
Here's the new fletching part:
procedure fletchLogs();
var
logsDTM, x, y: integer;

begin
if not isLoggedIn() then
exit;

logsDTM := DTMFromString('mggAAAHicY2NgYDBlZGDQA2JHILYHYl1GiFg5ENcCcQ4Q1wBxIRDnA7GPpSJDQ5oFUCcjQ6SzOpgd6qDKgAsw4sAQAAC8Pgh6');
writeLn('Log''s DTM has been converted!');
if findDTM(logsDTM, x, y, tabBackPack.getBounds()) then
begin
writeLn('Logs have been found in the invy!');
mouse(x, y, 3, 3, MOUSE_MOVE);
if isMouseOverText(['raft', 'ogs']) then
fastClick(MOUSE_LEFT);
writeLn('Logs selected!')
//actionBar.clickSlot(1);

if toolScreen.isOpen(3000) then
toolScreen.select('Knife');
writeLn('Knife selected!');

if productionScreen.isOpen(5000) then
writeLn('production Screen is open!');
wait(randomRange(500, 1000));
productionScreen.selectBox(1);
writeLn('Arrow shafts selected!');
wait(randomRange(500, 1000));
productionScreen.clickStart();
writeLn('We are fletching!')

if progressScreen.isOpen(5000) then
begin
repeat
antiPattern();
wait(randomRange(1000, 1500));
until (not progressScreen.isOpen());
end;
inc(loadsDone);
writeLn('Whole inventory fletched!')
end;
end;
the debug box gets spammed with 'Log's DTM has been converted!'

3Garrett3

2015-04-08 20:53:41

From: jamesayo
I tried updating the DTM and adding in writeLns.
Here's the new fletching part:
procedure fletchLogs();
var
logsDTM, x, y: integer;

begin
if not isLoggedIn() then
exit;

logsDTM := DTMFromString('mggAAAHicY2NgYDBlZGDQA2JHILYHYl1GiFg5ENcCcQ4Q1wBxIRDnA7GPpSJDQ5oFUCcjQ6SzOpgd6qDKgAsw4sAQAAC8Pgh6');
writeLn('Log''s DTM has been converted!');
if findDTM(logsDTM, x, y, tabBackPack.getBounds()) then
begin
writeLn('Logs have been found in the invy!');
mouse(x, y, 3, 3, MOUSE_MOVE);
if isMouseOverText(['raft', 'ogs']) then
fastClick(MOUSE_LEFT);
writeLn('Logs selected!')
//actionBar.clickSlot(1);

if toolScreen.isOpen(3000) then
toolScreen.select('Knife');
writeLn('Knife selected!');

if productionScreen.isOpen(5000) then
writeLn('production Screen is open!');
wait(randomRange(500, 1000));
productionScreen.selectBox(1);
writeLn('Arrow shafts selected!');
wait(randomRange(500, 1000));
productionScreen.clickStart();
writeLn('We are fletching!')

if progressScreen.isOpen(5000) then
begin
repeat
antiPattern();
wait(randomRange(1000, 1500));
until (not progressScreen.isOpen());
end;
inc(loadsDone);
writeLn('Whole inventory fletched!')
end;
end;
the debug box gets spammed with 'Log's DTM has been converted!'


So since it's not making it to "Logs have been found in the invy!" We can say for sure it's not finding the logs. Try having the script debug your backpack location (Writeln(toStr(tabBackpack.getBounds())) would work, or you can debug with smartImage.drawBox(tabBackpack.getBounds())). That way you can tell if SRL is finding the right spot and you'll know if you did the DTM right.

Laquisha

2015-04-08 21:18:50

You can try:


procedure fletchLogs();
var
logsDTM: Integer := DTMFromString('mggAAAHicY2NgYDBlZGDQA2JHILYHYl1GiFg5ENcCcQ4Q1wBxIRDnA7GPpSJDQ5oFUCcjQ6SzOpgd6qDKgAsw4sAQAAC8Pgh6');
begin
if not isLoggedIn() then exit();

if tabBackpack.clickDTM(logsDTM, MOUSE_RIGHT, 'raft', 1000) then
begin
if toolScreen.isOpen(3000) then
toolScreen.select('Knife');

if productionScreen.isOpen(5000) then
begin
writeLn('production Screen is open!');

if productionScreen.getSelectedBoxText() <> 'Arrow shafts' then // or whatever
productionScreen.selectBox(1);

productionScreen.clickStart();

if progressScreen.isOpen(5000) then
repeat
antiPattern();
wait(randomRange(1000, 1500));
until (not progressScreen.isOpen());

inc(loadsDone);
writeLn('Whole inventory fletched!')
end;
end;
end;

If that doesn't work then your DTM is probably bad

jamesayo

2015-04-08 23:31:01

From: The Simba Noob
You can try:

If that doesn't work then your DTM is probably bad

It worked! Thank you!
I also tweaked colour for finding the trees to make it work better and made it left click instead of right click the trees. I think the next thing i'll work on is making sure it doesn't wander far from the main bunch of trees.
Any idea what was wrong with my code?
I also used smartImage.drawBox(tabBackpack.getBounds())) and it was working fine.

EDIT: It works in a weird way, it clicks every log in the invy before it finally clicks the fletch button. It was right clicking them all and displaying a bunch of errors in debug, but I changed it to left click and it still did the same thing.
EDIT: Ah-ha! Got it working with a mix of our codes:
procedure fletchLogs();
var
logsDTM: Integer := DTMFromString('mlwAAAHicY2dgYFjKwsCwDoi3AvECIJ4NxDOBeAkQazIxMEgDsQ4QmwKxIRCrAbEcEPtaKQJ1M0ExIxKbiYGLATdgxIOhAAAxdQaQ');
x, y: integer;
begin
smartImage.drawBox(tabBackpack.getBounds());
if not isLoggedIn() then exit();

begin
if findDTM(logsDTM, x, y, tabBackPack.getBounds()) then
begin
mouse(x, y, 3, 3, MOUSE_MOVE);
if isMouseOverText(['raft', 'ogs']) then
fastClick(MOUSE_LEFT);

if toolScreen.isOpen(3000) then
toolScreen.select('Knife');

if productionScreen.isOpen(5000) then
begin
writeLn('production Screen is open!');

if productionScreen.getSelectedBoxText() <> 'Arrow shafts' then // or whatever
productionScreen.selectBox(1);

productionScreen.clickStart();

if progressScreen.isOpen(5000) then
repeat
antiPattern();
wait(randomRange(1000, 1500));
until (not progressScreen.isOpen());

inc(loadsDone);
writeLn('Whole inventory fletched!')
end;
end;
end;
end;