SRL Archive - OSR Help

My Script


kevin33

2011-12-25 18:02:45

Ok so I decided that I needed to make a ChopNBurn script in the end because I need a good working one. I had made progress on one before although with all these updates, a couple things are in need of change. My computer was fixed for me for Christmas so now Ive started reworking it. I just hit a speed bump and am in need of assistance. I cant for the life of me figure out how to script the burning part of the script. The toolbelt thing has thrown me off and so I ask how can I script the burning of logs after being chopped using the toolbelt option?

cause

2011-12-25 18:08:10

You'll need to be a bit more specific and you should probably post any of your code to get help lol. Question: is this toolbelt f2p? Cuz I've never heard of it

onilika

2011-12-25 18:09:49

function ClickAllItemsExcept(ItemType: String; Identifier: Integer; option: string; SlotIgnores: TIntegerArray; waitnum: Integer; tol: TIntegerArray):Integer;
By: WT-Fakawi, Sumilion & Nava2
Description: Performs "option" popup menu action on all items with:
ItemType - 'dtm', 'bitmap', 'bitmap mask', 'color'
Identifier - name/value of your dtm/bmp/color/bmpmask.
Tol - 'dtm' - [] (dtm's can't have tolerance).
'bmp' - [BMPTol].
'color' - [COLOUR Tol, Colour Count].
'bmpmask' - [BMPTol, ContourTol].
Will not click items in slots SlotIgnores


From Core.
Having tinderbox on toolbelt, you simply need to right-click on the log and select the option 'fire', if I'm not wrong about the option.
That function, if not mistaken, will right click, and select the fire option. But since it's the first option, you can simply left click.

kevin33

2011-12-25 18:20:18

From: onilika
From Core.
Having tinderbox on toolbelt, you simply need to right-click on the log and select the option 'fire', if I'm not wrong about the option.
That function, if not mistaken, will right click, and select the fire option. But since it's the first option, you can simply left click.


Ok so how would I code that in the form of logs??
Sorry I still am drawing a blank on how to code it so it will perform. I am about to eat so I cant do it atm. Ive been working like all day so Im gonna go to bed soon. If someone could please show me how to code it, credit will be given when I release script for testing :) Anyways Ill be back in like 20 minutes hopefully to chck up, work on the script and hopefuly complete it, then go to bed in about an hour.

@cause I will probably post some of it after dinner. And yes toolbelt is both f2p and p2p. You are able to put necessary items like a needle, pick, hatchet, fishing net, etc in it so you dont have it take up room in the inventory.

kevin33

2011-12-25 19:19:10

Alright so Im done dinner. here is my script up to the burning part. Keep in mind it has some old functions that I am in the process of changing because it has been on my computer for a bit as it was my bros (sorry forget username for vill) and I just got the computer back now. He is at University right now and he stopped playing so I have some of his stuff here at home. Anyways here it is:
program ChopNBurn;

{.include SRL/SRL.scar}
{.include SRL/SRL/skill/firemaking.scar}

//have hatchet equipped
//be near some trees you want to cut
//Maples I do not have the colours for
//Colors may be off, fix them as you need to, I will do my best to fix them also
Const
TREE_TOL=5;
TREE = 0;
OAK = 1;
WILLOW = 2;
MAPLE = 3;
YEW = 4;
//Tree_Colors
//Tree_Names
var
TreeDTM: Integer;
Tree_Colors:Array[0..4] of TIntegerArray;
Tree_Names:Array of String;

procedure declarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[1].BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];

With Players[0] do
begin
Name := ''; //username
Pass := ''; //password
Nick := ''; //3-4 letters from your username
Active := true;
Integers[1] := 2; //tree you wish to cut

end;
end;
procedure StatsGuise(wat:String);
Begin
Status(wat);
Disguise(wat);
End;

procedure setupScript;
begin
ClearDebug;
SetupSRL;
ActivateClient;
declarePlayers;
Tree_Colors[0] := [3622483, 3754069, 3820120] //Trees
Tree_Colors[1] := [1845555, 2437176, 2700350] //Oaks
Tree_Colors[2] := [2964027, 2963771, 2832184] //Willows
Tree_Colors[3] := [] //Maples don't currently have colors for
Tree_Colors[4] := [3358796, 4017756, 4542554] //Yews
Tree_Names := ['ree', 'ak', 'illow', 'aple', 'ew'];
while not(RSReady) do
Wait(1000)
end;
procedure IdentifyTree; //just extra info just in case I make a pure firemaker
var
x,y: integer;
begin
if not LoggedIn then Exit;

