Results 1 to 8 of 8

Thread: 1st time scripting help

  1. #1
    Join Date
    May 2012
    Posts
    51
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default 1st time scripting help

    I just got done following the tutorial on how to make a simple woodcutter script. I am now attempting to add walking and banking to the procedure but every time I add the walking function, it either gets ignored, or walking is the only thing the script will do. I used the path creator program to get my walking coordinates.

    Any help is greatly appreciated!

    HTML Code:
    program new;
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    
    Procedure DeclarePlayers;
    begin
     HowManyPlayers := 1;
     NumberOfPlayers(HowManyPlayers);
     CurrentPlayer := 0;
    
     Players[0].Name :='';
     Players[0].Pass :='';
     Players[0].Nick :='';
     Players[0].Active:=True;
     Players[0].Pin :=''
    end;
    
    
    procedure AntiBan;
    begin
       if(not(LoggedIn))then
       Exit;
       case Random(8) of
        0:
        begin
          HoverSkill('woodcutting', false);
          wait(2453+Random(432));
        end;
        1: PickUpMouse;
        2:
        begin
          MakeCompass('N');
          wait(100+random(133));
          MakeCompass('S');
          wait(50+random(133));
          MakeCompass('N');
        end;
      end;
    end;
    
    
    Procedure ChopTree;
    var x, y: integer;
    begin
      repeat
      if FindObj(x,y,'hop',1384479, 05) then
      begin
        Mouse(x, y, 2, 2, false);
        ChooseOption('hop');
      end;
        repeat
          Wait(400+random(250));
          AntiBan;
        Until not IsUpText('ew') or (InvFull);
     until(invFull);
       end;
    
    Procedure Walk;
    Var
      myPath:TPointArray;
    begin
      SetupSRL;
      SPS_Setup(RUNESCAPE_SURFACE,['11_7']);
      myPath :=[Point(4497, 3032), Point(4500, 3029), Point(4503, 3026), Point(4509, 3008), Point(4509, 3008), Point(4509, 3003), Point(4509, 2998), Point(4510, 2992), Point(4512, 2981), Point(4516, 2970), Point(4516, 2964), Point(4522, 2949), Point(4522, 2949), Point(4525, 2948), Point(4528, 2945), Point(4531, 2943), Point(4535, 2942), Point(4542, 2939), Point(4548, 2939), Point(4553, 2938), Point(4560, 2935), Point(4564, 2933), Point(4571, 2929), Point(4576, 2923), Point(4581, 2915), Point(4582, 2911), Point(4588, 2908), Point(4593, 2908)];//Path
      SPS_WalkPath(myPath);
    end;
    
    
    begin
     SetUpSRL;
     ActivateClient;
     DeclarePlayers;
     LoginPlayer;
     ChopTree;
    end.

  2. #2
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Add
    Simba Code:
    Walk;

    after the

    Simba Code:
    ChopTree;

    EG:

    Simba Code:
    begin
     SetUpSRL;
     ActivateClient;
     DeclarePlayers;
     LoginPlayer;
     ChopTree;
     Walk;
    end.

    Forum account issues? Please send me a PM

  3. #3
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    I noticed that your walk procedure is never actually called in the MainLoop, put it after ChopTree;

    E:`d

  4. #4
    Join Date
    Dec 2009
    Posts
    380
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Also, I don't know if it'll make a difference, but you may want to add more areas of the runescape surface to load. Just a single one (you're using 11_7) may not be enough. Make sure the map covers the entire path, AND some space around it. I don't know what map 11_7 is but I don't know if it'll cover your trees, path, AND bank all in the single map.

    Use a path creator, make your path, and copy that. THEN click on points circling the path and copy the area.
    Currently: Playing OSRS legit until I get bored

  5. #5
    Join Date
    Nov 2012
    Posts
    2,351
    Mentioned
    55 Post(s)
    Quoted
    603 Post(s)

    Default

    Try never to call SPS_SetUp(x) more than once in the code too, that can cause problems, so move it to its own procedure before the main loop and out of Walk;


    Programming is like trying keep a wall of shifting sand up, you fix one thing but somewhere else starts crumbling

  6. #6
    Join Date
    May 2012
    Posts
    51
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by DannyRS View Post
    Try never to call SPS_SetUp(x) more than once in the code too, that can cause problems, so move it to its own procedure before the main loop and out of Walk;
    I do not know what you mean by this?

    I am having a real hard time deciphering exactly how to script. I've been staring at tutorials for two days now.

    I have given up on the walking part for now and I am working on adding banking instead.

    I am having trouble with using functions.

    When I copy and paste the OpenBankNPC function into my script I just get a duplicate identifier error at line 69.

    Code:
    program new;
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    
    Procedure DeclarePlayers;
    begin
     HowManyPlayers := 1;
     NumberOfPlayers(HowManyPlayers);
     CurrentPlayer := 0;
    
     Players[0].Name :='';
     Players[0].Pass :='';
     Players[0].Nick :='';
     Players[0].Active:=True;
     Players[0].Pin :=''
    end;
    
    
    procedure AntiBan;
    begin
       if(not(LoggedIn))then
       Exit;
       case Random(8) of
        0:
        begin
          HoverSkill('woodcutting', false);
          wait(2453+Random(432));
        end;
        1: PickUpMouse;
        2:
        begin
          MakeCompass('N');
          wait(100+random(133));
          MakeCompass('S');
          wait(50+random(133));
          MakeCompass('N');
        end;
      end;
    end;
    
    
    Procedure ChopTree;
    var x, y: integer;
    begin
      repeat
      if FindObj(x,y,'hop',1384479, 05) then
      begin
        Mouse(x, y, 2, 2, false);
        ChooseOption('hop');
      end;
        repeat
          Wait(400+random(250));
          AntiBan;
        Until not IsUpText('ew') or (InvFull);
     until(invFull);
       end;
    
    Procedure Walk;
    Var
      myPath:TPointArray;
    begin
      SetupSRL;
      SPS_Setup(RUNESCAPE_SURFACE,['11_7']);
      myPath :=[Point(4497, 3032), Point(4500, 3029), Point(4503, 3026), Point(4509, 3008), Point(4509, 3008), Point(4509, 3003), Point(4509, 2998), Point(4510, 2992), Point(4512, 2981), Point(4516, 2970), Point(4516, 2964), Point(4522, 2949), Point(4522, 2949), Point(4525, 2948), Point(4528, 2945), Point(4531, 2943), Point(4535, 2942), Point(4542, 2939), Point(4548, 2939), Point(4553, 2938), Point(4560, 2935), Point(4564, 2933), Point(4571, 2929), Point(4576, 2923), Point(4581, 2915), Point(4582, 2911), Point(4588, 2908), Point(4593, 2908)];//Path
      SPS_WalkPath(myPath);
    end;
    
    function OpenBankNPC: Boolean;
    var
      NPCBox :TBox;
      Colors, NPCArray :TPointArray;
      ATPA: T2DPointArray;
      MSNPC, NPCPoint :TPoint;
      CTS, C, II, I :Integer;
    begin
      Result := False;
      Result := (BankScreen) or (PinScreen);
      If Result then
        Exit;
      NPCArray := GetMinimapDots('NPC');
      If Length(NPCArray) < 1 then
        Exit;
      SortTPAFrom(NPCArray, Point(MMCX, MMCY));
      for I := 0 to High(NPCArray) do
      begin
        NPCPoint := MMToMS(NPCArray[I])
        If (NPCPoint.x = -1) and (NPCPoint.y = -1) then
          Continue;
        with NPCPoint do
          NPCBox := IntToBox(Max(X - 40, MSX1), Max(Y - 40, MSY1), Min(X + 40, MSX2), Min(Y + 40, MSY2));
        If PixelShift(NPCBox, 200) > 500 then
          Continue;
    
        CTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        SetColorSpeed2Modifiers(0.13, 1.52);
        FindColorsTolerance(Colors, 6067652, NPCBox.X1, NPCBox.Y1, NPCBox.X2, NPCBox.Y2, 13);
        SetColorSpeed2Modifiers(0.2, 0.2);
        ColorToleranceSpeed(CTS);
        ATPA := TPAToATPAEx(Colors, 15, 20);
        SortATPASize(ATPA, True);
    
        for II := 0 to High(ATPA) do
        begin
          MSNPC := MiddleTPA(ATPA[II]);
          MMouse(MSNPC.X, MSNPC.Y, 3, 3);
          If WaitUpTextMulti(['ooth', 'anker'], 200) then
          begin
            ClickMouse2(False);
            If WaitOptionMulti(['Bank B', 'nk B'], 600) then
              MarkTime(c);
            Repeat
              Wait(RandomRange(50, 100));
            Until (BankScreen) or (PinScreen) or (TimeFromMark(C) > 4500);
            if (Players[CurrentPlayer].Pin <> '') then
              InPin(Players[CurrentPlayer].Pin);
            Result := (BankScreen) or (PinScreen);
            If Result then
              Exit;
          end;
        end;
      end;
    end;
    
    
    begin
     SetUpSRL;
     ActivateClient;
     DeclarePlayers;
     LoginPlayer;
     ChopTree;
     Walk;
     OpenBankNPC;
    end.
    I wrote line 69 in red.


    The error
    HTML Code:
    [Error] C:\Simba\Scripts\(2).simba(70:10): Duplicate identifier 'OPENBANKNPC' at line 69
    Compiling failed.

    I use the search tool to find solutions, it is just a matter of my brain understanding the logic.

    This tells me the problems behind the duplicate identifier.
    http://villavu.com/forum/showthread....ate+identifier

    This explains to me what procedures/ functions/ variables/ etc are. But I just can't grasp the meaning behind it all.
    http://villavu.com/forum/showthread.php?t=58935
    Last edited by Ann_arbor; 12-09-2012 at 11:46 PM.

  7. #7
    Join Date
    Mar 2007
    Posts
    5,125
    Mentioned
    275 Post(s)
    Quoted
    901 Post(s)

    Default

    Quote Originally Posted by Ann_arbor View Post
    I do not know what you mean by this?

    I am having a real hard time deciphering exactly how to script. I've been staring at tutorials for two days now.

    I have given up on the walking part for now and I am working on adding banking instead.

    I am having trouble with using functions.

    When I copy and paste the OpenBankNPC function into my script I just get a duplicate identifier error at line 69.

    Code:
    program new;
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    
    Procedure DeclarePlayers;
    begin
     HowManyPlayers := 1;
     NumberOfPlayers(HowManyPlayers);
     CurrentPlayer := 0;
    
     Players[0].Name :='';
     Players[0].Pass :='';
     Players[0].Nick :='';
     Players[0].Active:=True;
     Players[0].Pin :=''
    end;
    
    
    procedure AntiBan;
    begin
       if(not(LoggedIn))then
       Exit;
       case Random(8) of
        0:
        begin
          HoverSkill('woodcutting', false);
          wait(2453+Random(432));
        end;
        1: PickUpMouse;
        2:
        begin
          MakeCompass('N');
          wait(100+random(133));
          MakeCompass('S');
          wait(50+random(133));
          MakeCompass('N');
        end;
      end;
    end;
    
    
    Procedure ChopTree;
    var x, y: integer;
    begin
      repeat
      if FindObj(x,y,'hop',1384479, 05) then
      begin
        Mouse(x, y, 2, 2, false);
        ChooseOption('hop');
      end;
        repeat
          Wait(400+random(250));
          AntiBan;
        Until not IsUpText('ew') or (InvFull);
     until(invFull);
       end;
    
    Procedure Walk;
    Var
      myPath:TPointArray;
    begin
      SetupSRL;
      SPS_Setup(RUNESCAPE_SURFACE,['11_7']);
      myPath :=[Point(4497, 3032), Point(4500, 3029), Point(4503, 3026), Point(4509, 3008), Point(4509, 3008), Point(4509, 3003), Point(4509, 2998), Point(4510, 2992), Point(4512, 2981), Point(4516, 2970), Point(4516, 2964), Point(4522, 2949), Point(4522, 2949), Point(4525, 2948), Point(4528, 2945), Point(4531, 2943), Point(4535, 2942), Point(4542, 2939), Point(4548, 2939), Point(4553, 2938), Point(4560, 2935), Point(4564, 2933), Point(4571, 2929), Point(4576, 2923), Point(4581, 2915), Point(4582, 2911), Point(4588, 2908), Point(4593, 2908)];//Path
      SPS_WalkPath(myPath);
    end;
    
    function OpenBankNPC: Boolean;
    var
      NPCBox :TBox;
      Colors, NPCArray :TPointArray;
      ATPA: T2DPointArray;
      MSNPC, NPCPoint :TPoint;
      CTS, C, II, I :Integer;
    begin
      Result := False;
      Result := (BankScreen) or (PinScreen);
      If Result then
        Exit;
      NPCArray := GetMinimapDots('NPC');
      If Length(NPCArray) < 1 then
        Exit;
      SortTPAFrom(NPCArray, Point(MMCX, MMCY));
      for I := 0 to High(NPCArray) do
      begin
        NPCPoint := MMToMS(NPCArray[I])
        If (NPCPoint.x = -1) and (NPCPoint.y = -1) then
          Continue;
        with NPCPoint do
          NPCBox := IntToBox(Max(X - 40, MSX1), Max(Y - 40, MSY1), Min(X + 40, MSX2), Min(Y + 40, MSY2));
        If PixelShift(NPCBox, 200) > 500 then
          Continue;
    
        CTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        SetColorSpeed2Modifiers(0.13, 1.52);
        FindColorsTolerance(Colors, 6067652, NPCBox.X1, NPCBox.Y1, NPCBox.X2, NPCBox.Y2, 13);
        SetColorSpeed2Modifiers(0.2, 0.2);
        ColorToleranceSpeed(CTS);
        ATPA := TPAToATPAEx(Colors, 15, 20);
        SortATPASize(ATPA, True);
    
        for II := 0 to High(ATPA) do
        begin
          MSNPC := MiddleTPA(ATPA[II]);
          MMouse(MSNPC.X, MSNPC.Y, 3, 3);
          If WaitUpTextMulti(['ooth', 'anker'], 200) then
          begin
            ClickMouse2(False);
            If WaitOptionMulti(['Bank B', 'nk B'], 600) then
              MarkTime(c);
            Repeat
              Wait(RandomRange(50, 100));
            Until (BankScreen) or (PinScreen) or (TimeFromMark(C) > 4500);
            if (Players[CurrentPlayer].Pin <> '') then
              InPin(Players[CurrentPlayer].Pin);
            Result := (BankScreen) or (PinScreen);
            If Result then
              Exit;
          end;
        end;
      end;
    end;
    
    
    begin
     SetUpSRL;
     ActivateClient;
     DeclarePlayers;
     LoginPlayer;
     ChopTree;
     Walk;
     OpenBankNPC;
    end.
    I wrote line 69 in red.


    The error
    HTML Code:
    [Error] C:\Simba\Scripts\(2).simba(70:10): Duplicate identifier 'OPENBANKNPC' at line 69
    Compiling failed.

    I use the search tool to find solutions, it is just a matter of my brain understanding the logic.

    This tells me the problems behind the duplicate identifier.
    http://villavu.com/forum/showthread....ate+identifier

    This explains to me what procedures/ functions/ variables/ etc are. But I just can't grasp the meaning behind it all.
    http://villavu.com/forum/showthread.php?t=58935

    What the duplicate identifier for 'OpenBankNPC' means is that the procedure\function 'OpenBankNPC' has already been coded somewhere else (In the script\include\plugin), in this case, It's already been scripted into the SRL include so you wont need the full procedure\function in your script, you are able to just call 'OpenBankNPC' and it will do its procedure\function.

    Forum account issues? Please send me a PM

  8. #8
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    duplicate identifier:

    Basically When you write a script the bit at the top $i Include is opening another simba file with a load of code other people have written... cool huh? So by copying and pasting
    OpenBankNPC you have 2 copies of the same code

    Try naming OpenBankNPC to OpenNPCBank

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •