Results 1 to 6 of 6

Thread: function findcentreroad(Rcolor : integer; x1,y1,x2,y2:integer; tol :integer):boolean;

  1. #1
    Join Date
    Feb 2006
    Location
    With mooncow on the moon
    Posts
    292
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default function findcentreroad(Rcolor : integer; x1,y1,x2,y2:integer; tol :integer):boolean;

    hi,
    im not sure why i made this but it should find the centre of a road or any object and the click it (it should )

    *edit* i remember why i made it know , im going to make some walking procedures

    Code:
    
    program findcentreroad;
    {.include SRL\SRL.scar}
    
    
    function findcentreroad(Rcolor : integer; x1,y1,x2,y2:integer; tol :integer):boolean;
    var
      spaces ,x, y, ys, xs :integer;
      a, b, c ,cent ,back :integer;
      n, e , s, w :integer;
      dir:string;
    begin
    c:=0;
     ys:=0;
       xs:=0;
         if (FindColorTolerance(x, y, RColor, x1, y1, x2, y2, tol)) then
           begin
             Mmouse(x,y,3,4)
               getmousepos(a,b)
                cent:=a; back:=b;
                 begin
                  dir:='North';
                   spaces:=0;
                   repeat
                  c:=c-1;
                 movemousesmooth(a,b + c)      Getmousepos(x,y)
               wait(250+random(50))
             spaces:=spaces+1;
           until(not(getcolor(x,y) =Rcolor)or(spaces=20))
          n:=spaces;
        begin
      Mmouse(cent,back,0,0)
       dir:='South';
        spaces:=0;
         c:=1;
          repeat
            c:=c+1;
             movemousesmooth(a,b + c)          Getmousepos(x,y)
              wait(250+random(50))
               spaces:=spaces+1;
                 until(not(getcolor(x,y) =Rcolor)or(spaces=20))
                s:=spaces;
               begin
              Mmouse(cent,back,0,0)
             dir:='East';
            spaces:=0;
           c:=1;
          repeat
         c:=c+1;
        movemousesmooth(a -c, b)               Getmousepos(x,y)
       wait(250+random(50))
      spaces:=spaces+1;
     until(not(getcolor(x,y) =Rcolor)or(spaces=20))
    e:=spaces;
     begin
      Mmouse(cent,back,0,0)
       dir:='west';
         spaces:=0;
           c:=0;
            repeat
             c:=c-1;
              movemousesmooth(c, b)               Getmousepos(x,y)
               wait(250+random(50))
              spaces:=spaces+1;
             until(not(getcolor(x,y) =Rcolor)or(spaces=20))
           w:=spaces;
       begin
       cent:=n/s
     back:=e/w
    a:=a+cent;
      b:=b+back;
       mouse(a,b,0,0,true)
        flag;
         end;
           end;
             end;
           end;
         end;
       end;
    end;

  2. #2
    Join Date
    Feb 2006
    Posts
    920
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by solemn wishes
    hi,
    im not sure why i made this but it should find the centre of a road or any object and the click it (it should )

    *edit* i remember why i made it know , im going to make some walking procedures

    Code:
    ............
    I must say that is some pretty detectable procedure- does it need to move the mouse every time or is it on dev status ?

  3. #3
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Thanks, always good to have people post their stuff here.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  4. #4
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    Hey man,

    I think you are doing a great job, really, like I said before, both public and private
    However, I think you will need to climb out of your Ivory Tower and start learning from others. I hardly ever script anymore, I just borrow from my own library or from other scripters!

    You will need to learn a couple of concepts:
    1. Vars are ALWAYS FALSE or 0, unless you assign them true or a value.
    so, dont do s:=0; or Result:=False; in the beginning of a procedure, because it already is 0 and False.
    2. Work on identing, it makes reading so much more comfortable. Regret to say, but I am having a hard time reading your code, please, please reformat
    3. Understand the concept of a function returning values: var.
    4. Work longer on one Function. Before I design a function or script, I first try to make a clear picture of it's logic before I start coding. Remember: it is not the Quantity, but the Quality that counts.
    5. If you want to be a DemiGod of the Scripting society, you really should start working on the abovementioned!

    General Tips:

    If have access to a Printer, please print out every major script you can get your hands on.
    Study them hard, take a Marker, mark thing you do or dont understand. try to understand the scripters logic.
    Think about programmatic problems during daily routines: while biking to school for instance....
    You will do fine!

    Ow, and try to understand SRL, try to work with it. It is really easy to work with once you get the feeling for it

    Keep 'm up!, and redo your functions

    P.S.

    Don't be sad, Solemn Wishes, I greatly appreciate your presence here and I admire your persistence!

    Code:
    program New;
    {.include SRL/SRL.scar}
    
    //----------------------------------------------------------------------------//
    // FindMonsterTol will Scan box for a Monster with Name, Color and Tolerance.
    // Outputs True if found + the coordinates of the monster.
    //----------------------------------------------------------------------------//
    
    Function FindMonsterTol(var Mx,My:integer; MonsterName: String; monstercolor, x1, y1, x2, y2, tol:integer):boolean;
    var
      c:integer;
    
    begin
      if(FindColorSpiralTolerance(x,y,monstercolor,x1,y1,x2,y2,tol))Then
      begin
        if IsUpText(MonsterName) then
        begin
          Mmouse(x,y,5,4);
          Mx:=x;
          My:=y;
          Result:=true;
          Exit;
        end;
      end
      else
      begin
        repeat
          wait(500+random(500))
          c:=c+1;
          if(FindColorSpiralTolerance(x,y,monstercolor,x1,y1,x2,y2,c))then
          begin
            if IsUpText(MonsterName) then
            begin
              Mmouse(x,y,5,4);
              Mx:=x;
              My:=y;
              Result:=true;
              Exit;
            end;
          end;
        until Result or(c>=tol);
      end;
      if not Result then
        Writeln('Monster NOT Found');
    end;
    
    //-----Main Loop----//
    
    begin
      SetupSRL;
      FindMonsterTol(x,y,'Name',1345684,MSX1,MSY1,MSX2,MSY2,50);
    end.
    This is your original code:
    Code:
    function monstertolerance(xcord1,ycord1,xcord2,ycord2:integer):boolean;
    var c,tolmonster,tol:integer;
     begin
       tol:=0;
      c:=0;
    if(FindColorSpiralTolerance(x,y,monster,xcord1,ycord1,xcord2,ycord2,tol))Then
      begin
        Mmouse(x,y,5,4)
          writeln('//////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\')
         writeln('   Monster visable on screen, no tolerance needed')
       writeln('//////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\')
     found:=true;
    end;
       if(found=false)then
          begin
            writeln('//////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\')
           writeln('        No monster is visable on the screen')
          writeln('          Creating a monster tolerance')
        writeln('//////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\')
      monsterfound:=false;
     tolmonster:=monster;
    repeat
     wait(500+random(500))
      tol:=tol+1;
        c:=c+1;
       writeln('monster color :'+inttostr(tolmonster))
      if(FindColorSpiralTolerance(x,y,tolmonster,xcord1,ycord1,xcord2,ycord2,tol))then
    begin
      monsterfound:=true;
        Mmouse(x,y,5,4)
      end;
        until(monsterfound=true)or(c=30)
      if(c=30)then
        writeln('')
          writeln('//////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\')
             writeln('')
               writeln('Increased tolerance to 30, monster is still not visable')
             writeln('   Unable to find the monster, color may be wrong')
          writeln('')
       writeln('//////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\')
      result:=false;
     end;
    end;
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  5. #5
    Join Date
    Feb 2006
    Posts
    381
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    or, you just use FindColorSpiral2 for finding the center of a color. and you don't need a writeln('') in your procedures i find it very un-pleasing to the eye.

  6. #6
    Join Date
    Feb 2006
    Posts
    920
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by WT-Fakawi
    Think about programmatic problems during daily routines: while biking to school for instance....
    Jesus christ are you a female or what? Othervise you may have noticed that it's impossible for lads to multi-task. That's why I never script and walk to dog on the same time *like in my mind*.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. function SendKeyboard(FKey:Integer; Text:String): Integer;
    By Daniel in forum Research & Development Lounge
    Replies: 4
    Last Post: 07-18-2007, 04:28 PM

Posting Permissions

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