ScriptUO

Official ScriptUO EasyUO Scripts => Script Snippets => Topic started by: Neo on September 19, 2011, 07:34:13 AM

Title: fast & safe drag and drop sub
Post by: Neo on September 19, 2011, 07:34:13 AM
Lagging out while drag and dropping was always a big crash cause for me...

So I wrote this sub, which I'm now using in my private miner and my lumber 1.0, to move stuff...

Code: [Select]
;Usage: gosub neo_dragdrop %itemtomove %bagtomoveto %amount (ex: gosub neo_dragdrop #findid #backpackid #findstack -> will move the whole stack of #findid to your backpack)

;======= drag and drop sub =======
sub neo_dragdrop
  namespace push
  namespace local neodragdrop
  set !item %1
  set !bag %2
  set !amount %3
  set !timeout1 #scnt2 + 10
  set !timeout2 #scnt + 6
  repeat
    event property !bag
  until Stones in #property
  set !initcnt #property
  exevent drag !item !amount
  exevent dropc !bag
  repeat
    repeat
      event property !bag
    until Stones in #property
    set !newcnt #property
  until !initcnt <> !newcnt || #scnt >= !timeout2
  if !initcnt = !newcnt
  {
    event macro 9 7
    wait 1
    nextCPos 776 577 ; change this to where you want the backpack to open
    event macro 8 7
    gosub gumpwait container_gump N/A #backpackid ; -> change this to your gumpwait sub
    wait 15
  }
  repeat
  until #scnt2 >= !timeout1
  namespace pop
return
;======= end sub =======

The idea here is using event property on the destination container, so that you can actually check for when the item is in fact moved to that container. If this happens before 1 second, it will wait until that second is up before moving on... If it takes more than 1 second, it will wait until the property changes on the destination container to move on... If this takes more than 6 seconds, it's probably some ghosting/lag issue, and it will reopen your backpack before moving on... This can also be changed to reopen some other container you're getting stuff from, if that's the case for you...

I found this pretty useful to avoid crashes while moving stuff due to lag issues...

Hope people can find this useful too...

cheers

neo
Title: Re: fast & safe drag and drop sub
Post by: Endless Night on September 19, 2011, 08:33:42 AM
Excellent... mind if i snag this into my libraries (I'll add a credit comment of course).

This is only for moving a container .. so i would also rename it  :)  Excellent.
Title: Re: fast & safe drag and drop sub
Post by: Neo on September 19, 2011, 08:38:03 AM
Excellent... mind if i snag this into my libraries (I'll add a credit comment of course).

This is only for moving a container .. so i would also rename it  :)  Excellent.

Yeah, this only for moving items from anywhere into containers, if that's what you meant... It's called "sub dragdrop" in my lumber, or something like that... Guess I should rename it here as well... Thanks for the tip...

And I wouldn't mind, you're free to use it as you want! :)

cheers

neo

EDIT: I forgot to mention... I found that the container you're moving stuff into must be visible on your screen, for the property to be properly set... For instance, if you're moving it to a container inside your home, that gets "invisible" to you after you recall somewhere and recall back home, then the property for that container won't be properly set, causing issues...
Title: Re: fast & safe drag and drop sub
Post by: manwinc on September 19, 2011, 05:57:00 PM
Be sure to idiot proof it and have a check to make sure the destination container exists......
Title: Re: fast & safe drag and drop sub
Post by: Cerveza on September 22, 2011, 04:37:28 AM
I'm wondering if opening your paperdoll will initialize your backpack to get an accurate count of items?
Title: Re: fast & safe drag and drop sub
Post by: Neo on September 22, 2011, 06:57:39 AM
I'm wondering if opening your paperdoll will initialize your backpack to get an accurate count of items?
I'm not sure I know what you mean...

To use finditem * C_ , #backpackid ?
Title: Re: fast & safe drag and drop sub
Post by: Cerveza on September 22, 2011, 07:11:32 AM
I was referring to the event macro 9 7 to open the backpack and then contpos it where you want it. What is the purpose of doing that? I assumed it was to refresh the count in the backpack??

That's why I was thinking that opening the backpack paperdoll would accomplish the same thing.
Title: Re: fast & safe drag and drop sub
Post by: Neo on September 22, 2011, 08:13:53 AM
I was referring to the event macro 9 7 to open the backpack and then contpos it where you want it. What is the purpose of doing that? I assumed it was to refresh the count in the backpack??

That's why I was thinking that opening the backpack paperdoll would accomplish the same thing.
Oh... I don't know if opening the paperdoll refreshes your backpack...

Usually if you can't move an item after a few seconds, it's because of ghosting of that item inside your backpack, and the only way I know to get rid of that is by reopening the backpack...

The only thing I know about opening the paperdoll it that thing where the monsters will all target you when you open it...
Title: Re: fast & safe drag and drop sub
Post by: Cerveza on September 22, 2011, 08:42:31 AM
Item ghosting is a pain...

exevent dropc #backpackID usually drops it into the pack. I was thinking you were opening the backpack to get the item refresh on what's inside, if it's a ghosting issue then the paperdoll may not work.

I don't think toggling paperdoll attracts monsters any longer.
Title: Re: fast & safe drag and drop sub
Post by: MeWonUo on September 22, 2011, 01:14:45 PM
Item ghosting is a pain...

exevent dropc #backpackID usually drops it into the pack. I was thinking you were opening the backpack to get the item refresh on what's inside, if it's a ghosting issue then the paperdoll may not work.

I don't think toggling paperdoll attracts monsters any longer.

Paperdoll popping is still live and kicking.  Fantastic tool for champ spawns.
Title: Re: fast & safe drag and drop sub
Post by: rana70 on October 09, 2011, 04:29:38 AM
Hi,

I am not the expert here, but I guess this part of your SUB
without any extra wait command will cause a lot trouble
to higher ping (>70) users  ;)
Code: [Select]
...
  set !initcnt #property
  exevent drag !item !amount
  exevent dropc !bag
...

cu
Title: Re: fast & safe drag and drop sub
Post by: Neo on October 09, 2011, 05:02:35 AM
Actually, as long as the total wait time is 1 second, you don't need a pause between exevent drag and exevent dropc...

The lowest ping I get is 180 @ Atlantic, and this is the best way I found so far to avoid crashes! :)

If you get a chance, give this a go on shards where you have higher ping...

cheers!