Author Topic: First script and could use some help  (Read 5935 times)

0 Members and 1 Guest are viewing this topic.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
First script and could use some help
« on: May 07, 2012, 12:44:12 PM »
0
Ok I am using Kal In Ex's SOS Master to take me to SOS locations for SOS that I have on me. I can do quite a few quickly and was getting tired of double clicking the fishing pole so I decided to try and write a very basic script to fish there until it pulls up a treasure chest. I am getting stuck on the journal scan, the rest is working fine. It keeps fishing after the chest is pulled from the water.

Code: [Select]
finditem XHF_KDF C_ , #BACKPACKID ; this first part is borrowed from TM
  if #FINDKIND = -1                     
  {
    finditem XHF_KDF C_ , #CHARID
    if #FINDKIND = -1
    {
      display ok How can you fish without your fishing pole?
      halt
    }
  }
  set %fishingpole #FINDID

findItem XHF 1
set #LObjectID #FindID
set #LTargetKind 2
set #LTargetX 2 + #CharPosX
set #LTargetY #CharPosY
event macro 17 0
target
event macro 22 0
set %fishtimeout #SCNT + 9
target 12s
{
if You_pull_up_a_heavy_chest_from_the_depths_of_the_ocean in #journal
halt
}
return

Any help would be appreciated and I would love for someone to explain anything that I did wrong.

Thanks!

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: First script and could use some help
« Reply #1 on: May 07, 2012, 01:24:06 PM »
0
You might consider trying my journal handler subs.  They'll really help you de-mystify the whole journal thing.

http://www.scriptuo.com/index.php?topic=33.msg33#msg33
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: First script and could use some help
« Reply #2 on: May 07, 2012, 03:35:21 PM »
0
I am not sure if I am on the right track or not, guessing not because it is not stopping once the chest is pulled up. I may be using the wrong term to end the script, I am using halt.

Code: [Select]
gosub TM_AdvJournalSync FISHING
finditem XHF_KDF C_ , #BACKPACKID
  if #FINDKIND = -1
  {
    finditem XHF_KDF C_ , #CHARID
    if #FINDKIND = -1
    {
      display ok How can you fish without your fishing pole?
      halt
    }
  }
  set %fishingpole #FINDID
 
SOSFishLoop:
 findItem XHF 1
 set #LObjectID #FindID
 set #LTargetKind 2
 set #LTargetX 0 + #CharPosX
 set #LTargetY 4 + #CharPosY
 event macro 17 0
 target
 event macro 22 0
 set %fishtimeout #SCNT + 9
 target 12s

 gosub TM_AdvJournalScan FISHING VALID chest_from_the_depths_of_the_ocean
 if #RESULT = #TRUE
    {
    TM_AdvJournalSync Fishing
    goto endSOSFish
      }
 goto SOSFishLoop
 
EndSOSFishLoop:
 Halt

;=================================================================
;------------------------  Call interface  -----------------------
;=================================================================
set !TM_FunctionCalled #FALSE
if %0 = 1
  gosub %1
if %0 = 2
  gosub %1 %2
if %0 = 3
  gosub %1 %2 %3
if %0 = 4
  gosub %1 %2 %3 %4
if %0 = 5
  gosub %1 %2 %3 %4 %5
if %0 = 6
  gosub %1 %2 %3 %4 %5 %6
if %0 = 7
  gosub %1 %2 %3 %4 %5 %6 %7
if %0 = 8
  gosub %1 %2 %3 %4 %5 %6 %7 %8
if %0 = 9
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9
if %0 = 10
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10
if %0 = 11
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11
if %0 > 11
{
  display ok Too many arguments for "call", edit file.
  stop
}

if !TM_FunctionCalled = #TRUE
  exit
if %0 = N/A
  display ok You may not run this script directly.
else
  display ok Function " , %1 , " not found.
