set #LPC 300
set %type N/A
set %ignore_list
set %sample_contid N/A
set %first_moved
gosub TM_AdvJournalSync drag
repeat
if #CONTNAME = drag_gump && %sample_contid <> N/A
{
set %type #LLIFTEDTYPE
if %type notin %ignore_list
{
repeat
until #CONTNAME <> drag_gump
set %dest_cont #CONTID
if %dest_cont = N/A || %last_cont = N/A
continue
if %type notin %first_moved
{
display yesno Do you want me to move the rest of these?
if #DISPRES = no
{
set %ignore_list %ignore_list , _ , %type
continue
}
}
wait 10
set %first_moved %first_moved , _ , %type
gosub DragAll %type %last_cont %dest_cont
}
}
set %temp_contid #CONTID
if %temp_contid <> N/A
{
set %last_cont %sample_contid
set %sample_contid %temp_contid
}
until #FALSE
;-------------------------------------------------------------------------------
sub DragAll
namespace push
namespace local DA
set !item %1
set !source %2
set !dest %3
repeat
finditem !item C_ , !source
if #FINDCNT > 0
{
exevent drag #FINDID #FINDSTACK
wait 10
exevent dropc !dest
wait 10
gosub TM_AdvJournalScan drag ADVANCE cannot
if #RESULT = #TRUE
break
}
until #FINDCNT = 0
namespace pop
return
;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - #LPC setting (optional)
; Brings !_jindex up to the most recent #journal entry
sub TM_AdvJournalSync
namespace push
namespace local TM_AdvJS_ , %1
set !_jindex #jindex + 1
if %0 > 1
set !lpc_set %2
namespace pop
set !TM_FunctionCalled #TRUE
return
;-------------------------------------------------------------------------------
; %1 - Journal Name
; %2 - NONE, ADVANCE , ( _VALID ) - advances jindex pointer, anything else
; %3, %4, %5, etc strings to match
; returns #TRUE for match, #FALSE for no match
; Will not advance !_jindex pointer to allow for scanning journal history for more than one search.
; Also searches for : , #SPC in journal entry to be sure someone isn't spamming the text
; About %2 arguments:
; NONE: defaults to basic journal scan (no SPAM checking, no #jindex pointer copy advancing)
; ADVANCE: no spam checking, advances #jindex copy
; VALID: invokes SPAM filtering, no advance of #jindex copy
; VALID_ADVANCE, VALIDADVANCE, ADVANCE_VALID, etc.: invokes SPAM filtering, advances of #jindex copy
sub TM_AdvJournalScan
namespace push
namespace local TM_AdvJS_ , %1
set !args %2
set !temp_lpc #LPC
if !lpc_set = N/A
set #LPC 1000
else
set #LPC !lpc_set
set !num_args %0
set !first_arg 3
set !sampled_jindex #JINDEX
if !_jindex = N/A
set !_jindex !sampled_jindex
if !charname = N/A
{
set !charname #CHARNAME
AdvJournalScan_loop1:
str pos !charname #SPC
if #STRRES <> 0
{
set !val #STRRES - 1
str left !charname !val
set !left #STRRES
set !val !val + 1
str del !charname 1 !val
set !charname !left , _ , #STRRES
goto AdvJournalScan_loop1
}
}
set !index !first_arg
repeat
set !temp_jindex !_jindex
set !text % . !index
while !temp_jindex <= !sampled_jindex
{
scanjournal !temp_jindex
str pos #JOURNAL !charname 1
set !namepos #STRRES
str count #JOURNAL !charname
set !namecnt #STRRES
str pos #JOURNAL :_ 1
set !smcpos #STRRES
str pos #JOURNAL !text 1
set !textpos #STRRES
if !textpos < !smcpos && !smcpos <> 0 || !smcpos = 1 || :_ notin #JOURNAL || VALID notin !args
set !pass #TRUE
else
set !pass #FALSE
if ( !text in #journal && ( ( !namepos = 1 && !namecnt <= 1 ) || !pass ) )
{
set !temp_jindex !temp_jindex + 1
if ADVANCE in !args
set !_jindex !temp_jindex
set #LPC !temp_lpc
namespace pop
set !TM_FunctionCalled #TRUE
return #TRUE
}
set !temp_jindex !temp_jindex + 1
}
set !index !index + 1
until !index - !first_arg > !num_args - !first_arg
set %10 !sampled_jindex - !_jindex
set %10 %1 , _ , %10 ; for debugging purposes
set #LPC !temp_lpc
namespace pop
set !TM_FunctionCalled #TRUE
return #FALSE