SRL Archive - RS3 Help

Using break;


SlipperyPickle

2015-02-13 05:00:54

Hi,

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

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.

if not (isQuickKeySet) then
break;

My full code is:

  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!

The Mayor

2015-02-13 05:22:17

From: SlipperyPickle


I want it to break out of the loop.



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



What loop?

SlipperyPickle

2015-02-13 05:26:52

From: The Mayor
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.

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

typeSend('1', false);

The Mayor

2015-02-13 05:29:57

From: SlipperyPickle
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.

  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:


for 1 to 10 do
begin
break;
end;

repeat
break;
until false;

while true do
begin
break;
end;

cosmasjdz

2015-02-13 05:30:16

I think there is your problem.

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.

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;

SlipperyPickle

2015-02-13 05:33:32

From: The Mayor
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:


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.

The Mayor

2015-02-13 05:35:27

From: cosmasjdz
I think there is your problem.

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.


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 :p

SlipperyPickle

2015-02-13 05:41:25

From: The Mayor
That is legit code, although the bs.isOpen() isn't needed as bs.open() returns true if it is open.


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 :p


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 :p

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

SlipperyPickle

2015-02-13 11:51:37

@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! :)

riwu

2015-02-13 17:58:54

From: SlipperyPickle
@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…

SlipperyPickle

2015-02-13 18:03:06

From: riwu
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