stop
;-------------------------------------------------------------------------------
sub TM_AdvJournalGetTrigger
  namespace push
  namespace local TM_AdvJS_ , %1
  set #RESULT !trigger
  namespace pop
  set !TM_FunctionCalled #TRUE
return #RESULT
;-------------------------------------------------------------------------------
; %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 !trigger !text
        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
  set TM_AdvJournalGetTrigger #FALSE
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------


Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: First script and could use some help
« Reply #3 on: May 07, 2012, 03:44:49 PM »
0
See if this slightly tweaked version works:

Code: [Select]
gosub TM_AdvJournalSync FISHING
finditem XHF_KDF C_ , #BACKPACKID
if #FINDKIND = -1
{
  finditem XHF_KDF C_ , #CHARID
  if #FINDKIND = -1
  {
    display ok How can you fish without your fishing pole?
    halt
  }
}
set %fishingpole #FINDID

SOSFishLoop:
  findItem XHF 1
  set #LObjectID #FindID
  set #LTargetKind 2
  set #LTargetX 0 + #CharPosX
  set #LTargetY 4 + #CharPosY
  event macro 17 0
  target
  event macro 22 0
  set %fishtimeout #SCNT + 9
  target 12s
 
  gosub TM_AdvJournalScan FISHING VALID_ADVANCE chest_from_the_depths_of_the_ocean
  if #RESULT = #TRUE
  {
    display ok Found one!
    goto EndSOSFishLoop
  }
  goto SOSFishLoop
 
  EndSOSFishLoop:
Halt


;-------------------------------------------------------------------------------
sub TM_AdvJournalGetTrigger
  namespace push
  namespace local TM_AdvJS_ , %1
  set #RESULT !trigger
  namespace pop
  set !TM_FunctionCalled #TRUE
return #RESULT
;-------------------------------------------------------------------------------
; %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 !trigger !text
        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
  set TM_AdvJournalGetTrigger #FALSE
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------


Please read the ScriptUO site RULES
Come play RIFT with me!

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: First script and could use some help
« Reply #4 on: May 07, 2012, 04:01:20 PM »
0
Intrigued. I whipped something purely pseudo up.

Code: [Select]
set %timeOut #scnt2
set %fishingPole XHF_KDF

Call TM_AdvJournalScan
Call TM_AdvJournalSync // Correct?

repeat:
if #charName = N/A
event macro 8 2
gosub check
if %timeOut < #scnt2
gosub fish
gosub journalScan
return

sub journalScan
Call TM_AdvJournalScan depths VALID_ADVANCE you_pull_up_a_heavy_chest_from_the_depths_of_the_ocean
{
Display Chest Fished!
halt
}
return

sub fish
finditem %fishingPole C_ , #charid
set #lobjectid #FINDID
set #ltargetkind 1 //you had this set to 2, which is Ground,Mountains,Caves. 1 is Object, I assume XHF_KDF are both Fishing Pole IDs
set #ltargetX 2 + #charPosX
set #ltagetY #charPosY
event macro 17 0
target
event macro 22 0
set %timeOut #scnt2 + 9
return

sub check
finditem %fishingPole C_ , #charid
if #FINDKIND = -1
  gosub equipPole
return

Sub equipPole
SET  #lobjecttype %fishingPole
finditem %fishingPole C_ , %backpackid
      if #FINDKIND = -1 
      { 
      display A pole to fish, one must have.
      halt 
      } 
   SET #RHANDID #findid
   wait 10
   event macro 24 2
   wait 10
return

NOTE: I do not have UO installed, I haven't played it in a while at all. I am almost 100% certain that this will not work right off the bat, as stated, it is purely pseudo. Plus I am pretty sure I did not implement TM's journal scan correctly. But it's just an idea :>

