1. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)

Multiple Trees

Hey,

I have a power chopping script, it currently only works with normal trees but I want to make it a power chopper for different trees.

How do I declare the trees and where?
How do I call them during the script and make the script recognize the users choice of the tree?

Thanks

2. You can use my tutorial here:

3. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Originally Posted by abu_jwka
You can use my tutorial here:

Ok thank you, will do. I'm surprised I haven't come across this tutorial before I've looked through most of them :P.

4. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Another question.

From ACA I have a big blob of text:
Code:
program AutoColor;
{.include SRL\SRL.simba}

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

FindColorsSpiralTolerance(MSCX, MSCY, arP, 2440522, 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.32) and (X <= 11.16) and (Y >= 1.35) and (Y <= 11.23) and (Z >= 0.75) and (Z <= 5.34) 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;
Is there a way to store all this information in something and save it as like OakTreeACA
and then call it during the script without having to paste all that text?

5. Sure, just name the function OakTreeACA, then you can just call it anywhere.

6. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
If I have the code from ACA at top like this:
Simba Code:
function NormalACA: Integer;var  arP: TPointArray;  arC: TIntegerArray;  tmpCTS, i, arL: Integer;  X, Y, Z: Extended;begin  tmpCTS := GetColorToleranceSpeed;  ColorToleranceSpeed(2);  SetColorSpeed2Modifiers(0.07, 0.21);  FindColorsSpiralTolerance(MSCX, MSCY, arP, 2440522, 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.32) and (X <= 11.16) and (Y >= 1.35) and (Y <= 11.23) and (Z >= 0.75) and (Z <= 5.34) 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;

and then in my script I call it like this:

Simba Code:
type TreeType = record  TreeDTM, TreeColour: Integer;end;var  tree: TreeType;procedure LoadTreeTypebegin  case lowercase(Players[CurrentPlayer].Strings[0]) of    'Normal':       begin                      tree.TreeColour := NormalACA;                      tree.TreeDTM := DTMFromString                    end;    'Oak':     begin                      tree.TreeColour := OakACA;                      tree.TreeDTM := DTMFromString                    end;    'Willow':      begin                      food.FoodColour := WillowACA;                      tree.TreeDTM := DTMFromString                    end;    'Maple':    begin                      food.FoodColour := MapleACA;                      tree.TreeDTM := DTMFromString                    end;  end;end;

Would it work?
Last edited by Spandzbab; 05-01-2012 at 12:17 AM.

7. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Bump (Sorry for spam need quick help )

8. Originally Posted by Spandzbab
If I have the code from ACA at top like this:
Simba Code:
function NormalACA: Integer;var  arP: TPointArray;  arC: TIntegerArray;  tmpCTS, i, arL: Integer;  X, Y, Z: Extended;begin  tmpCTS := GetColorToleranceSpeed;  ColorToleranceSpeed(2);  SetColorSpeed2Modifiers(0.07, 0.21);  FindColorsSpiralTolerance(MSCX, MSCY, arP, 2440522, 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.32) and (X <= 11.16) and (Y >= 1.35) and (Y <= 11.23) and (Z >= 0.75) and (Z <= 5.34) 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;

and then in my script I call it like this:

Simba Code:
type TreeType = record  TreeDTM, TreeColour: Integer;end;var  tree: TreeType;procedure LoadTreeTypebegin  case lowercase(Players[CurrentPlayer].Strings[0]) of    'Normal':       begin                      tree.TreeColour := NormalACA;                      tree.TreeDTM := DTMFromString                    end;    'Oak':     begin                      tree.TreeColour := OakACA;                      tree.TreeDTM := DTMFromString                    end;    'Willow':      begin                      food.FoodColour := WillowACA;                      tree.TreeDTM := DTMFromString                    end;    'Maple':    begin                      food.FoodColour := MapleACA;                      tree.TreeDTM := DTMFromString                    end;  end;end;

Would it work?
Yes, except, 'Oak','Willow' etc. need to be lowercase, because of
Code:
case lowercase(Players[CurrentPlayer].Strings[0]) of
Which is a good thing to have

9. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Originally Posted by nickrules
Yes, except, 'Oak','Willow' etc. need to be lowercase, because of
Code:
case lowercase(Players[CurrentPlayer].Strings[0]) of
Which is a good thing to have
Thank you

10. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Simba Code:
program SpandzChop;//{$DEFINE SMART}{.include SRL\SRL.simba}{.Include SRL\SRL\Misc\Debug.simba}//{$i SRL\SRL\Misc\paintsmart.simba}const  // Settings for you to change  TakeBreaks = False;      // Take breaks? 'True' or 'False'  SRLStats_Username = '';  // Your SRL Stats Username  SRLStats_Password = '';  // Your SRL Stats Password  BreakEvery        = 350; //How Many Minutes To Break After  BreakFor          = 10;  //How Long To Break For  // Don't touch the settings below  SRL_ANGLE_HIGH  = 0;  SRL_ANGLE_LOW   = 1;  SRL_ANGLE_NONE  = 2;var  TooLong: Integer;procedure DeclarePlayers;begin  HowManyPlayers := 1; // Read below if you want to use more than 1 player  NumberOfPlayers(HowManyPlayers);  CurrentPlayer := 0;  Players[0].Name := '';          //Your Runescape username  Players[0].Pass := '';          //Your Runescape password  Players[0].Active := True;      //'True' to use this player 'False' to disable  Players[0].Strings[0] := 'willows';  //'willows' , 'tree' , 'oak' or 'maple'end;// Keep the tree name lowercase or the script will not run// To use more than one more player copy the whole bit under begin then-// - change HowManyPlayers to 2, and instead of Players [0] put Players [1]// For 3 players it's the same, HowManyPlayers 3, Players [2] etc.procedure Randoms;begin  if not (LoggedIn) or not (Players[CurrentPlayer].Active) then    NextPlayer(False);  Status ('Checking for Randoms');  FindNormalRandoms;end;procedure RandomKey;begin  if not (LoggedIn) or not (Players[CurrentPlayer].Active) then    Writeln ('Player not logged in or inactive');    Exit;  case Random(3) of    0:      begin        KeyDown(VK_Left);        wait(Random(600) + 500);        KeyUp(VK_Left);      end;    1:      begin        KeyDown(VK_Right);        wait(Random(600) + 500);        KeyUp(VK_Right);      end;    2:      begin        KeyDown(VK_Up);        wait(Random(200) + 500);        KeyUp(VK_Up);      end;  end;end;procedure SetAngle(Angle: Integer);begin  if ((Angle = SRL_ANGLE_NONE) or (not LoggedIn)) then    Exit;  KeyDown((Angle * 2) + 38);  Sleep(1000 + Random(300));  KeyUp((Angle * 2) + 38);  Wait(500 + Random(100));end;function TreeColorACA: Integer;var  arP: TPointArray;  arC: TIntegerArray;  tmpCTS, i, arL: Integer;  H, S, L: Extended;  X, Y, Z: Extended;begin  tmpCTS := GetColorToleranceSpeed;  ColorToleranceSpeed(1);  FindColorsSpiralTolerance(MSCX, MSCY, arP, 2701118, MSX1, MSY1, MSX2, MSY2, 63);  if (Length(arP) = 0) then  begin    Writeln('Failed to find the color, no result.');    ColorToleranceSpeed(tmpCTS);    Exit;  end;  arC := GetColors(arP);  ClearSameIntegers(arC);  arL := High(arC);  for i := 0 to arL do  begin    ColorToHSL(arC[i], H, S, L);    if (H >= 10.12) and (H <= 11.13) and (S >= 19.55) and (S <= 29.65) and (L >= 6.45) and (L <= 33.75) then    begin      ColorToXYZ(arC[i], X, Y, Z);      if (X >= 0.57) and (X <= 10.43) and (Y >= 0.60) and (Y <= 10.82) and (Z >= 0.42) and (Z <= 7.18) then      begin        Result := arC[i];        Writeln('AutoColor = ' + IntToStr(arC[i]));        Break;      end;    end;  end;  ColorToleranceSpeed(tmpCTS);  if (i = arL + 1) then    Writeln('AutoColor failed in finding the color of TREE.');end;function OakColorACA: Integer;var  arP: TPointArray;  arC: TIntegerArray;  tmpCTS, i, arL: Integer;  X, Y, Z: Extended;begin  tmpCTS := GetColorToleranceSpeed;  ColorToleranceSpeed(2);  SetColorSpeed2Modifiers(0.07, 0.21);  FindColorsSpiralTolerance(MSCX, MSCY, arP, 2440522, 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.32) and (X <= 11.16) and (Y >= 1.35) and (Y <= 11.23) and (Z >= 0.75) and (Z <= 5.34) 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 of OAK.');end;function WillowColorACA: Integer;var  arP: TPointArray;  arC: TIntegerArray;  tmpCTS, i, arL: Integer;  X, Y, Z: Extended;begin  tmpCTS := GetColorToleranceSpeed;  ColorToleranceSpeed(2);  SetColorSpeed2Modifiers(0.22, 0.28);  FindColorsSpiralTolerance(MSCX, MSCY, arP, 2176311, MSX1, MSY1, MSX2, MSY2, 7);  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.35) and (X <= 5.67) and (Y >= 1.52) and (Y <= 6.22) and (Z >= 0.91) and (Z <= 3.50) 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 of WILLOW.');end;function MapleColorACA: Integer;var  arP: TPointArray;  arC: TIntegerArray;  tmpCTS, i, arL: Integer;  X, Y, Z: Extended;begin  tmpCTS := GetColorToleranceSpeed;  ColorToleranceSpeed(2);  SetColorSpeed2Modifiers(0.24, 0.24);  FindColorsSpiralTolerance(MSCX, MSCY, arP, 3097436, MSX1, MSY1, MSX2, MSY2, 9);  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 >= 3.22) and (X <= 12.10) and (Y >= 2.90) and (Y <= 11.33) and (Z >= 1.74) and (Z <= 5.98) 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 of MAPLE.');end;type TreeType = record  TreeDTM, TreeColour: Integer;end;var  tree: TreeType;procedure LoadTreeType;begin  case lowercase(Players[CurrentPlayer].Strings[0]) of    'tree':    begin                      tree.TreeColour := TreeColorACA;                      tree.TreeDTM := DTM := DTMFromString('maQEAAHicE2RgYBBkgABmKM0KxJxALADEokAsBcRyUAxiSwKxOBALATEvELNBaRDmBmIRIBZDUicKFQOp5wNiDiS7mICYBYq9LRSgIuTjAAbKASMVMAYAACNQAx8=');               end;    'oak':     begin                      tree.TreeColour := OakColorACA;                      tree.TreeDTM := DTMFromString('mwQAAAHic42RgYOAHYlkgFgZiNgYIkABiMSDmg4rxALEQEItC5UB8LqhaZiBmAeIsfz0gyUgAEwaETEAxBQAKaQHx');               end;    'willow':  begin                      food.FoodColour := WillowColorACA;                      tree.TreeDTM := DTMFromString('mwQAAAHic42RgYBAAYg4g5gNiESCWYoAAWSAWB2IWIOYBYkkgZgZiUSBmg4oJQdWC1BjpgExgJIAJA0ImoJgCANKQAXg=');               end;    'maple':   begin                      food.FoodColour := MapleColorACA;                      tree.TreeDTM := DTMFromString('mwQAAAHic42RgYOAHYjYgFgZieSCWYoAASSBmhsrzALEYEIsCsQBUPQ9UHSsQMwGxiw4HkGQkgAkDQiagmAIA1sMBfw==');               end;  end;end;beginSetupSRL;ActivateClient;DeclarePlayers;LoadTreeType;end.