if TreeDTM <= 0 then
case Players [CurrentPlayer].Integers[1] of
TREE:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYOhiYWCYDMRtQFwHxM1A3A/EM4A4mZGBIQKIo4A4BYjzgTibESLubiYP1M0ExsUxRnA2BOMGjHgwFAAAwEQIWg==');
OAK:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYOhmYWCYDMRtQFwLxC1A3A/EM4C4nZGBoQaI64C4GYgnA3E/EHcCcaa/HlA3Ew6MGzDiwVAAAPTwCJ8=');
Willow:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYLjPwsDwHIhvAPFFIL4OxI+B+A0QJzEyMEQAcRQQJwNxPhBnQ9nGuvxA3Uw4MG7AiAdDAQCWsAl2');
Maple:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYNjCwsCwF4jXAfFyIN4MxPuA+BAQJzMyMEQAcRQQJwFxLhBnAXEKELvrcwF1M+HAuAEjHgwFAAXtCGk=');
Yew:
TreeDTM := DTMFromString ('mlwAAAHicY2dgYOBiZWAQBGJmIP7NwsDABOWLAXEyIwNDBBBHAXEcEOcDcRYjRNxOlwOomwkHxg0Y8WAoAAAN1ASo');
end; //just showing I can use DTMs :)
end;

procedure setupPlayer;
begin
if LobbyScreen then LeaveLobby;
if not(LoggedIn) then LoginPlayer;
SetAngle(True);
MakeCompass('N');
Players[CurrentPlayer].Integers[1] := 0; //chopped
Players[CurrentPlayer].Integers[2] := 0; //burned
end;

procedure BurnOfChop;

There is more after just the burning part is all I need help with. Anyone think they could help me code it asap. :)

Valkyrie

2011-12-25 20:03:12

Nice code right there mate! nice DTMS.

kevin33

2011-12-25 20:05:58

From: Valkyrie
Nice code right there mate! nice DTMS.


Well thank you sir. If only I could finish it off. I am seriously getting impatient. I am trying to code the burning but it just wont work. Wish they never added the whole toobelt thing atm. I like it when I use it but not coding it :p So can anyone code the burning of logs for me with the new toolbelt function? Credit will be given when the script is released in beta form for testing and feedback.

Kyle Undefined

2011-12-26 23:16:15

This should work, and it's simple.


With Players[0] do
begin
Name := ''; //username
Pass := ''; //password
Nick := ''; //3-4 letters from your username
Active := true;
Integers[1] := 2; //tree you wish to cut
Booleans[0] := True; // Tinderbox is in your toolbelt
end;

And this should work for the burning:

procedure BurnOfChop();
var
I : Integer;
invSlot1, logSlot : TPoint;
begin
case(Players[CurrentPlayer].Booleans[0])of
True:
begin
if({FIND A LOG HERE})then
begin
Mouse(x, y, 4, 4, False);
Wait(RandomRange(250, 750));
ChooseOption('raf');
// Wait till done igniting all logs
end;
end;
False:
begin
if({FIND TINDERBOX HERE, SHOULD MAKE IT REQUIRED TO BE IN FIRST SLOT})then
begin
invSlot1 := ItemCoords(1);
for I := 2 to 28 do
begin
logSlot := ItemCoords(I);
Mouse(invSlot1.X, invSlot.Y, 4, 4, True);
Wait(RandomRange(250, 1000));
Mouse(logSlot.X, logSlot.Y, 4, 4, True);
Wait(RandomRange(750, 1250)); // Wait for the log to be ignited
end;
end;
end;
end;
end;

Didn't test these, just wrote them out so they may need to be altered.

kevin33

2011-12-26 23:32:19

if({FIND A LOG HERE}) //here
if({FIND TINDERBOX HERE, SHOULD MAKE IT REQUIRED TO BE IN FIRST SLOT}) //and here
Sorry I am like dying to release the script before I pass out from needing sleep. Boxing day ruined me :p
What would I put in the {} sets??
And after I test would u mind if I sent script to you to test and help me improve. Its pretty old school scripting and I apologize. I just got computer back so its all in old form.

Kyle Undefined

2011-12-26 23:35:06

Between the curly brackets, you'd put in code to either find a log for the "FIND A LOG HERE". Or, you'd put in code to find the tinderbox in the first slot for the "FIND TINDERBOX HERE", just to make sure the tinderbox is there.

I can look it over, but can't test, sorry.

kevin33

2011-12-26 23:44:26