Basically it will ensure that your fishing pole is always in hand (if you haven't one at all, it presents a badboy), and it should do what you want it to do.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: First script and could use some help
« Reply #5 on: May 07, 2012, 04:52:23 PM »
0
Thanks TM!! The tweaks worked perfectly!! I added a header and included your Journal Handler in the credits in case anyone else ever uses it.

Code: [Select]
;===================================================================
; Script Name: Crisis SOS Chest Fisher

; Author: Crisis
; Version: 1.0c
; Shard OSI / FS: OSI
; Revision Date: 05/07/2012
; Purpose:
;     Completely automates the operation of fishing up treasure chests when you are in the correct area of your SOS.
;     Works great with Kal In Ex's SOS Master
;
; Features:
;     . Automatically fishes until you fish up a treasure chest.
;
; Requirements:
;     . You should be on a boat in the area of your SOS
;     . Must have the SOS in your backpack
;
; Special Thanks:
;     TrailMyx for helping me iron out the kinks and for TrailMyx's Advanced Journal Handler
;===================================================================

gosub TM_AdvJournalSync FISHING
finditem XHF_KDF C_ , #BACKPACKID
if #FINDKIND = -1
{
  finditem XHF_KDF C_ , #CHARID
  if #FINDKIND = -1
  {
    display ok How can you fish without your fishing pole?
    halt
  }
}
set %fishingpole #FINDID

SOSFishLoop:
  findItem XHF 1
  set #LObjectID #FindID
  set #LTargetKind 2
  set #LTargetX 0 + #CharPosX
  set #LTargetY 4 + #CharPosY
  event macro 17 0
  target
  event macro 22 0
  set %fishtimeout #SCNT + 9
  target 11s

  gosub TM_AdvJournalScan FISHING VALID_ADVANCE chest_from_the_depths_of_the_ocean
  if #RESULT = #TRUE
  {
    display ok Found one!
    goto EndSOSFishLoop
  }
  goto SOSFishLoop

  EndSOSFishLoop:
Halt


;-------------------------------------------------------------------------------
sub TM_AdvJournalGetTrigger
  namespace push
  namespace local TM_AdvJS_ , %1
  set #RESULT !trigger
  namespace pop
  set !TM_FunctionCalled #TRUE
return #RESULT
;-------------------------------------------------------------------------------
; %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 !trigger !text
        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
  set TM_AdvJournalGetTrigger #FALSE
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: First script and could use some help
« Reply #6 on: May 07, 2012, 05:30:17 PM »
0
Glad you got it to work.  You were really close.  Just a typo (needed a "gosub" statement) and I added the "ADVANCE" option to automatically advance the journal pointer when a valid entry is found.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline formerlyrara

  • Full Member
  • ***
  • Posts: 137
  • Activity:
    0%
  • Reputation Power: 2
  • formerlyrara has no influence.
  • Respect: +19
  • Referrals: 0
    • View Profile
Re: First script and could use some help
« Reply #7 on: May 07, 2012, 06:49:01 PM »
0
Great Script, saves wear and tear on finger clicks for sure :) Thanks Crisis

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: First script and could use some help
« Reply #8 on: May 08, 2012, 03:40:15 PM »
0
I am back for more help on this because I want to add more stuff to it and because it is helping me learn the scripts. I am trying to add in for the script to cut up the bones that get pulled up while trying to get the chest. What is happening is the script is looping again back to fishing after pulling the chest up instead of cutting the bones up. I am guessing that either I messed up inputting the cut_bones sub or I am messed up putting in the goto after the chest is pulled up.

Code: [Select]
;===================================================================
; Script Name: Crisis SOS Chest Fisher
;
; Author: Crisis
; Version: 1.0d
; Shard OSI / FS: OSI
; Revision Date: 05/07/2012
; Purpose:
;     Completely automates the operation of fishing up treasure chests when you are in the correct area of your SOS.
;     Works great with Kal In Ex's SOS Master
;
; Features:
;     . Automatically fishes until you fish up a treasure chest.
;
; Requirements:
;     . You should be on a boat in the area of your SOS
;     . Must have the SOS in your backpack
;
; Special Thanks:
;     TrailMyx for helping me iron out the kinks and for TrailMyx's Advanced Journal Handler
;===================================================================
set %cuttypes AJK_DJK_FJK_XIK_BJK_ZIK_SCK_YIK_RCK
set %scissortypes KAG_JAG
set %scissors N/A

