Results 1 to 8 of 8

Thread: Emp

  1. #1
    Join Date
    Nov 2013
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default Emp

    So I am working on my first script, and it's not easy.

    But I've decided if I can solve one problem at a time, I may eventually get a working copy out there.

    The issue I am currently experiencing is that the script doesn't seem to know when it has a full inventory or not.

    The code I am using.

    Code:
    //=========================================\\
    //                                         \\
    //            INV FULL CHECK               \\
    //                                         \\
    //=========================================\\
    function InvFull() : Boolean;
    begin
      if not isLoggedIn() then
        exit;
    
      if (tabBackpack.isFull()) then
      begin
        writeln('Inv Full!');
        result := true;
      end;
    end;
    Example of how I am calling it.

    Code:
    if (GPS = 'Bank') and InvFull() then
    Any suggestions?

    Currently it will always try to deposit inventory.

  2. #2
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by AliveDrive View Post
    So I am working on my first script, and it's not easy.

    But I've decided if I can solve one problem at a time, I may eventually get a working copy out there.

    The issue I am currently experiencing is that the script doesn't seem to know when it has a full inventory or not.

    The code I am using.

    Code:
    //=========================================\\
    //                                         \\
    //            INV FULL CHECK               \\
    //                                         \\
    //=========================================\\
    function InvFull() : Boolean;
    begin
      if not isLoggedIn() then
        exit;
    
      if (tabBackpack.isFull()) then
      begin
        writeln('Inv Full!');
        result := true;
      end;
    end;

    Example of how I am calling it.

    Code:
    if (GPS = 'Bank') and InvFull() then
    Any suggestions?

    Currently it will always try to deposit inventory.

    There is no need for this whole function - tabBackpack.isFull() achieves exactly the same result

    Simba Code:
    if (GPS = 'Bank') and tabBackpack.isFull() then
    begin
      writeLn('We are at the bank with a full inventory');
      //do stuff
    end;

  3. #3
    Join Date
    Jul 2013
    Location
    An horse
    Posts
    300
    Mentioned
    9 Post(s)
    Quoted
    120 Post(s)

    Default

    It looks fine to me. It's either the way it checks if the inventory is full or the (GPS = 'Bank') part.
    Last edited by Foundry; 02-14-2014 at 11:19 PM. Reason: removed useless info.
    Currently lurking while messing around with dll injection. Will continue contributing after I finish my quest.

  4. #4
    Join Date
    Nov 2013
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    Thanks for the quick reply guys.

    Mayor, you're right but I figured out why it wasn't working.

    Your tutorial informed me that you always need a begin..end after an if..then if you have more than one command.

    The GPS code is something from another post I commented on, I need to make the script always know where it is.

    Code:
    //=========================================\\
    //                                         \\
    //                 GPS                     \\
    //               by Sjoe                   \\
    //=========================================\\
    function GPS(): String;
    var
      p: Tpoint;
    begin
      if (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) then
          Result := 'Bank';
    
      if (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) then
          Result := 'Shop';
    
      if not (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) or not (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) then
          begin
          Result := 'Cave';
          inEssCheck;
          end;
    end;

  5. #5
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by AliveDrive View Post
    Thanks for the quick reply guys.

    Mayor, you're right but I figured out why it wasn't working.

    Your tutorial informed me that you always need a begin..end after an if..then if you have more than one command.

    The GPS code is something from another post I commented on, I need to make the script always know where it is.

    Code:
    //=========================================\\
    //                                         \\
    //                 GPS                     \\
    //               by Sjoe                   \\
    //=========================================\\
    function GPS(): String;
    var
      p: Tpoint;
    begin
      if (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) then
          Result := 'Bank';
    
      if (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) then
          Result := 'Shop';
    
      if not (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) or not (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) then
          begin
          Result := 'Cave';
          inEssCheck;
          end;
    end;
    after you have your result you can exit the function

    Result := 'Bank';
    Exit;

    you can check where you are by using this in other procedures if(Result = 'Bank') then

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  6. #6
    Join Date
    Nov 2013
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default

    So the code I am trying to use now looks like this.

    Code:
    //=========================================\\
    //                                         \\
    //                 GPS                     \\
    //               by Sjoe                   \\
    //=========================================\\
    function GPS(): String;
    var
      p: Tpoint;
    begin
      if (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) and distance(minimap.getCenterPoint(), p) < 5 then
          Result := 'Bank';
          exit;
    
      if (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) and distance(minimap.getCenterPoint(), p) < 5 then
          Result := 'Shop';
          exit;
    
      if not (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) and not (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) then
          Result := 'Cave';
          exit;
    end;
    Is checking the distance from the symbol unnecessary?

    This is how I am trying to use it. Is this incorrect?

    Code:
    procedure mainLoop;
    begin
      repeat
        if not isLoggedIn then
          playerSetup;
    //A SPACE GOES HERE!!!!!!!!!!!!
          GPS; //EDIT! Remember kids, scripting is a black-hearted siren.
    
        if (GPS = 'Bank') and (tabBackpack.isFull()) then
          begin
          findBanker;
          depositEss;
          end;
    
        if (GPS = 'Bank') and (not tabBackpack.isFull()) then
          begin
          walkToAubury;
          end;
    Last edited by AliveDrive; 02-15-2014 at 12:52 AM.

  7. #7
    Join Date
    Jul 2013
    Location
    An horse
    Posts
    300
    Mentioned
    9 Post(s)
    Quoted
    120 Post(s)

    Default

    Quote Originally Posted by Sk1nyNerd View Post
    after you have your result you can exit the function

    Result := 'Bank';
    Exit;

    you can check where you are by using this in other procedures if(Result = 'Bank') then
    With Lape you can also do exit(whatever your result is here).

    Simba Code:
    exit('Bank');
    Currently lurking while messing around with dll injection. Will continue contributing after I finish my quest.

  8. #8
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by AliveDrive View Post
    So the code I am trying to use now looks like this.

    Code:
    //=========================================\\
    //                                         \\
    //                 GPS                     \\
    //               by Sjoe                   \\
    //=========================================\\
    function GPS(): String;
    var
      p: Tpoint;
    begin
      if (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) and distance(minimap.getCenterPoint(), p) < 5 then
          Result := 'Bank';
          exit;
    
      if (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) and distance(minimap.getCenterPoint(), p) < 5 then
          Result := 'Shop';
          exit;
    
      if not (minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds)) and not (minimap.findSymbol(p, MM_SYMBOL_SHOP_MAGIC, minimap.getBounds)) then
          Result := 'Cave';
          exit;
    end;
    ...
    You forgot begin end, since you have more then one statement after the "if"'s.
    Code:
    ...
      if (Minimap.FindSymbol(p, MM_SYMBOL_BANK, Minimap.GetBounds)) and (Distance(Minimap.GetCenterPoint(), p) < 5) then
      begin
        Result := 'Bank';
        Exit();
      end;
    ...
    Better option is mentioned above, and will look something like this:
    Code:
    ...
      if (Minimap.FindSymbol(p, MM_SYMBOL_BANK, Minimap.GetBounds)) and (Distance(Minimap.GetCenterPoint(), p) < 5) then
        Exit('Bank');
    ...
    !No priv. messages please

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
  •