Wait what would I write for the coding?? Sorry for asking so many noobie questions. I just dont grasp it atm. :( Like for logs would i write something like this or is it all much simpler?/
for itemNum:=1 to 27 do
 begin
if not(LoggedIn) then exit;
FindNormalRandoms;
LevelUp;
if CantLightCheck then exit;
if ExistsItem(itemNum) then
begin
InvMouse(itemNum, 3)
if WaitUpText('ogs', 200) then
begin
ClickMouse2(True);
InvMouse(28, 1);
wait(1500);
LevelUp;
LightWait;
inc(Players[CurrentPlayer].Integers[2]); //number burned

Kyle Undefined

2011-12-26 23:51:38

The procedure I wrote already handles that for you, all you have to do is FIND a log in the inventory. You can use FindColor(), some other made function or make a function that returns True/False if it does/doesn't find a log. Whatever you decide to do, replace the "{}" with it. That is for the "True" part of the case statement.

For the "False" part, all you need to do is double check and make sure the tinderbox is in the 1st slot of the inventory. Same goes for here, either use FindColor(), some other made function, or make a function that returns True/False if the tinderbox is/isn't found. You'd replace the "{}" with whatever you decide to do.

kevin33

2011-12-26 23:53:55

From: Kyle Undefined
The procedure I wrote already handles that for you, all you have to do is FIND a log in the inventory. You can use FindColor(), some other made function or make a function that returns True/False if it does/doesn't find a log. Whatever you decide to do, replace the "{}" with it. That is for the "True" part of the case statement.

For the "False" part, all you need to do is double check and make sure the tinderbox is in the 1st slot of the inventory. Same goes for here, either use FindColor(), some other made function, or make a function that returns True/False if the tinderbox is/isn't found. You'd replace the "{}" with whatever you decide to do.


Ok great I took that way outta perspective then. Will do thank you. I will test then send it to you. It is probably buggy but still. Do I need to do the colour for all the types of logs or just one type? Also is it just colors or do I need like tolerance or something?

kevin33

2011-12-27 00:20:51

Kyle do you mind checking this over please and tell me anything to change, etc.
var
I : Integer;
invSlot1, logSlot : TPoint;

begin
case(Players[CurrentPlayer].Booleans[0])of
True:
begin
if(FindColor(2771040, 15790320, 1325891, 3892358, 669516))then //colors may need changing and again no maple log you may fix that yourself
//^Line 102 here
begin
Mouse(x, y, 4, 4, False);
Wait(RandomRange(250, 750));
ChooseOption('raf');
// Wait till done igniting all logs
end;
end;
False:
begin
if({FindColor(5790300, 5527128)})then
begin
invSlot1 := ItemCoords(1);
for I := 2 to 28 do
begin
logSlot := ItemCoords(I);
Mouse(invSlot1.X, invSlot.Y, 4, 4, True);
Wait(RandomRange(250, 1000));
Mouse(logSlot.X, logSlot.Y, 4, 4, True);
Wait(RandomRange(750, 1250)); // Wait for the log to be ignited
end;
end;
end;
end;
end;

I got an error about a variable expected at line 102 so far. Any thoughts?

lilcmp1

2011-12-27 01:00:15

What is line 102?

Kyle Undefined

2011-12-27 02:21:52

Add this above your Burn procedure:


function colorIsFound(colors : TIntegerArray) : Boolean;
var
TPA : TPointArray;
I : Integer;
begin
for I := 0 to High(Colors) do
begin
FindColors(TPA, colors[I], MIX1, MIY2, MIX2, MIY2);
if(Length(TPA) > 0)then
Break;
end;

Result := Length(TPA) > 0;
end;

Then, for both of your "FindColor" areas, change them to this:
if(colorIsFound([color, color, etc]))then

kevin33

2011-12-27 02:28:54

Mouse(x, y, 4, 4, False);
[Error] (118:17): Unknown identifier 'x' at line 117
Compiling failed.
Do i need variable declared or something??

Kyle Undefined

2011-12-27 02:33:18

Yes. You always need variables declared when trying to use them.

kevin33

2011-12-27 02:39:01

From: Kyle Undefined
Yes. You always need variables declared when trying to use them.


var
I : Integer;
invSlot1, logSlot : TPoint;

begin
case(Players[CurrentPlayer].Booleans[0])of
True:
begin
if(colorIsFound([2771040, 15790320, 1325891, 3892358, 669516]))then //colors may need changing and again no maple log you may fix that yourself
begin
Mouse(x, y, 4, 4, False);
//need to declare variable for x and y but when I type them in it still says unknown type. How would I declare them? I was writing x, y: Integers; is this correct cuz it wasnt working :(

Kyle Undefined

2011-12-27 02:50:07


x, y : Integer;

kevin33

2011-12-27 02:55:20

invSlot1, logSlot : TPoint; //here

begin
case(Players[CurrentPlayer].Booleans[0])of
True:
begin
if(colorIsFound([2771040, 15790320, 1325891, 3892358, 669516]))then //colors may need changing and again no maple log you may fix that yourself
begin
Mouse(x, y, 4, 4, False);
Wait(RandomRange(250, 750));
ChooseOption('raf');
// Wait till done igniting all logs
end;
end;
False:
begin
if(colorIsFound([5790300, 5527128]))then
begin
invSlot1 := ItemCoords(1);
for I := 2 to 28 do
begin
logSlot := ItemCoords(I);
Mouse(invSlot1.X, invSlot.Y, 4, 4, True); //here
Wait(RandomRange(250, 1000));
Mouse(logSlot.X, logSlot.Y, 4, 4, True); //probably here
[Error] (133:29): Unknown identifier 'invSlot' at line 132
Compiling failed.
Isnt it identified? How do I fix it?

Kyle Undefined

2011-12-27 02:59:27


Mouse(invSlot1.X, invSlot1.Y, 4, 4, True);

Come on dude, read.

kevin33

2011-12-27 04:13:00

Ok so the script compiles and everything. One problem now is that when I run it, the Simba game window doesnt open. Any cause of this?
I also just tested and the mouse just hovers around the screen with a thing popping up in the debug. I know the colours I chose were quickly and poorly done so I have to change them. What is the best way to get colours of the various forms of trees?
Also what should the tolerance be set to for each?
Const
TREE_TOL=5;
TREE = 0;
OAK = 1;
WILLOW = 2;
MAPLE = 3;
YEW = 4;
//Tree_Colors
//Tree_Names
var
TreeDTM: Integer;
Tree_Colors:Array[0..4] of TIntegerArray;
Tree_Names:Array of String;

procedure declarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];
SMART_Server := 4;
SMART_Signed := True;
SMART_Members := False;