gosub TM_AdvJournalSync FISHING
finditem XHF_KDF C_ , #BACKPACKID
if #FINDKIND = -1
{
  finditem XHF_KDF C_ , #CHARID
  if #FINDKIND = -1
  {
    display ok How can you fish without your fishing pole?
    halt
  }
}
set %fishingpole #FINDID

SOSFishLoop:
  findItem XHF 1
  set #LObjectID #FindID
  set #LTargetKind 2
  set #LTargetX 0 + #CharPosX
  set #LTargetY 4 + #CharPosY
  event macro 17 0
  target
  event macro 22 0
  set %fishtimeout #SCNT + 9
  target 11s

  gosub TM_AdvJournalScan FISHING VALID_ADVANCE chest_from_the_depths_of_the_ocean
  if #RESULT = #TRUE
  {
    display ARRR!! Thar be me sunken booty!!
    goto sub cut_bones
  }
  goto SOSFishLoop

  ;EndSOSFishLoop:
;Halt

;-------------------------------------------------------------------------------
Sub SetScissors
  set %scissors N/A
  Finditem %ScissorTypes C_ , #Backpackid
  IF #Findcnt >= 1
     set %Scissors #Findid
Return
;-------------------------------------------------------------------------------
sub cut_bones
  If %Scissors = N/A
     Gosub SetScissors
  If %Scissors = N/A
     Return
  finditem %cuttypes C_ , #backpackid
  if #findcnt >= 1
     {
     set #ltargetid #findid
     set #lTargetKind 1
     set #lobjectid %scissors
     wait 5
     event macro 17 0
     target 5s
     event macro 22 0
     wait 9
     }
return
;-------------------------------------------------------------------------------
sub TM_AdvJournalGetTrigger
  namespace push
  namespace local TM_AdvJS_ , %1
  set #RESULT !trigger
  namespace pop
  set !TM_FunctionCalled #TRUE
return #RESULT
;-------------------------------------------------------------------------------
; %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 !trigger !text
        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
  set TM_AdvJournalGetTrigger #FALSE
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------

I also edited out the EndSOSFishLoop so the script wouldn't stop after pulling up the chest, was I wrong to do that? I was going to figure out how to halt the script once I knew that it was cutting the bones up. Where did I go wrong?

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: First script and could use some help
« Reply #9 on: May 08, 2012, 04:35:02 PM »
0
Code: [Select]
set %scissors N/A



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: First script and could use some help
« Reply #10 on: May 08, 2012, 04:59:55 PM »
0
Code: [Select]
set %scissors N/A


Code: [Select]
set %scissortypes KAG_JAG
set %scissors N/A

Sub SetScissors
  set %scissors N/A
  Finditem %ScissorTypes C_ , #Backpackid
  IF #Findcnt >= 1
     set %Scissors #Findid
Return

It specifies in
Code: [Select]
set %scissortypes KAG_JAG what the type is and the next line sets it to N/A correct and then in the sub setscissors it tells you to look for N/A right or am I reading that completely wrong? It can be so confusing lol.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: First script and could use some help
« Reply #11 on: May 08, 2012, 06:55:50 PM »
0
Okay I finally was able to get it to start the cut_bones sub but the problem now is that it cuts the first bone pile and then it says "you must wait to perform another action" and then goes back to fishing. I am guessing that it is trying to cut the next bone pile too quick and because there is nothing to cut it reverts back to the original loop of fishing. I had adjust the wait already from 9 to 14 but maybe I am adjusting the wrong thing.

I adjusted this line in the sub cut_bone
Code: [Select]
wait 14
is that the wrong timer to adjust?

Here is my code in it's entirety:

Code: [Select]
;===================================================================
; Script Name: Crisis SOS Chest Fisher
;
; Author: Crisis
; Version: 1.0c
; Shard OSI / FS: OSI
; Revision Date: 05/07/2012
; Purpose:
;     Completely automates the operation of fishing up treasure chests when you are in the correct area of your SOS.
;     Works great with Kal In Ex's SOS Master
;
; Features:
;     . Automatically fishes until you fish up a treasure chest.
;
; Requirements:
;     . You should be on a boat in the area of your SOS
;     . Must have the SOS in your backpack
;
; Special Thanks:
;     TrailMyx for helping me iron out the kinks and for TrailMyx's Advanced Journal Handler
;===================================================================
gosub TM_AdvJournalSync FISHING
finditem XHF_KDF C_ , #BACKPACKID
if #FINDKIND = -1
{
  finditem XHF_KDF C_ , #CHARID
  if #FINDKIND = -1
  {
    display ok How can you fish without your fishing pole?
    halt
  }
}
set %fishingpole #FINDID
set %cuttypes AJK_DJK_FJK_XIK_BJK_ZIK_YIK
set %scissortypes KAG_JAG
set %scissors KAG

SOSFishLoop:
  findItem XHF 1
  set #LObjectID #FindID
  set #LTargetKind 2
  set #LTargetX 0 + #CharPosX
  set #LTargetY 4 + #CharPosY
  event macro 17 0
  target
  event macro 22 0
  set %fishtimeout #SCNT + 9
  target 11s

  gosub TM_AdvJournalScan FISHING VALID_ADVANCE chest_from_the_depths_of_the_ocean
  if #RESULT = #TRUE
  {
    display ARRR!! Thar be me sunken booty!!
    goto EndSOSFishLoop
  }
  goto SOSFishLoop

  EndSOSFishLoop:
gosub SetScissors
gosub cut_bones

;-------------------------------------------------------------------------------
Sub SetScissors
  set %scissors N/A
  Finditem %ScissorTypes C_ , #Backpackid
  IF #Findcnt >= 1
     set %Scissors #Findid
Return
;-------------------------------------------------------------------------------
Sub cut_bones
  If %Scissors = N/A
     Gosub SetScissors
     Return
  finditem %cuttypes C_ , #backpackid
  if #findcnt >= 1
     {
     set #ltargetid #findid
     set #lTargetKind 1
     set #lobjectid %scissors
     wait 5
     event macro 17 0
     target 5s
     event macro 22 0
     wait 14
     }
return
;-------------------------------------------------------------------------------
sub TM_AdvJournalGetTrigger
  namespace push
  namespace local TM_AdvJS_ , %1
  set #RESULT !trigger
  namespace pop
  set !TM_FunctionCalled #TRUE
return #RESULT
;-------------------------------------------------------------------------------
; %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 !trigger !text
        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
  set TM_AdvJournalGetTrigger #FALSE
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------

Once it is working properly and cutting all of the bone piles in my backpack, how can I make the script halt?
« Last Edit: May 08, 2012, 06:58:04 PM by Crisis »

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: First script and could use some help
« Reply #12 on: May 08, 2012, 07:06:12 PM »
0
Instead of having it jump straight to the sub to cut bones. have it scan the ground for them instead, and implement a loop. While %bones are on the ground, then cut. Then you can have it halt when there are none.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3015
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: First script and could use some help
« Reply #13 on: May 09, 2012, 05:11:29 AM »
0
Instead of having it jump straight to the sub to cut bones. have it scan the ground for them instead, and implement a loop. While %bones are on the ground, then cut. Then you can have it halt when there are none.

The bones are fished up out of the water when fishing for a SOS treasure chest. They end up in the backpack, I don't think I have ever had any end up on the ground before so not sure that will work. :(

Offline dxrom

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +100
  • Referrals: 1
    • View Profile
Re: First script and could use some help
« Reply #14 on: May 09, 2012, 11:34:35 AM »
0
Same logic applies then :>
Instead of scanning the ground, scan the backpack.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Tags: