SRL Archive - OSR Help

Help with learning lape


elephant

2015-03-26 16:13:43

Hi, I am no too sure if this is the correct place for this thread, however not really sure where to place it sorry if it's misplaced. Anyways, I am looking to learn how to make some basic bots with Simba, I would like to use lape, and than use smart with reflection for any bots I make, so they will not use the actual computer mouse. Is reflection the only thing I need? What else do I need to learn/use? What I mean is do you need to use aerolib as well with reflection for movement? Furthermore, I can not find any up to date tutorials for lape or aerolib, while I have been able to find a tutorial on reflection for lape that's all. If someone can link me to some tutorials for those it would be great :D, or even some beginner tutorials for lape.

In a brief summary of my questions, in case that's a bit of a read they are:
1.What do you need to know to make lape bots with reflection in smart? Just reflection or aerolib etc as well for movement?
2. Are there any tutorials people can link me to for lape and reflection, and possibly aerolib include as well if that is needed?


P.S. Somehow managed to forget to mention somewhere in there, I want to learn for osrs preferably.

MariusK

2015-03-26 16:37:39

1. It is possible to only use reflection, but there are some useful functions in aerolib too, so I suggest you use both.

2.

https://villavu.com/forum/showthread.php?t=107698
https://villavu.com/forum/showthread.php?t=111555
https://villavu.com/forum/showthread.php?t=111664

I believe these are all the basic lape reflection guides available. Some stuff has changed tho.

elephant

2015-03-26 18:19:45

From: MariusK
1. It is possible to only use reflection, but there are some useful functions in aerolib too, so I suggest you use both.

2.

https://villavu.com/forum/showthread.php?t=107698
https://villavu.com/forum/showthread.php?t=111555
https://villavu.com/forum/showthread.php?t=111664

I believe these are all the basic lape reflection guides available. Some stuff has changed tho.


Thanks for the info, it seems you need Aerolib for any mouse functions mainly though, are there any tutorials by any chance on that or just a post similar to the reflection one :P? Furthermore, I have just been looking through already made scripts, is there much to know about smart or are there just a few commands you need to send to it?

MariusK

2015-03-26 19:31:00

I don't think so. However, there's AeroLib thread, so maybe you can find some useful content there.

https://villavu.com/forum/showthread.php?t=108953

Regarding Smart, you just need to define it at the start of the script. If you'll be using reflection/AeroLib it will be spawn automatically.

elephant

2015-03-26 22:17:15

Thanks @MariusK for the responses/answers. I just have one more question atm if anyone can answer it about lape reflection. How do you find item ids?

Kyle

2015-03-26 22:18:35

From: elephant
Thanks @MariusK for the responses/answers. I just have one more question atm if anyone can answer it about lape reflection. How do you find item ids?


Just use names if you don't want to debug the ID's

elephant

2015-03-27 15:02:28

From: elfyyy
Just use names if you don't want to debug the ID's


Is there any way to know what an object is called? I was trying to see if I could get it to detect tin and output whether or not it found it. It always outputs false, even when standing next to tin :(. Whenever I do just "Rocks" it will detect it, however not too sure how to only detect a certain type of rock. My code I wrote was :

[PHP]// Find the ore
procedure findOre();
begin
while (running = true) do begin
if (Ore.Find(objGame, 'tin', 20) then begin
writeln('test');
end else begin
writeln('Cannot find the ore');
running := false;
end;
end;
end;
[/PHP]

rj

2015-03-27 15:25:00

From: elephant
Is there any way to know what an object is called? I was trying to see if I could get it to detect tin and output whether or not it found it. It always outputs false, even when standing next to tin :(. Whenever I do just "Rocks" it will detect it, however not too sure how to only detect a certain type of rock. My code I wrote was :

[PHP]// Find the ore
procedure findOre();
begin
while (running = true) do begin
if (Ore.Find(objGame, 'tin', 20) then begin
writeln('test');
end else begin
writeln('Cannot find the ore');
running := false;
end;
end;
end;
[/PHP]


If the object isn't called tin then it isn't going to detect 'tin' :) I think all rocks are called "Rocks", you should instead be looking for the ID.You can find out the ID using the reflection debugger: https://villavu.com/forum/showthread.php?t=112438 Example:

The trees id is 1278

elephant

2015-03-27 15:28:52

From: rj
If the object isn't called tin then it isn't going to detect 'tin' :) I think all rocks are called "Rocks", you should instead be looking for the ID.You can find out the ID using the reflection debugger: https://villavu.com/forum/showthread.php?t=112438 Example:

The trees id is 1278


Thanks, exactly something I was looking for :).

The Mayor

2015-03-27 16:07:40

From: elephant
Thanks, exactly something I was looking for :).


