thankyou Twinkle McNugget could someone help me learn how to use the brackets in this situation? I basically dont understand the proper way to use them and can't find a reference to go from that I can understand.
To help answer your question, lets take a look at your code.
SUB CHECKFORENEMIES
finditem abc g_10
if #findCnt > 0
{
set #lobjectid #findid
SET %q #findid
event macro 27
wait 5
REPEAT
finditem %q
event pathfind #findx #findY
event macro 27
WAIT 5
until #findCNT = 0
GOSUB FINDCORPSE
}
GOSUB PRIMARYLOCATION
RETURN
Now, in this code below, you are telling your script to find something and then saying
IF it finds abc to do EVERYTHING inside of the code tags that follow:
SUB CHECKFORENEMIES
finditem abc g_10
if #findCnt > 0
So, lets say the script finds abc on the ground within 10 tiles. The script then knows to execute the code within the code tags that follow:
{
set #lobjectid #findid
SET %q #findid
event macro 27
wait 5
REPEAT
finditem %q
event pathfind #findx #findY
event macro 27
WAIT 5
until #findCNT = 0
GOSUB FINDCORPSE
}
Once your script jumps into the code brackets you have it repeating the finditem %q (your monster) AND pathfinding to %q's coordinates until the findcnt = 0, at which point it jumps out of the repeat and goes to the sub Findcorpse. When your Sub Findcorpse completely executes, it should return you back to the line following your gosub findcorpse statement.... which just happens to be your } bracket. The script then sees that the code bracket has been closed and executes the next line of code.
Now, the difference is this... When the script does the Finditem abc g_10 and executes the IF #findcnt > 0 and it finds
NOTHING the script knows NOT to jump into the brackets and execute the code inside of them. Which means, it jumps straight past the brackets down to the GOSUB PRIMARYLOCATION line and executes it.
I hope this helps to answer your question.
JaF