SRL Archive - OSR Help

Script WIP


Wire

2014-06-15 16:30:55

Is there a way to possibly slow down the mouse speed when it closes the bank or when the option is chosen for the withdraws? Also if there is anything that should be used over what i have, by all means please state your opinion and why it would be better. Thanks Wire.
Procedure OakLogsCheck;
begin
Oak:= DTMFromString('mPwEAAHic42dgYOAHYk4gZgNiSSCWBmI+IBYBYjkgloWKiwIxFxCzMCAADxBLQNWCxIWBWAzKB5nLDcSMULUsUHtAZgsBcbitPFSWHEw+INdGLLYCAGBjAow=');
If FindDTM(Oak, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin
MMouse(x, y, 10, 10);
Wait(500+random(1000));
If IsUpText('ak') Then
Mouse(x, y, 3, 3, False);
WriteLn('Found Oak Logs');
ChooseOption('ithdraw-Al')
Wait(500+random(500));
CloseBank; //Change to moving on minimap
FreeDTM(Oak);
end;
end;

The Mayor

2014-06-15 17:15:12

Even if the uptext doesn't match it will print it found the logs :p

Awkwardsaw

2014-06-15 18:36:14

You can change the mouse speed by doing

mousespeed := 9;//or any other number, lower = slower. defualt is 12

also, it looks like you forgot a begin/end nest :)

Gunner

2014-06-15 20:14:28

From: The Mayor
Even if the uptext doesn't match it will print it found the logs :p


Dammit man, you are like a heat seeking missile when it comes to missing begin-ends. You nail me on that every time too. Lol.

The Mayor

2014-06-15 20:19:31

From: Gunner
Dammit man, you are like a heat seeking missile when it comes to missing begin-ends. You nail me on that every time too. Lol.



Haha, well I guess you won't be making those mistakes anymore :)

Gunner

2014-06-15 20:22:32

From: The Mayor
Haha, well I guess you won't be making those mistakes anymore :)


Oh, I don't know about that Lol. Pretty sure I'll miss another one, hell there's probably still one missing in my script now. Haha.

Flight

2014-06-15 21:09:09

Honestly when choosing a right-click option the mouse speed should be significantly lower, as it is in AL. If you want to go pro-human you can adjust the mouse speed depending on how many choose-options are visible in the right-click menu; the more options the slower the mouse speed as it would take longer for a human to read and determine which one to choose.

Also as for closing the bank, this could also auto-adjusted. If you're using mouse box then why not adjust the mouse speed based on the dimensions of the box? Big box = easy target so faster speeds, smaller boxes like the close-bank box could be slower speeds, or at least start slowing down when the mouse is near the target (BrakeMMouse…).

Wire

2014-06-15 22:08:28