Debugging is getting added to the include officially, just waiting on elfyyy to accept it

https://villavu.com/forum/showthread.php?t=112455&p=1336252#post1336252

elephant

2015-03-27 17:42:41

From: The Mayor
Debugging is getting added to the include officially, just waiting on elfyyy to accept it

https://villavu.com/forum/showthread.php?t=112455&p=1336252#post1336252


Looks awesome :)

Anyways, I wrote a simple tin miner script and am having a few problems would anyone be able to to possibly point out what is going wrong?
Problems
1. When dropping it will drop an ore, than re-click the spot where it previously dropped the ore. I can't quite figure out why it does this. When adding a wait(500) time to drop, it made it so it will only have that problem every 5 or so ores it drops. However without a wait timer or a faster time it will do it almost every other time it drops. Am I doing something wrong with the dropping system?
2. When mining, it will click the ore after you finish mining it, I tried adding a wait timer, and looking for what would cause this problem I cannot find it :(.

I posted the entire script, since I'm not too sure what could be causing either problem. Hopefully someone can point out a simple fix. Also, if I am coding anything a weird way/incorrect please point it out, I'm not use to object oriented languages, I have only coded oop ones in the past.

[PHP]program tinMiner;
{$DEFINE SMART}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}

// Variables
var
ReflectPlayer : TReflectLocalPlayer;
Ore : TReflectObject;
tinOreID : integer;
tinRockID : integer;

// Got this setup format from a forum post
// Information about player/account
procedure declarePlayer();
begin
Me.Name := '';
Me.Pass := '';
Me.Pin := '';
Me.Nick := '';
Me.LampSkill := SKILL_MINING;
Me.Member := True;
Me.Active := True;
end;

// check if player is in mining animation
function checkIfMining : boolean;
begin
if (reflectplayer.GetAnimation = 626) then begin
// return result := true if doing animation
result := true;
end else begin
// return result := false if not doing animation
result := false;
end;
end;

// check if players inventory is full
function checkInventorySpace : boolean;
begin
// if it is result := true which will commence dropping
if (Reflect.Inv.IsFull) then begin
result := true;
end else begin
// if it is not result := false which will continue mining
result := false;
end;
end;

// Checks to make sure the bot has not wandered off etc, will log out as fail safe if true
// Will add this later
function checkPlayerLocation : boolean;
begin

end;


procedure clickOre(oreLocation : TPoint);
begin
reflect.Mouse.Move(oreLocation, 5, 5);
wait (100);
reflect.Mouse.Click(1);
end;

procedure dropOres();
var
tin : tstringarray;
begin
tin := ['Tin ore'];
// Drop ores
while (Reflect.Inv.Contains(tin) = true) do begin
reflect.Inv.Drop(438);
wait(500);
writeln('Dropping tin ores');
end;
end;


// Find the ore
procedure findOre();
var
oreLocation : TPoint;

begin
while (Me.Active = true) do begin
if (Ore.Find(objGame, 14863, 20)) then begin
oreLocation := ore.GetMSPoint;
// ore is found do the following
// Check if user is already mining/in animation
if (checkIfMining = false) then begin
if (checkInventorySpace = false) then begin
// contiune mining
clickOre(oreLocation);
wait(1000);
end else begin
// start dropping ores
dropOres();
end;
end;
end else begin
// Do a few things in-case there are not ores to mine
// Check player location, to see if rocks are just spawning
// If player is not in the correct location end the script
writeln('Cannot find the ore');
Me.Active := false;
end;
end;
end;

