Results 1 to 11 of 11

Thread: Using break;

  1. #1
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default Using break;

    Hi,

    Whatever I try, I can't use the 'break;' statement.

    Code:
    Error: Cannot break out of this statement at line 137
    Compiling failed.
    I have a global variable (isQuickKeySet), and if it is set I want it to break out of the loop.

    Simba Code:
    if not (isQuickKeySet) then
      break;

    My full code is:

    Simba Code:
    if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
        if bankScreen.isOpen(1000) then
          bankScreen.clickButton(BANK_BUTTON_PRESET_1);
      tabBackpack.waitWhileLocked(1000);
      if not (tabBackpack.isFull) then
      TerminateScript();

      if not (isQuickKeySet) then
      begin
        tabBackPack.mouseSlot(1, MOUSE_MOVE);
        dragMouse(actionBar.getSlotBox(1).getRandomPoint());
        isQuickKeySet := true;
      end;

      typeSend('1', false);

      if productionScreen.isOpen(1000) then
        productionScreen.clickStart(true);

      if not (tabBackpack.waitSlotPixelChange(4, 3000)) then
        exit;

      repeat
        antiBan(1500);
        Wait(750);
      until tabBackpack.waitSlotPixelChange(28, 18000);
      wait(gaussRangeInt(500, 750));

    But it always fails to typesend 1, somehow it isn't called after this lines. Is that because it doesn't break properly? Because it just waits for a bit and than starts banking again.

    Thanks in advance!

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

    Default

    Quote Originally Posted by SlipperyPickle View Post

    I want it to break out of the loop.

    Simba Code:
    if not (isQuickKeySet) then
      begin
        tabBackPack.mouseSlot(1, MOUSE_MOVE);
        dragMouse(actionBar.getSlotBox(1).getRandomPoint());
        isQuickKeySet := true;
      end;
    What loop?

  3. #3
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    What loop?
    Not a loop, I tried to explain it wrong. Sorry!

    After the first part: "is not (isQuickKeySet)", the part "typeSend('1', false);" isn't called.

    Simba Code:
    if not (isQuickKeySet) then
      begin
        tabBackPack.mouseSlot(1, MOUSE_MOVE);
        dragMouse(actionBar.getSlotBox(1).getRandomPoint());
        isQuickKeySet := true;
      end;

      typeSend('1', false);

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

    Default

    Quote Originally Posted by SlipperyPickle View Post
    Not a loop, I tried to explain it wrong. Sorry!

    After the first part: "is not (isQuickKeySet)", the part "typeSend('1', false);" isn't called.

    Simba Code:
    if not (isQuickKeySet) then
      begin
        tabBackPack.mouseSlot(1, MOUSE_MOVE);
        dragMouse(actionBar.getSlotBox(1).getRandomPoint());
        isQuickKeySet := true;
      end;

      typeSend('1', false);
    Wait so your question isn't about using break?

    You can only break out of a loop, so break must be inside one of the 3 loops:

    Simba Code:
    for 1 to 10 do
    begin
      break;
    end;

    repeat
      break;
    until false;

    while true do
    begin
      break;
    end;

  5. #5
    Join Date
    Jun 2014
    Location
    Lithuania
    Posts
    475
    Mentioned
    27 Post(s)
    Quoted
    200 Post(s)

    Default

    I think there is your problem.

    Simba Code:
    if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
        if bankScreen.isOpen(1000) then
          bankScreen.clickButton(BANK_BUTTON_PRESET_1);

    try do something like, or whenever you want it to stop. Personally i would just split your code to 2 functions to banking and after bank one. Now its difficult in this code to add failsafes especially taking in mind if exiting whole function would impact other functions whose depends on actions made not made there.

    Simba Code:
    if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
    begin
        if bankScreen.isOpen(1000) then
          bankScreen.clickButton(BANK_BUTTON_PRESET_1);
      tabBackpack.waitWhileLocked(1000);
      if not (tabBackpack.isFull) then
      TerminateScript();

      if not (isQuickKeySet) then
      begin
        tabBackPack.mouseSlot(1, MOUSE_MOVE);
        dragMouse(actionBar.getSlotBox(1).getRandomPoint());
        isQuickKeySet := true;
      end;

    end;

  6. #6
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Wait so your question isn't about using break?

    You can only break out of a loop, so break must be inside one of the 3 loops:

    Simba Code:
    for 1 to 10 do
    begin
      break;
    end;

    repeat
      break;
    until false;

    while true do
    begin
      break;
    end;
    Thanks! I tried to type my question to quick. The break part was another question. My question is why the second part isn't called. But I believe I've solved it, gonna try now.

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

    Default

    Quote Originally Posted by cosmasjdz View Post
    I think there is your problem.

    Simba Code:
    if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
        if bankScreen.isOpen(1000) then
          bankScreen.clickButton(BANK_BUTTON_PRESET_1);
    That is legit code, although the bs.isOpen() isn't needed as bs.open() returns true if it is open.

    Simba Code:
    if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
      bankScreen.clickButton(BANK_BUTTON_PRESET_1);

    And your typeSend looks like it will run no matter what? I hope you're not terminating the script because you're not giving waitWhileLocked enough time

  8. #8
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    That is legit code, although the bs.isOpen() isn't needed as bs.open() returns true if it is open.

    Simba Code:
    if bankScreen.open(BANK_CHEST_LUMBRIDGE) then
      bankScreen.clickButton(BANK_BUTTON_PRESET_1);

    And your typeSend looks like it will run no matter what? I hope you're not terminating the script because you're not giving waitWhileLocked enough time
    Lol, no the problem isn't that it hasn't enough time. It just doesn't typesend 1. So after the actionbar is set, it waits a bit, starts banking again and than the loops just starts without problem. It works but not good. That's annoying

    But g2g to work now, will try to solve this when I'm home again.

  9. #9
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    @The Mayor and @cosmasjdz it turned out to be a bug in RuneScape. When you set a herb in the actionbar you just won't be able to clean the herb with the actionbar number instantly. That's why it wasn't working. Very annoying! But thanks for your help anyway!

  10. #10
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by SlipperyPickle View Post
    @The Mayor and @cosmasjdz it turned out to be a bug in RuneScape. When you set a herb in the actionbar you just won't be able to clean the herb with the actionbar number instantly. That's why it wasn't working. Very annoying! But thanks for your help anyway!
    Is it a bug in RS or just SMART? Have u experienced the same problem using the official RS?
    This hotkey not working in SMART issue has bugged me for ages as well...

  11. #11
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Is it a bug in RS or just SMART? Have u experienced the same problem using the official RS?
    This hotkey not working in SMART issue has bugged me for ages as well...
    It's a bug in RS. Tried it in the official client with the same result,, really annoying :P

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
  •