ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: The Ghost on January 09, 2015, 09:59:36 PM

Title: Exiting a button within a loop
Post by: The Ghost on January 09, 2015, 09:59:36 PM
Been hunting some little monster and I'm tired to hitting play/stop from window every time.  So I decide to make a menu,  I find out that I can perform one action at the time. Heal my self, recall, invis.   Now I'm trying to attack a monster with spell  and keep casting until dead.

I try this but it doesn't exit after the monster is dead.  What do I'm missing
Code: [Select]
gosub menu1

set #menuButton N/A
set %EndScript #false
Repeat
  If #MenuButton <> N/A
     {
     gosub #menuButton
     set #menuButton N/A
     }
until #menubutton = closed

Sub button1 ;  kill monster
 repeat
finditem xxx G_10
if #findcnt > 0
{
  set #ltargetkind 1
  set #ltargetid #findid
  event macro 15 17   
  target 3s
  event macro 22
  wait 2s
}
set #RESULT #FALSE
until #FALSE
event macro 3 0  Return_out
return #RESULT

Title: Re: Exiting a button within a loop
Post by: The Ghost on January 10, 2015, 05:21:50 PM
After doing a bit of testing, I was able to get it to work this way.  Not sure if this is the best way but it seen to work.

Code: [Select]
Sub button1
 repeat
finditem XXX G_10
if #findkind = -1
   return
if #findcnt > 0
{
  set #ltargetkind 1
  set #ltargetid #findid
  event macro 15 17
  target 3s
  event macro 22
  wait 2s
}
; until #CLICNT = 0
until #false