ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: crameep on March 28, 2009, 02:08:35 PM

Title: Sub nested without return - need new eyes
Post by: crameep on March 28, 2009, 02:08:35 PM
Hey, cant seem to find it need new eyes. Thanks in advance.

Code: [Select]
  sub findcorpse
    finditem YFM G_15
    if #findkind = -1
    {
      move %startposx %startposy 0 5s
      goto mainloop
    }
    set %body #findid
    if #findx > %startposx + 15 || #findy > %startposy + 15
    {
      goto mainloop
    }
    set wait 10 + %lags Looting
    gosub updatestatus
    move #findX #findy 0 10s
    set #lobjectid %body
    nextCPos 10 10
    wait 10 + %lag
    event macro 17 0
    wait 1s
    set %nt2 #scnt2 + 10
    set %bod #contID
_OQ:
    finditem %loot C_ . #contID
    if #findkind = -1 && %nt2 < #scnt2
      goto _OQ
    wait 13
    set %bod #contid
_findloot:
    finditem %loot C_ . %bod
    if #findkind = -1 || #findbagid = #charid || #findbagid = #backpackid
    {
      event SysMessage finished Corpse.
      ignoreitem %body
      wait 15
      move %startposx %startposy 0 5s
      goto mainloop
    }
    if #weight > #maxweight - 100
    {
      set !amount ( #maxweight - #weight ) * 50
      if !amount > #findstack
        set !amount #findstack
    }
    else
      set !amount #findstack
    exevent drag #findid !amount
    exevent dropc #charid
    wait 1s
    gosub sendgold
    goto _findloot
  return
Title: Re: Sub nested without return - need new eyes
Post by: TrailMyx on March 28, 2009, 02:17:00 PM
Can't tell from this snippet, not enough code.  Looks fine from the syntax editor.  But do you notice that you are "goto"ing out of your subroutine?  That's bad medicine.
Title: Re: Sub nested without return - need new eyes
Post by: Khameleon on March 29, 2009, 10:37:42 AM
Ya, thats a big no, no.. I believe its sucks your resources also.
Title: Re: Sub nested without return - need new eyes
Post by: 12TimesOver on March 30, 2009, 05:04:25 AM
Better to handle the Goto's with Return's. I'm unclear as to what you are trying to accomplish here though with your point in the thread title, are trying to NOT use return for some reason?

XII
Title: Re: Sub nested without return - need new eyes
Post by: Petkiller on March 30, 2009, 06:09:31 AM
Just a quick question what is the max number of tiles you can scan?  I see the G_15 so I guess that means 15 tiles what is the practical limit 20 25? 
Title: Re: Sub nested without return - need new eyes
Post by: TrailMyx on March 30, 2009, 06:39:34 AM
In practice, the longest distance I've gotten to is 18.
Title: Re: Sub nested without return - need new eyes
Post by: Cerveza on March 30, 2009, 07:38:09 AM
I think I was 'cuttin bones' around 15 reliably. Maybe it was 12, don't remember.
Title: Re: Sub nested without return - need new eyes
Post by: Endless Night on March 30, 2009, 08:18:17 AM
Replace all
   goto mainloop
With
  RETURN


As far reliable tile scanning 18 is my vote.. but i belive the amount of tile radius loaded is a setting someplace in UO isnt it ?
Title: Re: Sub nested without return - need new eyes
Post by: crameep on March 30, 2009, 12:09:15 PM
Yeah, I guess I wasn't thinking about goto & returns. No particular reason for it just .. too much time in the code I guess. Woops.
Title: Re: Sub nested without return - need new eyes
Post by: 12TimesOver on March 30, 2009, 12:50:03 PM
(http://img29.exs.cx/img29/7232/stallowned5mg.jpg)
Title: Re: Sub nested without return - need new eyes
Post by: TrailMyx on March 30, 2009, 12:53:38 PM
Oh man, that's a hideous picture....
Title: Re: Sub nested without return - need new eyes
Post by: crameep on March 31, 2009, 01:09:01 PM
Yeah, i'll second that one, horrible picture.