Would something like this work? Is it connected to what the player choice of tree was? Also before the LoadTreeType procedure I have a var tree: Treetype; but in my script normal tree is also called tree would there be a problem with that? Should I change it to normaltree just in case?

11. Originally Posted by Spandzbab
Would something like this work? Is it connected to what the player choice of tree was? Also before the LoadTreeType procedure I have a var tree: Treetype; but in my script normal tree is also called tree would there be a problem with that? Should I change it to normaltree just in case?
No need because the record is not called treeDTM, it is called tree.TreeDTM <- which I doubt is the name of the nromal tree DTM

12. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Originally Posted by abu_jwka
No need because the record is not called treeDTM, it is called tree.TreeDTM <- which I doubt is the name of the nromal tree DTM
Overall would this bit of the script work? Like will the script know what tree the user has chosen to chop?

Btw I can't add rep to you for some reason, when I can I will.

13. Originally Posted by Spandzbab
Overall would this bit of the script work? Like will the script know what tree the user has chosen to chop?
Yes it will.

Notice how in your procedure it says:
Simba Code:
case lowercase(Players[CurrentPlayer].Strings[0]) of
So whatever the player has put as Strings[0], it will locate which tree.TreeDTM to use.

Also just noticed, you never changed the variables for your willow and maple trees, it still says food.FoodColour

14. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Originally Posted by abu_jwka
Yes it will.

Notice how in your procedure it says:
Simba Code:
case lowercase(Players[CurrentPlayer].Strings[0]) of
So whatever the player has put as Strings[0], it will locate which tree.TreeDTM to use.

Also just noticed, you never changed the variables for your willow and maple trees, it still says food.FoodColour
Ok thank you for your help , if I have another problem can I pm you with it if your online?

Oh and do the tree.treecolour stay the same for all trees or should it be like this:
Tree.OakColour
or
Oak.TreeColour
or
Oak.OakColour?

Sorry for so many questions :P
Last edited by Spandzbab; 05-01-2012 at 09:06 PM.

15. Originally Posted by Spandzbab
Ok thank you for your help , if I have another problem can I pm you with it if your online?

Oh and do the tree.treecolour stay the same for all trees or should it be like this:
Tree.OakColour
or
Oak.TreeColour
or
Oak.OakColour?

Sorry for so many questions :P
Tree.TreeColour.

Also you can pm me if you want, just don't be too reliant on me replying

16. I suggest reading a quick tutorial on types/records, in regards to your Tree.XYZ questions. They're really nifty stuff, and super useful. Not to mention it's a nice little starter to OOP, which is pretty useful.

17. SRL Junior Member
Join Date
Mar 2012
Posts
40
Mentioned
0 Post(s)
Quoted
3 Post(s)
Originally Posted by nickrules
I suggest reading a quick tutorial on types/records, in regards to your Tree.XYZ questions. They're really nifty stuff, and super useful. Not to mention it's a nice little starter to OOP, which is pretty useful.
I've read Abu's tutorial on records, been following that just making sure I've done everything correctly .