Results 1 to 5 of 5

Thread: Problem when applying invcount and/or invfull

  1. #1
    Join Date
    Nov 2011
    Location
    Sweden
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Problem when applying invcount and/or invfull

    So, I've been crudescripting a wine of zamorak bot and when testing it yesterday i found that it jumped parts of the code for no obvious reason(that i can find atleast).
    the problem was that it ignored the InvFull and InvCount that i had included in the repeat and went on like the lines of code didnt exist. I've rewritten it atleast 20 times by now and still can't find the reason for it not working and thus i turn to you since your knowledge far exceeds when it comes to this

    the procedure as it is right now:

    Simba Code:
    Procedure WineGrabbing;
    var
      x, y, I, p: Integer;
      MyPos: TPoint;
    begin
      if (rs_GetCompassAngleDegrees <> 0) then
        begin
          ClickNorth(true);
          SetAngle(true);
        end else;
          begin
          SetAngle(true);
          end;

      MyPos := SPS_GetMyPos();
        if (MyPos.x <> 3545) and (MyPos.y <> 2575) then
        repeat
          SPS_WalkToPos(point(3545, 2575));
          wait(2000);
          MyPos := SPS_GetMyPos();
        until (MyPos.x = 3545) and (MyPos.y = 2575);
      o := 0
      repeat
        inc(o)
        if (o>25) then
        begin
          GameTab(tab_inv);
          for I := 1 to 28 do
            if (ExistsItem(I)) then
            Inc(p);
            o := ((o + p - 2) / 2)
        end;
        Gametab(tab_Magic);
        if (rs_GetCompassAngleDegrees <> 0) then
        begin
          ClickNorth(true);
          SetAngle(true);
        end;
          repeat
            x := RandomRange(614, 627)
            y := RandomRange(295, 310)
            MMouse(x, y, 3, 3);
            Mouse(x, y, 0, 0, True);
            wait(100 + RandomRange (100,450))
            x := RandomRange(213, 219)
            y := RandomRange(156, 161)
            MMouse(x, y, 3, 3);
            wait(50 + RandomRange (100,250))
          until IsUpText('elekinetic') = true;
        FindObject(x, y);
        wait(randomrange(194, 673));
        writeln('inventcount: ' + IntToStr(p));
        writeln('tries: ' + IntToStr(o));

      until (p = 27)

    end;

    earlier arrangements called invfull and broke loop when it turned true, also tried with using InvCount := p for example in the end of the script, which is preferable but didn't work either. don't get any errors while compiling but it wont even go as far as open the tab, only returns 0 as value, the rest of the script works without problems. Sorry for messy script...
    Last edited by PerryP; 11-18-2011 at 07:50 AM. Reason: tried to colour text in simbatag -_-

  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I for one am thoroughly confused...

    Simba Code:
    inc(o)
        if (o>25) then
        begin
          GameTab(tab_inv);
          for I := 1 to 28 do
            if (ExistsItem(I)) then
            Inc(p);
            o := ((o + p - 2) / 2)
        end;
    I don't understand this, what are you trying to figure here? Keep repeating the code in this loop until 'p' reaches 27? "until (p = 27)". What I usually do is, when creating 'repeat/until' loops is have "until" set forever, like so: "until(false)". That initiates an infinite loop. Now inside that loop, I put something like "if InvFull then break;", that will break out of the loop and continue with whatever code you have after that loop. Now if you use "Exit;" instead of 'Break;', it'll exit out of the loop and your whole procedure (WineGrabbing).

    Again, I'm really confused as to what you're saying, it's quite unclear. If you could give just a simple explanation of what you want it to do and what it's doing currently that'd be helpful.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  3. #3
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Well for one, P is never reset. So you'll pass over 27 and continue to go through, because what P is right now is like 1! + 2! + 3! + 4! etc. (except for addition and not multiplication), so what you need to do is reset P to 0 after every loop.

    But, InvCount should work. But really InvFull should work. Unless there was an update in the past few hours or something..

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

    Default

    1. You use fixed x and y ranges
    2. Then you hover random over the area until
    3. you find the uptext (In an endless loop)
    4. Then you do FindObject(x,y)


    I would do

    SCAR Code:
    repeat

       break when timeout

    until findobject;
    or


    Simba Code:
    repeat
      findobject;
    until timeout

    Also there is a very nice function FindObjTPA, that allows you to find colored areas in the runescape screen.
    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
    Nov 2011
    Location
    Sweden
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    Well for one, P is never reset. So you'll pass over 27 and continue to go through, because what P is right now is like 1! + 2! + 3! + 4! etc. (except for addition and not multiplication), so what you need to do is reset P to 0 after every loop.

    But, InvCount should work. But really InvFull should work. Unless there was an update in the past few hours or something..
    thought p was reset everytime the procedure was done, since it's not a global variable?


    Quote Originally Posted by WT-Fakawi View Post
    1. You use fixed x and y ranges
    2. Then you hover random over the area until
    3. you find the uptext (In an endless loop)
    4. Then you do FindObject(x,y)


    I would do

    SCAR Code:
    repeat

       break when timeout

    until findobject;
    or


    Simba Code:
    repeat
      findobject;
    until timeout

    Also there is a very nice function FindObjTPA, that allows you to find colored areas in the runescape screen.
    1. the clicking of the telegrab spell?
    2. A human would never stay as the spellbutton until spawn so i ´move mouse to the are of the spawn
    3. the uptext for the spell since there's always a risk that the click on the spell didn't work and this avoids thatyou click the wine without it...
    4. the findobject function is written to search in the area the wine respawns only to reduce timebefore identify


    since i need the search and click to repeat until inventory is full i have built it so that it repeats until inventory fills, i will add a timeout aswell as a failsafe as soon as i get it to work with checking the inventory.

    will lock at the FindObjTPA when i get my own pc back on sunday. the best would probably have been to meassure colourchange in an area since that would speed up the process of checking when the item spawn...


    Quote Originally Posted by Flight View Post
    I for one am thoroughly confused...

    Simba Code:
    inc(o)
        if (o>25) then
        begin
          GameTab(tab_inv);
          for I := 1 to 28 do
            if (ExistsItem(I)) then
            Inc(p);
            o := ((o + p - 2) / 2)
        end;
    I don't understand this, what are you trying to figure here? Keep repeating the code in this loop until 'p' reaches 27? "until (p = 27)". What I usually do is, when creating 'repeat/until' loops is have "until" set forever, like so: "until(false)". That initiates an infinite loop. Now inside that loop, I put something like "if InvFull then break;", that will break out of the loop and continue with whatever code you have after that loop. Now if you use "Exit;" instead of 'Break;', it'll exit out of the loop and your whole procedure (WineGrabbing).

    Again, I'm really confused as to what you're saying, it's quite unclear. If you could give just a simple explanation of what you want it to do and what it's doing currently that'd be helpful.

    When i get my pc back on sunday i will explain more thoroughly every step of the procedure, sorry.

    o increases every time it atempt to get 1 wine.
    when o reaches 25(tried 25 times) it checks the inventory (since no human would check inventory every time they cast the telegrab-spell)
    number of full inventoryspaces := p
    o is reduced so that it will check inventory again first when there has been a possibility to fill the remaining spots in the inventory)

    hmm,should probably have p>26 or preferably put the check after the find object to be able to break when p=28(since inv cant have more places then 28...)

    On sunday evening (CET) i will get my pc with the script back and then i can explain it better.

    Thank you for your help so far all of you

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
  •