ScriptUO

Official ScriptUO EasyUO Scripts => Script Snippets => Topic started by: TrailMyx on July 16, 2009, 08:47:31 PM

Title: TrailMyx's Item Move helper
Post by: TrailMyx on July 16, 2009, 08:47:31 PM
Ok, I just whipped this up because I'm tired of moving items from one container to another.  I have scripts to do this, but I'm tired of setting them up with an item type, source and destination.  So this little snippet will try and understand what the source, item and destination are.  Once it understands what you are trying to do, it'll ask you if it can move the rest for you.  You can even move back to the source container!  Great for moving MIBs around, or other items that enumerate your backpack.

Yet another little snippet that was born from the frustration of playing UO.

Code: easyuo
  1. set #LPC 300
  2. set %type N/A
  3. set %ignore_list
  4. set %sample_contid N/A
  5. set %first_moved
  6. gosub TM_AdvJournalSync drag
  7. repeat
  8.   if #CONTNAME = drag_gump && %sample_contid <> N/A
  9.   {
  10.     set %type #LLIFTEDTYPE
  11.     if %type notin %ignore_list
  12.     {
  13.       repeat
  14.       until #CONTNAME <> drag_gump
  15.       set %dest_cont #CONTID
  16.       if %dest_cont = N/A || %last_cont = N/A
  17.         continue
  18.       if %type notin %first_moved
  19.       {
  20.         display yesno Do you want me to move the rest of these?
  21.         if #DISPRES = no
  22.         {
  23.           set %ignore_list %ignore_list , _ , %type
  24.           continue
  25.         }
  26.       }
  27.       wait 10
  28.       set %first_moved %first_moved , _ , %type
  29.       gosub DragAll %type %last_cont %dest_cont
  30.     }
  31.   }
  32.   set %temp_contid #CONTID
  33.   if %temp_contid <> N/A
  34.   {
  35.     set %last_cont %sample_contid
  36.     set %sample_contid %temp_contid
  37.   }
  38. until #FALSE
  39. ;-------------------------------------------------------------------------------
  40.  
  41. sub DragAll
  42.   namespace push
  43.   namespace local DA
  44.   set !item %1
  45.   set !source %2
  46.   set !dest %3
  47.   repeat
  48.     finditem !item C_ , !source
  49.     if #FINDCNT > 0
  50.     {
  51.       exevent drag #FINDID #FINDSTACK
  52.       wait 10
  53.       exevent dropc !dest
  54.       wait 10
  55.       gosub TM_AdvJournalScan drag ADVANCE cannot
  56.       if #RESULT = #TRUE
  57.         break
  58.     }
  59.   until #FINDCNT = 0
  60.   namespace pop
  61. return
  62.  
  63. ;-------------------------------------------------------------------------------
  64. ; %1 - Journal Name
  65. ; %2 - #LPC setting (optional)
  66. ; Brings !_jindex up to the most recent #journal entry
  67. sub TM_AdvJournalSync
  68.   namespace push
  69.   namespace local TM_AdvJS_ , %1
  70.   set !_jindex #jindex + 1
  71.   if %0 > 1
  72.     set !lpc_set %2
  73.   namespace pop
  74.   set !TM_FunctionCalled #TRUE
  75. return
  76. ;-------------------------------------------------------------------------------
  77. ; %1 - Journal Name
  78. ; %2 - NONE, ADVANCE , ( _VALID ) - advances jindex pointer, anything else
  79. ; %3, %4, %5, etc strings to match
  80. ; returns #TRUE for match, #FALSE for no match
  81. ;  Will not advance !_jindex pointer to allow for scanning journal history for more than one search.
  82. ;  Also searches for : , #SPC in journal entry to be sure someone isn't spamming the text
  83. ;  About %2 arguments:
  84. ;    NONE: defaults to basic journal scan (no SPAM checking, no #jindex pointer copy advancing)
  85. ;    ADVANCE: no spam checking, advances #jindex copy
  86. ;    VALID: invokes SPAM filtering, no advance of #jindex copy
  87. ;    VALID_ADVANCE, VALIDADVANCE, ADVANCE_VALID, etc.: invokes SPAM filtering, advances of #jindex copy
  88. sub TM_AdvJournalScan
  89.   namespace push
  90.   namespace local TM_AdvJS_ , %1
  91.   set !args %2
  92.   set !temp_lpc #LPC
  93.   if !lpc_set = N/A
  94.     set #LPC 1000
  95.   else
  96.     set #LPC !lpc_set
  97.   set !num_args %0
  98.   set !first_arg 3
  99.   set !sampled_jindex #JINDEX
  100.   if !_jindex = N/A
  101.     set !_jindex !sampled_jindex
  102.   if !charname = N/A
  103.   {
  104.     set !charname #CHARNAME
  105.     AdvJournalScan_loop1:
  106.       str pos !charname #SPC
  107.       if #STRRES <> 0
  108.       {
  109.         set !val #STRRES - 1
  110.         str left !charname !val
  111.         set !left #STRRES
  112.         set !val !val + 1
  113.         str del !charname 1 !val
  114.         set !charname !left , _ , #STRRES
  115.         goto AdvJournalScan_loop1
  116.       }
  117.   }
  118.   set !index !first_arg
  119.   repeat
  120.     set !temp_jindex !_jindex
  121.     set !text % . !index
  122.     while !temp_jindex <= !sampled_jindex
  123.     {
  124.       scanjournal !temp_jindex
  125.       str pos #JOURNAL !charname 1
  126.       set !namepos #STRRES
  127.       str count #JOURNAL !charname
  128.       set !namecnt #STRRES
  129.       str pos #JOURNAL :_ 1
  130.       set !smcpos #STRRES
  131.       str pos #JOURNAL !text 1
  132.       set !textpos #STRRES
  133.       if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL || VALID notin !args
  134.         set !pass #TRUE
  135.       else
  136.         set !pass #FALSE
  137.       if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
  138.       {
  139.         set !temp_jindex !temp_jindex + 1
  140.         if ADVANCE in !args
  141.           set !_jindex !temp_jindex
  142.         set #LPC !temp_lpc
  143.         namespace pop
  144.         set !TM_FunctionCalled #TRUE
  145.         return #TRUE
  146.       }
  147.       set !temp_jindex !temp_jindex + 1
  148.     }
  149.     set !index !index + 1
  150.   until !index - !first_arg > !num_args - !first_arg
  151.   set %10 !sampled_jindex - !_jindex
  152.   set %10 %1 , _ , %10 ; for debugging purposes
  153.   set #LPC !temp_lpc
  154.   namespace pop
  155.   set !TM_FunctionCalled #TRUE
  156. return #FALSE
  157.  
  158.  

You can help the script a little bit by quickly clicking on the source container before you drag the first item.  Most of the time it'll still sense what you are trying to do, but this will guarantee it to move the rest of the items for you.
Title: Re: TrailMyx's Item Move helper
Post by: aibandit on May 08, 2010, 01:40:11 PM
Thank you so much for this!
Title: Re: TrailMyx's Item Move helper
Post by: TrailMyx on January 11, 2012, 06:21:05 PM
I still use this little snippet a whole bunch..  i.e. moving MIBs, like items, etc.  I modified it to work a little better. 
Title: Re: TrailMyx's Item Move helper
Post by: seeriusly on January 15, 2012, 09:58:40 AM
I use this a bunch!  Thanks TM...  Saves a whole hell of a lot of clicks!
Title: Re: TrailMyx's Item Move helper
Post by: TrailMyx on January 15, 2012, 10:02:05 AM
I use this a bunch!  Thanks TM...  Saves a whole hell of a lot of clicks!

Yah, it's one of those silly little scripts that can save so much time.  I use it alot when I'm moving my MIBs/SOSes from container to container.  I wanted something that would just "automatically" determine what you are trying to do.
Title: Re: TrailMyx's Item Move helper
Post by: NObama on January 16, 2012, 11:36:37 AM
Ha!  How many times are you going to write the same script?  Once again, Miffy's Item Finder does everything you ever needed in UO!  Hell, I PvP with it.

 ;)
Title: Re: TrailMyx's Item Move helper
Post by: TrailMyx on January 16, 2012, 12:06:54 PM
Well this one actually is different in the sense that it reacts to what you are moving around.  When it senses you are moving something, it will intervene and ask if you'd like the script to move the rest for you.  So no setup, no typing, just a bit of AI applied to your day.

My next little project is going to be fusing the CLAw to Miffy's Item finder.  That outta be cool.
Title: Re: TrailMyx's Item Move helper
Post by: NObama on January 16, 2012, 02:53:09 PM
I take it back - that *IS* cool.  It's what the UO Personal Attendant token should have been!