repeat
{
set #targcurs 1
}
until #targcurs = 0
This Bit Above Won't give you very consistent Results. What you are literally doing is forcing a target cursor 10x a second. So if you click something and it isn't right at the "Until #Targcurs = 0" Then it will just spit out another Cursor.
set #targcurs 1
While #targcurs = 1
wait 1
or
set #targcurs 1
Repeat
wait 1
Until #Targcurs = 1
That will help you with the container portion.
Brackets are also redundant inside of Repeat Untils, but they don't hurt anything for them to be there.
I also don't see you setting %Container in the sub itself.
repeat
{
set #targcurs 1
}
until #targcurs = 0
set #ltargetid %container
set #ltargetkind 1
event macro 22 0
After you get the #Targcurs = 0, you are probably wanting to set the %Container to the #ltargetid
set #targcurs 1
Repeat
wait 1
Until #Targcurs = 1
set %Container #ltargetid
set #ltargetid %container
set #ltargetkind 1
event macro 22 0
wait 20 ;<- A delay so the container can actually open before you check for bandages.
; Plenty of Coders have Subs for waiting for Things to happen like containers opening you can steal that are more reliable
; Than random Delays.