Hi, is there a line of code that'll just restart the script from the beginning? Not a repeat until false command. But a line that'll interrupt any procedure and reset the whole script.
Thanks.
Hi, is there a line of code that'll just restart the script from the beginning? Not a repeat until false command. But a line that'll interrupt any procedure and reset the whole script.
Thanks.
The "break" command can break out of any loop as far as I'm aware.
You can also call a function/procedure that is placed above the current one you are in.
What you are referring to is a goto, or jump, which I'm not sure Lape supports.
But I'm sure there would be a way to avoid it, as most cases, i'ts bad programming practice anyways.
Can I see a snippet of your script?
-Aspect Abyss-https://villavu.com/forum/showthread.php?t=117559
-WaterfallQuest Runner- https://villavu.com/forum/showthread.php?t=116562-GiantRat Slayer- https://villavu.com/forum/showthread.php?t=116523
They exist: http://wiki.freepascal.org/Goto and http://wiki.freepascal.org/Label (same in Lape IME)
But As you said, they're generally considered bad practice. I agree that @OP can, and should, accomplish what he wants with standard loops.
I've tried this. Here's examples;
This here is part of my main procedure I'm running.
As you can see, I've got a loot Procedure. This is part of my loot Procedure(so far)Code:if FindColorTolerance (X, Y, 1282019, 103, 49, 438, 235, 5) then movemouse(608, 365); wait(200); clickmouse(608, 365,1); wait(200); Loot(); wait(1800);
What I'm currently doing is inserting Loot(); throughout my main procedure; for when the chosen colour I want appears on screen.Code:Procedure Loot var x,y:Integer; begin if FindColorTolerance(x, y, 6133430, 16, 10, 508, 360, 5) then begin wait(500); KeyDown(38); wait(1000); KeyUp(38); movemouse(266,202); wait(200); clickmouse(266,202,1);
I would like it so that once it's checked loot and loot is TRUE(colour found) , The script restarts Mainloop(or just my end part), rather than continue on the main procedure as it's doing now. This is the end of my script;
I cant put MainLoop in Loot unless I put it above it. But if I do that, Zulrah will be below MainLoop, and It won't run either wayCode:Procedure MainLoop; begin SettingUp; GettingToBoat; Zulrah; end; begin MainLoop end;
Thanks for the reply too.
I'd strongly recommend you read and understand this tutorial before continuing: https://villavu.com/forum/showthread.php?t=58935
Anyway, here's a rough skeleton script that might help you understand how you can accomplish what you're describing:
Simba Code:program ZulrahKiller;
procedure KillZulrah();
begin
//kill snek
end;
function Loot(): Boolean;
begin
//get loot
end;
procedure Mainloop();
begin
//other stuff
KillZulrah();
if Loot() then Exit;
//other stuff
end;
begin
while True do Mainloop();
end.
Thanks for the example. I'll give that post a read over.
Sorry to come back to this. Just having some problems still. I've tried the skeleton you've given, @Citrus. I've got different issues now. Let me give you as much info on my script as possible.
- It's a zulrah killing script for a private server. I've coded it nearly perfectly up until the looting part. Because Its an RSPS and aerolib isn't 100% on rsps's i'm trying to figure out different ways to solve stuff. On this rsps, a zulrah teleport spawns on the floor next to my character when zulrah dies, and the loot then appears where my character is standing. What I've coded is I'm constantly checking my loot function to see if the colours on the teleport are on the screen.
Here's an example from my main procedure
As you can see I'm constantly calling upon loot which is;Code:Loot(); wait(50); clickmouse(X,Y,1); ....... wait(50); movemouse(621,288); wait(50); Loot();
And i've used your skeleton at the end of the script;Code:function Loot(): Boolean; var x,y:Integer; begin if FindColorTolerance(x, y, 6133430, 16, 10, 508, 360, 5) then begin wait(500); KeyDown(38); wait(1000); KeyUp(38); movemouse(266,202); wait(200); clickmouse(266,202,1); wait(1000); clickmouse(266,202,1); end; end;
I've read the thread you linked a few times over. I'm still struggling.Code:Procedure MainLoop(); begin SettingUp(); GettingToBoat(); Zulrah(); if Loot() then Exit; end; begin while True do MainLoop(); end;
With the CURRENT script i've shown, it DOES loot but as you can see i'm constantly checking loot because it kills zulrah at so many different points in the script so it loops for as many loot calls I write. Could you help me find a much easier way of doing this? The zulrah teleport is always on the floor till i leave, so it keeps on activating the loot function. I COULD put teleport out code in the loot function, but the script would still run as if i was still killing zulrah because It thinks looting is done. This is why I wanted the script to literally restart from the beginning once loot is done. And the if loot then Exit just continues from the main procedure, which is not what I want.
Thankyou very much.
Some suggestions to get better help:
1: Clean up your code with proper indentation and capitalization. As is, it's barely readable. Also, use [SIMBA]//code[/SIMBA] tags instead of CODE tags.
2: Post the whole script. These bits and pieces you're posting don't make sense.
3: Explain what you want the script to do in clear, plain language. A 5-year-old with no knowledge of RuneScape should be able to understand it.
4: For (maybe) quicker responses, ask on Discord: https://discord.gg/RSXyB8E
Last edited by Citrus; 05-01-2018 at 02:18 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)