With Players[0] do
begin
Name := ''; //username
Pass := ''; //password
Nick := ''; //3-4 letters from your username
Active := true;
Integers[1] := 2; //tree you wish to cut
Booleans[0] := True; // Tinderbox is in your toolbelt

end;
end;
procedure StatsGuise(wat:String);
Begin
Status(wat);
Disguise(wat);
End;

procedure setupScript;
begin
ClearDebug;
SetupSRL;
ActivateClient;
declarePlayers;
Tree_Colors[0] := [3622483, 3754069, 3820120] //Trees
Tree_Colors[1] := [1845555, 2437176, 2700350] //Oaks
Tree_Colors[2] := [2964027, 2963771, 2832184] //Willows
Tree_Colors[3] := [] //Maples don't currently have colors for
Tree_Colors[4] := [3358796, 4017756, 4542554] //Yews
Tree_Names := ['ree', 'ak', 'illow', 'aple', 'ew'];
while not(RSReady) do
Wait(1000)
end;

Nebula

2011-12-27 04:33:28

If you want SMART to open you have to include SMART at the beginning of your script and at the beginning of your mainloop.

kevin33

2011-12-27 04:34:50

From: Nebula
If you want SMART to open you have to include SMART at the beginning of your script and at the beginning of your mainloop.


Ahhh that would be why. I forgot about that. Thank you. Now I need the other questions answered. :)

Nebula

2011-12-27 04:40:16

What pops up in the debug box?

for trees I think the best way to click them effectively would be to set the camera angle down and find the colors of the trunks since the leafs aren't always clickable.

for most things a tolerance of 5-25 is used. I'd recommend just starting with a Tol of 15 and then changing it to what works best.

kevin33

2011-12-27 04:42:06

From: Nebula
What pops up in the debug box?

for trees I think the best way to click them effectively would be to set the camera angle down and find the colors of the trunks since the leafs aren't always clickable.

for most things a tolerance of 5-25 is used. I'd recommend just starting with a Tol of 15 and then changing it to what works best.


Ok will do. Thanks. I will edit this after with debug. I closed before I could do anything :p

Debug:
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong xs to a finder function: -16. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong xs to a finder function: -16. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong xs to a finder function: -16. That is below 0, thus out of bounds. Setting the value to 0 for now.
Warning! You passed a wrong ys to a finder function: -5. That is below 0, thus out of bounds. Setting the value to 0 for now.

Im getting off to go to bed its 5am :p
I will be back to check up tomorrow.