// Setup
begin
initAL;
Reflect.Setup;
declarePlayer();
LoginPlayer(False);
ReflectPlayer.Create;
Reflect.Login.LoginPlayer(Me.Name, Me.Pass);
findOre();
end. [/PHP]

The Mayor

2015-03-27 18:31:35

From: elephant
Looks awesome :)

Anyways, I wrote a simple tin miner script and am having a few problems would anyone be able to to possibly point out what is going wrong?
Problems
1. When dropping it will drop an ore, than re-click the spot where it previously dropped the ore. I can't quite figure out why it does this. When adding a wait(500) time to drop, it made it so it will only have that problem every 5 or so ores it drops. However without a wait timer or a faster time it will do it almost every other time it drops. Am I doing something wrong with the dropping system?
2. When mining, it will click the ore after you finish mining it, I tried adding a wait timer, and looking for what would cause this problem I cannot find it :(.

I posted the entire script, since I'm not too sure what could be causing either problem. Hopefully someone can point out a simple fix. Also, if I am coding anything a weird way/incorrect please point it out, I'm not use to object oriented languages, I have only coded oop ones in the past.


I don't have any experience with AreoLib, but for reflection you could:


program tinMiner;
{$DEFINE SMART}
{$i Reflection/Reflection.Simba}

var
ReflectPlayer: TReflectLocalPlayer;

procedure declarePlayer(); // I've changed this to use your ReflectPlayer
begin
ReflectPlayer.Username := '';
ReflectPlayer.Password := '';
ReflectPlayer.Active := True;
ReflectPlayer.Create;
end;

procedure checkPlayerLocation(); // each [1234, 1234] is a tile
var
MyArea: TPointArray;
begin
MyArea := [[1234, 1234], [1234, 1234], [1234, 1234], [1234, 1234]];

if not Reflect.Tiles.InPolygon(MyArea) then
ReflectPlayer.BlindWalkMM([1234, 1234]); // if not in area, walk to tile
end;

procedure findOre();
var
Ore: TReflectObject;
begin
if Ore.Find(objGame, 13450, 20) then
if Ore.IsOnMS then // checks that the 'Ore' object is on the mainscreen
begin
Reflect.Mouse.Move(Ore.GetMSPoint, 2, 2, MOUSE_LEFT); // You can click at the same time
ReflectPlayer.WaitForAnimation(100, 2000); // Wait to start animating
ReflectPlayer.WaitWhileAnimating(100, 10000); // Wait while animating (max time 10s)
end;
end;

begin
Reflect.Setup;
declarePlayer();

repeat
if not ReflectPlayer.IsLoggedIn then
ReflectPlayer.Login

repeat
findOre();
until Reflect.Inv.IsFull; // repeat mining until full

Reflect.Inv.DropAll; // drop all
until not ReflectPlayer.Active;

end.

And I just took a look at the dropping stuff, and it does seem buggy. I'll take a look at it

elephant

2015-03-27 19:49:32

From: The Mayor
everything


Hey, thanks for the reply, I'm gonna tweak my code with some fixes like yours for the clicking and mining part, pretty sure that will do the trick for that problem. However, I have two questions going off of what you said.

1. Is aerolib really even needed than? When I read the guide for reflection with lape, it says it needs aerolib for mouse movements and positioning, which is the reason why I used it. However, you easily accomplished that without aerolib. Basically what I'm confused on, is aerolib needed at all for making reflection bots or is it just some extra functions to make things easier?

2. In your code you do [PHP]Reflect.Inv.DropAll;[/PHP] while you said it still seems buggy for you that way, I was trying to make it so it will only drop specified objects so I could keep pickaxes, etc in inventory and not have it dropped. I did this, not sure if dropping this way is buggy? [PHP]while (Reflect.Inv.Contains(tin) = true) do begin
reflect.Inv.Drop(438);
wait(500);
writeln('Dropping tin ores');
end; [/PHP]

Forgot to mention, I really like that area setup, I was just going to set a tile or so and have it always start there. Your way is probably a lot more efficient :P.

The Mayor

2015-03-27 19:59:25

From: elephant
Hey, thanks for the reply, I'm gonna tweak my code with some fixes like yours for the clicking and mining part, pretty sure that will do the trick for that problem :). However, I have two questions going off of what you said.

1. Is aerolib really even needed than? When I read the guide for reflection with lape, it says it needs aerolib for mouse movements and positioning, which is the reason why I used it. However, you easily accomplished that without aerolib. Basically what I'm confused on, is aerolib needed at all for making reflection bots or is it just some extra functions to make things easier?

2. In your code you do [PHP]Reflect.Inv.DropAll;[/PHP] while you said it still seems buggy for you that way, I was trying to make it so it will only drop specified objects so I could keep pickaxes, etc in inventory and not have it dropped. I did this, not sure if dropping this way is buggy? [PHP]while (Reflect.Inv.Contains(tin) = true) do begin
reflect.Inv.Drop(438);
wait(500);
writeln('Dropping tin ores');
end; [/PHP]


Elfyyy has been adding heaps of new stuff to reflection since he wrote that tutorial. It can be used as a stand alone include as it has all the functions you need to do just about anything you want. Although AeroLib probably has some neat features which you may want to use too, so it's up to you if you want to include both.

Re: dropping. It doesn't wait for the item do drop so it can still see the ID of the item it just dropped. I'll fix it shortly.

P.S: The above snippet might not compile since WaitWhileAnimating and IsOnMS haven't been added yet. If you can't wait, you can download the zip from here, extract, and replace the files in C:/simba/includes/reflection.

elephant

2015-03-27 20:19:13

From: The Mayor
Elfyyy has been adding heaps of new stuff to reflection since he wrote that tutorial. It can be used as a stand alone include as it has all the functions you need to do just about anything you want. Although AeroLib probably has some neat features which you may want to use too, so it's up to you if you want to include both.

Re: dropping. It doesn't wait for the item do drop so it can still see the ID of the item it just dropped. I'll fix it shortly.

P.S: The above snippet might not compile since WaitWhileAnimating and IsOnMS haven't been added yet. If you can't wait, you can download the zip from here, extract, and replace the files in C:/simba/includes/reflection.


Alright, thanks for clearing that up. Didn't know reflection could be used without aerolib. As for dropping, glad to hear the problem was already found/worked on.

elephant

2015-03-28 11:52:10

nvm

elephant

2015-03-30 22:15:31

Just another question, hopefully someone probably knows what to do for this. I want to make a simple, paint or information hud display while the bots running. It will have information regarding how many ores were mined, time running etc. I currently wrote this, however I ran into two problems.
1. How do I check how many ores it mined? I was thinking an inventory count than just checking whenever it changes, since going off the timer in my script is a bit unreliable and will give it false positives :(.
2. How can I call/update the hud? I can't seem to be able to call it enough due to the waits in my script, it will pause for seconds at a time. Is there any way to properly do this?


Here's the current hud/gui/paint thing:
[PHP]// Display information
procedure displayInformation();
var
informationPaint, X, Y: Integer;
begin
// Set the image
informationPaint := BitmapFromString(120, 50, 'meJzt0EENwgAARTFEcOQ4Q8MC3' +
'uYOD2jY6b+EJlXQ4/U9kj7Pd9l5PW6Zf3r27HnOs2fPQfNJzwWePX' +
'sOmk96LvDs2XPQfNJzgWfPnoPmk54LPHv2HDSf9Fzg2bPnoPmk5wL' +
'Pnj0HzSc9F3j27DloPum5wLNnz0HzSc8Fnj17DppPei7w7Nlz0HzS' +
'c4Fnz//8/ANeYdwT');

// Finish setting the image

// Begin setting up the information
Reflect.Smart.Graphics.DrawBox(10, 10, 140, 60, True, clWhite);
Reflect.Smart.Graphics.DrawClippedText('Time running : ' + InttoStr(round(GetTimeRunning/1000)) , 'upchars07', point(10, 10), clRed);
Reflect.Smart.Graphics.DrawClippedText('Ores Mined : ' + InttoStr(OresMined) , 'upchars07', point(10, 20), clRed);
Reflect.Smart.Graphics.DrawBitmap(informationPaint, point(50, 50), false);

// free bitmaps
if (ReflectPlayer.Active = false) then
begin
FreeBitmap(informationPaint);
end;

end; [/PHP]

entire script if it helps :
[PHP]program tinMiner;
{$DEFINE SMART}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}


{
// bugs
- detect when you gain gems
}

// Variables
var
ReflectPlayer : TReflectLocalPlayer;
Ore : TReflectObject;
OresMined : Integer;
OresInInventory : TReflectObject;

// Information about player/account
procedure declarePlayer();
begin
ReflectPlayer.Username := '';
ReflectPlayer.Password := '';
ReflectPlayer.Active := True;
ReflectPlayer.Create;
end;

// Display information
procedure displayInformation();
var
informationPaint, X, Y: Integer;
begin
// Set the image
informationPaint := BitmapFromString(120, 50, 'meJzt0EENwgAARTFEcOQ4Q8MC3' +
'uYOD2jY6b+EJlXQ4/U9kj7Pd9l5PW6Zf3r27HnOs2fPQfNJzwWePX' +
'sOmk96LvDs2XPQfNJzgWfPnoPmk54LPHv2HDSf9Fzg2bPnoPmk5wL' +
'Pnj0HzSc9F3j27DloPum5wLNnz0HzSc8Fnj17DppPei7w7Nlz0HzS' +
'c4Fnz//8/ANeYdwT');

// Finish setting the image

// Begin setting up the information
Reflect.Smart.Graphics.DrawBox(10, 10, 140, 60, True, clWhite);
Reflect.Smart.Graphics.DrawClippedText('Time running : ' + InttoStr(round(GetTimeRunning/1000)) , 'upchars07', point(10, 10), clRed);
Reflect.Smart.Graphics.DrawClippedText('Ores Mined : ' + InttoStr(OresMined) , 'upchars07', point(10, 20), clRed);
Reflect.Smart.Graphics.DrawBitmap(informationPaint, point(50, 50), false);

// free bitmaps
if (ReflectPlayer.Active = false) then
begin
FreeBitmap(informationPaint);
end;

end;

// Check player location
procedure checkPlayerLocation();
var
miningArea: TPointArray;
begin
miningArea := [[3227, 3149], [3227, 3144], [3224, 3144], [3222, 3149]];

if not Reflect.Tiles.InPolygon(miningArea) then
ReflectPlayer.BlindWalkMM([3223, 3147]); // if not in area, walk to tile
end;

procedure dropOres();
var
tin : tstringarray;
begin
tin := ['Tin ore'];
// Drop ores
while (Reflect.Inv.Contains(tin) = true) do begin
reflect.Inv.Drop(438);
end;
end;


// Find the ore
procedure findOre();
begin
if (Ore.Find(objGame, 14863, 20)) then begin
// ore is found do the following
Reflect.Mouse.Move(Ore.GetMSPoint, 2, 2, MOUSE_LEFT); // You can click at the same time
ReflectPlayer.WaitForAnimation(100, 2000); // Wait to start animating
ReflectPlayer.WaitWhileAnimating(100, 10000); // Wait while animating (max time 10s)
wait (1000 + random(1000)) // Wait for a random time between 1-2 seconds before continuing
end else begin
// Do a few things in-case there are not ores to mine
// Check player location, to see if rocks are just spawning
// If player is not in the correct location end the script
writeln('Cannot find the ore');
checkPlayerLocation();
// ReflectPlayer.Active := false;
end;
end;


// Do antiban precautions
procedure antiBan();
begin

end;

// Output a progress report
procedure proggy();
begin
writeln('???????????????????');
writeln('? Progress Report ?');
writeln('???????????????????');
writeln('? Time Running : ?');
writeln('? Ores Mined : ?');
writeln('???????????????????');
end;

// Check for many problems that can arise durring the script
procedure failSafes();
begin
// Check for gems filling inventory
// Check if bot is stuck
end;

// Setup
begin
SMART_ShowConsole := false;
SMART_UserAgent := 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0';
initAL;
Reflect.Setup;
declarePlayer();
OresMined := 0;
repeat
if not ReflectPlayer.IsLoggedIn then
ReflectPlayer.Login
repeat
findOre();
displayInformation();
until Reflect.Inv.IsFull; // repeat mining until full

dropOres();
until not ReflectPlayer.Active;
// Output progress report when script is finished
proggy();
end. [/PHP]

3Garrett3

2015-03-31 14:01:30

From: elephant
Just another question, hopefully someone probably knows what to do for this. I want to make a simple, paint or information hud display while the bots running. It will have information regarding how many ores were mined, time running etc. I currently wrote this, however I ran into two problems.
1. How do I check how many ores it mined? I was thinking an inventory count than just checking whenever it changes, since going off the timer in my script is a bit unreliable and will give it false positives :(.
2. How can I call/update the hud? I can't seem to be able to call it enough due to the waits in my script, it will pause for seconds at a time. Is there any way to properly do this?


First (completely off topic) please use
 
(no space) tags when posting code. PHP hurts my eyes, and the Simba tags properly display the code with Simba highlighting which is easier to read.

1. Typically, before you drop your ores, you should do an inventory count. I'm not exactly sure the function in Reflection, but I'm assuming there is something to do it. You should have a global variable that keeps track of your total ore count. So something like:


var
totalOre : Integer; //This goes at the top of your script.

// Other code

procedure dropOres();
var
tin : tstringarray;
begin
tin := ['Tin ore'];
totalOres += reflect.Inv.count(tin); // += increases the variable by the count (I don't know the exact reflection function so this probably won't compile)
// Drop ores
while (Reflect.Inv.Contains(tin) = true) do begin
reflect.Inv.Drop(438);
end;
end;

// Other code

// Output a progress report
procedure proggy();
begin
writeln('???????????????????');
writeln('? Progress Report ?');
writeln('???????????????????');
writeln('? Time Running : ' + toStr(timeRunning)); // This is the SRL-6 variable for time running, I don't know what reflection does for this
writeln('? Ores Mined : ' + toStr(totalOres));
writeln('???????????????????');
end;

Sorry that I'm not very familiar with Reflection, but that should be fine if you can find the proper counting function and proper timeRunning variable.

2. Simba does not do multi-threading (normally) so you can't have a continuously updating progress report while mining. I only update mine every load I do because I'm not picky about it, but at best you can update it every ore that you mine.

elephant

2015-03-31 18:43:14

From: 3Garrett3
post


Thanks for the help with item count and explaining the progress report. I didn't know if I was doing it correct, guess I was. Also, didn't realize there was simba tags :P, great to know for future.

elephant

2015-03-31 21:22:43

Well, ran into another problem. Basically, I made a nice progress report/paint/gui thing to display. However, it is quite large and takes around 500 lines. Looking through other bots that have images similar to this, they paste the image on pastebin and use that. Would anyone be able to give an example of how to do this? I got lost looking at some other code.

Turpinator

2015-04-01 00:01:28

From: elephant
Well, ran into another problem. Basically, I made a nice progress report/paint/gui thing to display. However, it is quite large and takes around 500 lines. Looking through other bots that have images similar to this, they paste the image on pastebin and use that. Would anyone be able to give an example of how to do this? I got lost looking at some other code.


If you dont pad the output from the bitmap thing, it will just be on one like, albeit super long.

elephant

2015-04-01 17:04:08

From: Turpinator
If you dont pad the output from the bitmap thing, it will just be on one like, albeit super long.


Ah, that's good enough thanks :)

elephant

2015-04-01 19:45:34

Are there any form tutorials or documentation anyone can link me to? I can't seem to find one that is up to date.