Procedure OakLogsCheck;
begin
Oak:= DTMFromString('mPwEAAHic42dgYOAHYk4gZgNiSSCWBmI+IBYBYjkgloWKiwIxFxCzMCAADxBLQNWCxIWBWAzKB5nLDcSMULUsUHtAZgsBcbitPFSWHEw+INdGLLYCAGBjAow=');
If FindDTM(Oak, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin
MouseSpeed :=12;
MMouse(x, y, 10, 10);
Wait(500+random(1000));
If IsUpText('ak l') Then
Mouse(x, y, 3, 3, False); // should i change this to another tutorial i seen to give a more randomized click area it was something like Mouse(x+7,x+7,10,10).
WriteLn('Found Oak Logs');
ChooseOption('ithdraw-Al')
Wait(500+random(500));
CloseBank; //Change to moving on minimap should be faster and be more human like correct?
FreeDTM(Oak);
end else
CloseBank;
FreeDTM(Oak); // Is this irrelevant to have this FreeDTM here or above?
end;

Thank you everyone for the advice i do appreciate the help in learning this material, as i am having a hard time learning my first language. Thanks again Wire.
*As for speed i believe i find that my mouse speed at 12 is realistic enough even though it may be a tad slow. I think i may raise it a little higher later on in the script process. I believe i fixed the script to only write if the UpText is read for the WriteLn command.

The Mayor

2014-06-15 22:21:35

From: Wire


Thank you everyone for the advice i do appreciate the help in learning this material, as i am having a hard time learning my first language. Thanks again Wire.
*As for speed i believe i find that my mouse speed at 12 is realistic enough even though it may be a tad slow. I think i may raise it a little higher later on in the script process. I believe i fixed the script to only write if the UpText is read for the WriteLn command.


You are still missing that begin.

From: The Mayor

Now for a simple but important tip. If you have more than one statement following a ‘then’ you will need to add a begin and end. For example, this is incorrect:


if backpackIsFull() then
walkToBank();
findBanker();
depositLogs();

And this is correct:


if backpackIsFull() then
begin
walkToBank();
findBanker();
depositLogs();
end;

In the second example, you can see if the backpack is full, it will begin to read a new ‘block’ of code, which contains 3 procedures, walkToBank, findBanker, and depositLogs. In the first example, since there isn't a begin and end, Simba will think only the walkToBank is part of the if … then statement, and it will see the findBanker and depositLogs as separate, sort of like this:


if backpackIsFull() then
walkToBank();

findBanker();
depositLogs();

This means the findBanker and depositLogs procedures will ALWAYS run, even if the inventory isn't full! Remember - more than 1 statement after a then, you need a begin and end!


Something like this?


procedure OakLogsCheck;
begin
Oak:= DTMFromString('mPwEAAHic42dgYOAHYk4gZgNiSSCWBmI+IBYBYjkgloWKiwIxFxCzMCAADxBLQNWCxIWBWAzKB5nLDcSMULUsUHtAZgsBcbitPFSWHEw+INdGLLYCAGBjAow=');

if FindDTM(Oak, X, Y, MSX1, MSY1, MSX2, MSY2) then
begin
MouseSpeed :=12;
MMouse(x, y, 10, 10);
Wait(500+random(1000));

if IsUpText('ak l') then
begin
Mouse(x, y, 3, 3, False);
WriteLn('Found Oak Logs');
ChooseOption('ithdraw-Al')
Wait(500+random(500));
end else
writeLn('Uptext didn''t match');

end else
writeLn('Didn''t find the DTM');

CloseBank;
FreeDTM(Oak);
end;

Wire

2014-06-16 18:10:33

What is the best method for walking? This script is for plank running and one of the methods i have seen or atleast read about is DDTM. Would this be advised or should i use reflection for walking? I was following a tutorial on getting DDTM working but kept getting errors, perhaps i do not have all the required includes.

Edit-I think reflection is my best bet on walking.

*Mayor, thank you for providing the little tip although the code looks extremely similar to the one you provided, i did not copy it without actually breaking down the example so i understand the information. I made some modifications of my own that will open the bank via npc, wait for the dtm to be found and for the logs to be withdrawn.





program WirePlanks;

{$DEFINE SMART8}
{$I SRL-OSR/SRL.simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers (HowManyPlayers);
CurrentPlayer :=0;
Players[0].Name :=''; //UserName Login
Players[0].Pass :=''; //Password
Players[0].Nick :=''; //3-4 Letters from Name
Players[0].WorldInfo := []; //World Number
Players[0].Active:=True;
end;


Procedure OakLogsGrab;
var
Oak, X, Y: Integer;
begin
openbanknpc;
WaitFindDTM(x, y, Oak, 2000);
Oak:= DTMFromString('mPwEAAHic42dgYOAHYk4gZgNiSSCWBmI+IBYBYjkgloWKiwIxFxCzMCAADxBLQNWCxIWBWAzKB5nLDcSMULUsUHtAZgsBcbitPFSWHEw+INdGLLYCAGBjAow=');

if FindDTM(Oak, X, Y, MSX1, MSY1, MSX2, MSY2) Then
begin
MouseSpeed :=12;
MMouse(x, y, 10, 10);
Wait(500+random(1000));

if IsUpText('ak l') Then
begin
Mouse(x, y, 3, 3, False);
WriteLn('Found Oak Logs');
ChooseOption('ithdraw-Al')
Wait(500+random(500));
end else
writeLn('Uptext didnt match');

end else
writeLn('DTM didnt find the log');

CloseBank;
FreeDTM(Oak);
end;



begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
OakLogsGrab;
end.

Wetish

2014-06-16 20:15:54

Yep. Walking with reflection is very easy.

The Mayor

2014-06-16 20:36:05

Yea go reflection. The only problem with what you've posted is you try to find the DTM before you've assigned the DTM string to the Oak variable.

Wire

2014-06-17 15:54:55

Okay little update of sorts with more questions, wooo! Anyways for some reason the DTM isn't working properly, for instance it will say logs have been located, then on next test run the logs aren't. I also have been working on the reflection walking and think i implemented a decent method of retrieving logs and walking to mill. I also have my other attempt at walking to the mill with a check if logs are in the inventory. But this method failed so ignore it critique it for some extra learning. The SawMillToBank procedure is just a holding place for points until i sort out the NPC chat.

*Almost forgot, I added a small procedure to clear debug log for easy reading for the user. I do not know if this should be here yet or later down the line for the end users. Maybe this shouldn't even be used for checking for bugs.

* I know in the main loop i added // so i could test my other attempted method of walking.

The Mayor

2014-06-17 18:49:58

I would make the banking and walking separate procedures. Things get cluttered and harder to debug when you throw too much in a procedure.

Wire

2014-06-17 21:32:47

Any idea why the DTM for the logs messes up sometimes? Did I just make a bad DTM?

Flight

2014-06-17 21:55:58

From: Wire
Any idea why the DTM for the logs messes up sometimes? Did I just make a bad DTM?


Use my DTMs for the Oak Logs & Planks:

item_Logs.DTM := DTMFromString('mwQAAAHic42RgYMhlYmBIAOJkIM4E4lggTgfiaiAuA+IiIH4KVPcCiB8D8Sso/gjEz4D4FhC/BeKSSDOGBU3RDMs74hkmFboARRgxsByQRMaYKojDcAAAZfUR3g==');
item_Plank.DTM := DTMFromString('mlwAAAHicY2dgYJjBxMAwCYjnAPE8KN0HFeNgZGAQBGIGIP7LAOGLADEbEFckujK05fgwlMU7QxQgYREgCcOMJGAoAAD4Ogkz');

Wire

2014-06-18 12:52:51

From: Flight
Use my DTMs for the Oak Logs & Planks:

item_Logs.DTM := DTMFromString('mwQAAAHic42RgYMhlYmBIAOJkIM4E4lggTgfiaiAuA+IiIH4KVPcCiB8D8Sso/gjEz4D4FhC/BeKSSDOGBU3RDMs74hkmFboARRgxsByQRMaYKojDcAAAZfUR3g==');
item_Plank.DTM := DTMFromString('mlwAAAHicY2dgYJjBxMAwCYjnAPE8KN0HFeNgZGAQBGIGIP7LAOGLADEbEFckujK05fgwlMU7QxQgYREgCcOMJGAoAAD4Ogkz');


Okay, thanks! If you don't mind could you explain why my did/does that?

Dervish

2014-06-18 14:35:41

From: Wire
Okay, thanks! If you don't mind could you explain why my did/does that?


You probably missclicked a point in the dtm or something, I've never seen them mess up unless I made a bad DTM :P.

edit : in the bankscreen DTMs can mess up because of the numbers (I think).

Wire

2014-06-18 17:14:20

Please review and check the script for error :D! So far it opens the bank, walks to mill, opens the converting menu, finds the oak option, but can't seem to actually find the "buy all the planks" option. Other than that little problem i think the script has its "bare bones," i believe it will need adequate anti ban, paint, and a progress report before release.

Dervish

2014-06-18 19:28:26

procedure MillTalk;
begin
Wait(500+random(1000));
if FindColorSpiralTolerance( x, y, 13618870, MSX1, MSY1, MSX2, MSY2, 15) then
begin
MMouse(x, y, 5, 5);
If IsUpText('erator') then
begin
WriteLn('Found MillOperator');
WaitOption('pla',500);
Wait(500);
Oak:=DTMFromString('mVAEAAHicE2BgYAhkhOBoIE4E4iwgToDiMCCOA+J4qLwHELsAsT0QOwCxGxBPBeIKIG4G4hlAPBHKLgfiSiCeDcRLgXg1EC8G4nlAPB2IJwBxH0htljfD3IZIhhk14QwTSoMZyuJdGKZWhjJ05vsxlIRqMVRH6YDlQRgkDqIXt8YxRDopgtVSChgpxOgAADGnItw=');
WaitFindDTM(x, y, Oak, 500);
if FindDTM(Oak, X, Y, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 2, 2, false)
WaitOption('All',500);
Wait(500+random(1000));

end else
WriteLn('Couldnt convert logs');

end else
WriteLn('Didnt find MillOperator');
end else
Writeln('Didnt find color.');
FreeDTM(Oak);
end;

Small fixes which might help with doing what it's supposed to. I'll look more into it tomorrow ;).

You should try to use Reflection for Object finding and stuff, it makes the process a whole lot easier :D !

Also, add checks like "IsUpText(text)" to make sure you really found what you needed and don't click next to the spot ;). SRL is full of these nice little functions that, when combined, can make flawless scripts :).

Wire

2014-06-18 21:07:57

From: Dervish
procedure MillTalk;
begin
Wait(500+random(1000));
if FindColorSpiralTolerance( x, y, 13618870, MSX1, MSY1, MSX2, MSY2, 15) then
begin
MMouse(x, y, 5, 5);
If IsUpText('erator') then
begin
WriteLn('Found MillOperator');
WaitOption('pla',500);
Wait(500);
Oak:=DTMFromString('mVAEAAHicE2BgYAhkhOBoIE4E4iwgToDiMCCOA+J4qLwHELsAsT0QOwCxGxBPBeIKIG4G4hlAPBHKLgfiSiCeDcRLgXg1EC8G4nlAPB2IJwBxH0htljfD3IZIhhk14QwTSoMZyuJdGKZWhjJ05vsxlIRqMVRH6YDlQRgkDqIXt8YxRDopgtVSChgpxOgAADGnItw=');
WaitFindDTM(x, y, Oak, 500);
if FindDTM(Oak, X, Y, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 2, 2, false)
WaitOption('All',500);
Wait(500+random(1000));

end else
WriteLn('Couldnt convert logs');

end else
WriteLn('Didnt find MillOperator');
end else
Writeln('Didnt find color.');
FreeDTM(Oak);
end;

Small fixes which might help with doing what it's supposed to. I'll look more into it tomorrow ;).

You should try to use Reflection for Object finding and stuff, it makes the process a whole lot easier :D !

Also, add checks like "IsUpText(text)" to make sure you really found what you needed and don't click next to the spot ;). SRL is full of these nice little functions that, when combined, can make flawless scripts :).


Thanks XD, honestly i didn't forget about the checks such as "IsUpTest" because i was trying to get the "bare bones" setup first. Once i got the script running up and at least accomplishing its goal i would then go back and add its checks and fail safes. Still gotta learn how anti bans and such work but I don't know if that's an appropriate method of coding, so if you don't mind please share your methods ^.^. Thanks again i do appreciate the help, Wire.

*Don't suppose you have an example of finding a npc with reflection :D? Seen you said object* still got an example :D?


added some tweaks of your tweaked verison, it wasn't freeing the DTM properly and was Mouse command was in the wrong segment. The same problem still persist with selecting the log from the Plank/Mill interface.

procedure MillTalk;
begin
Wait(500+random(1000));
if FindColorSpiralTolerance( x, y, 13618870, MSX1, MSY1, MSX2, MSY2, 5) then
begin
MMouse(x, y, 5, 5);
Wait(500);
If IsUpText('wmil') then
begin
WriteLn('Found MillOperator');
Mouse(x, y, 2, 2, false)
WaitOption('pla',500);
Wait(500);
Oak:=DTMFromString('mwQAAAHic42RgYMhlYmBIAOJkIM4E4lggTgfiaiAuA+IiIH4KVPcCiB8D8Sso/gjEz4D4FhC/BeKSSDOGBU3RDMs74hkmFboARRgxsByQRMaYKojDcAAAZfUR3g==');
WaitFindDTM(x, y, Oak, 500);
if FindDTM(Oak, X, Y, MSX1, MSY1, MSX2, MSY2) then
begin
WaitOption('All',500);
Wait(500+random(1000));
FreeDTM(Oak);
end else
WriteLn('Couldnt convert logs');
FreeDTM(Oak);
end else
WriteLn('Didnt find MillOperator');
end else
Writeln('Didnt find color.');


end;

Update* Replaced the finding dtm in the plank interface with a findcolorspiral and its working for now. It works, sorta for some reason it absolutely refuses to bank the planks. :l Any ideas?