ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: The Ghost on February 13, 2013, 11:08:48 AM

Title: Scan Journal and Sysmsg
Post by: The Ghost on February 13, 2013, 11:08:48 AM
Been trying all morning to have this to work .   can't seen my mistake, so I'm sure one of you will point it out :)   thx     Right I remove the Scan and add a wait 25s to have it to work.  :)
 
Code: [Select]
sub SecretJournal
again:
for %1 %journalindex #jindex
{
   scanjournal %i
       if *_The_sand_collapses,_revealing_a_dark_hole._* in #Journal
               {
        return
        }
        if *_You_must_wait_a_while_before_planting_another_thorn._* in #Journal
       {
        goto plant
        }
else
 {
 goto again
 }
}


here is the sub part that is part of
Code: [Select]
; ---------  set up target self
wait %wait
set %ClickX #clixres / 2
set %ClickY ( #cliyres / 2 ) + 50
event macro 23 0  ;  Target self
wait %wait
;
;plant:
finditem GSF C_ , #backpackid
wait 5
if #findcnt = 0
{
  gosub bank
}
set #lobjectid #findid
event macro 17
wait 5
click %ClickX %ClickY f d
gosub SecretJournal
wait 25s
; looking for hole
finditem %hole G_3
set #lobjectid #findid
event macro 17 0
wait 1s
Title: Re: Scan Journal and Sysmsg
Post by: ximan on February 13, 2013, 10:39:42 PM
rewrote a little bit, srry not able to test it.  placed your second segment of code into the subroutine plantsequence.  be sure to set %wait and %hole somewhere before calling plantsequence. e.g.

set %wait 1s
set %hole HOLE_TYPE
gosub plantsequence
stop


Code: [Select]
sub markjindex
  set %jindex #jindex + 1
return

sub waitforjindex
  set %_wfj 12 ; default wait of 3 seconds
  if %0 > 0
    set %_wfj %1 * 4
  while ( %jindex > #jindex ) && ( %_wfj > 0 )
  {
    ; wait up to %1 seconds for journal response
    set %_wfj %_wfj - 1
    wait 5
  }
  while %jindex <= #jindex
  {
    scanjournal %jindex
    set %jindex %jindex + 1
    if a_dark_hole in #Journal
    {
      return darkhole
    }
    if must_wait in #Journal
    {
      return plant
    }
  }
return nothing

sub markpos
  set %location #charposx , _ , #charposy , _ , #charposz , _ , #curskind
return

sub waitforpos
  set %_wfp 12 ; default wait of 3 seconds
  if %0 > 0
    set %_wfp %1 * 4
  repeat
    ; wait up to %1 seconds for change of position/facet
    wait 5
    set %testloc #charposx , _ , #charposy , _ , #charposz , _ , #curskind
    set %_wfp %_wfp - 1
    if %testloc notin %location
      return moved
  until %_wfp <= 0
return nochange

sub plantsequence
psbegin:
  wait %wait
  set %ClickX #clixres / 2
  set %ClickY ( #cliyres / 2 ) + 50
  event macro 23 0  ;  Target self
  wait %wait
  ;
plant:
  finditem GSF C_ , #backpackid
  wait 5
  if #findcnt = 0
  {
    gosub bank
  }
  set #lobjectid #findid
  gosub markjindex           ; mark current point in journal
  event macro 17             ; use object
  target 3s                  ; wait up to 3 seconds for target cursor
  click %ClickX %ClickY f d  ; click ground
  gosub waitforjindex        ; wait up to 3 seconds for response in journal
  if plant in #result
    goto plant
  if darkhole in #result
    goto darkhole
  if nothing in #result
  {
    ; no response was found in the journal
    pause
    goto psbegin
  }

  ; looking for hole
darkhole:
  finditem %hole G_3
  if #findcnt = 0
  {
    ; no %hole found within 3 tiles
    pause
    gosub psbegin
  }
  set #lobjectid #findid     ; set last object
  gosub markpos              ; mark current character position/facet
  event macro 17 0           ; use object
  gosub waitforpos           ; wait up to 3 seconds for position/facet to change
  if nochange in #result
  {
    ; character in same spot/facet
    pause
    goto psbegin
  }
return