Results 1 to 4 of 4

Thread: how to repeat until an action is carried out

  1. #1
    Join Date
    Oct 2016
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default how to repeat until an action is carried out

    Hi so im still quite new to scripting but I am looking to make a safeguard in my script to make sure it doesn't skip until the action is complete.

    I made one safeguard for talking to my npc

    procedure clicknpc();
    var
    x, y, i: integer;
    begin
    if not isLoggedIn() then
    exit;

    repeat

    mainscreen.findObject(x, y, 3163475, 18, colorSetting(2, 0.05, 0.32), mainscreen.playerPoint, 8, 25, 20, ['npc'], MOUSE_LEFT);
    wait(randomRange(1000, 2000));
    inc(i);

    until conversationBox.isOpen();
    end;



    but I am wondering if I can do it for other actions... specifically making sure that I find the door and actually open the door before continuing.


    procedure clickDoor();
    var
    x, y: integer;

    repeat

    if mainscreen.findObject(x, y, 407630, 5, ['oor'], MOUSE_RIGHT) then
    begin
    writeLn('We right clicked the door!');
    chooseOption.select(['pen']);

    until
    (This is the part where I am having trouble)


    end;
    end;



    What I am wanting is to write a script saying repeat trying to find and click door until ... you have clicked the object. I'm not sure if I am making sense in my question. Thanks!

  2. #2
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    You could probably do something like this. May want to add a timeout though, so you don't get stuck in the loop. Goodluck

    Simba Code:
    function clickDoor(): boolean;
    var
      x, y: integer;
    begin
      result := false;
      repeat
        if mainscreen.findObject(x, y, 407630, 5, ['oor'], MOUSE_RIGHT) then
        begin
          writeLn('We right clicked the door!');
          if chooseOption.select(['pen']) then
            result := true;
        end;
      until (result = true);
    end;

  3. #3
    Join Date
    Oct 2016
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Awesome, Thanks a lot!

  4. #4
    Join Date
    Oct 2016
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    You can go even simpler than @jstemper's solution.
    Because chooseoption.select() returns true or false, you can say:

    Simba Code:
    function clickDoor(): boolean;
    var
      x, y: integer;
    begin
      result := false;
      repeat
        if mainscreen.findObject(x, y, 407630, 5, ['oor'], MOUSE_RIGHT) then
          writeLn('We right clicked the door!');
      until chooseOption.select(['pen']);
    end;

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
  •