ScriptUO

Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: SunTigress on July 29, 2009, 07:56:04 PM

Title: the beginnings
Post by: SunTigress on July 29, 2009, 07:56:04 PM
ok, i basically took the advise of my elders (hehe) and started from the beginning, testing each piece as I go. So far, I can check to make sure my dagger is in my pack, and I can set my variables. I can now SJ into Covetous and am working on writing in my rail.

Step 1 - Dagger check -> done
Step 2 - Set variables -> done
Step 3 - Recall to harpies -> done
Step 4 - Get on rail and find harpies -> in progress
Step 5 - Kill harpies
Step 6 - Use Claw to loot feathers
Step 7 - Continue on rail killing harpies and looting
Step 8 - When overweight, recall home
Step 9 - Dump loot
Step 10 - Repeat

Version 1.2

Code: [Select]
;Setup
;~~~~~~~~~~~~~~~~~~~~~~~~Daggers~~~~~~~~~~~~~~~~~~~~~~~~
finditem TSF_WSF_ c
if #findkind = -1
{
   display Ok, You do not have a dagger in your backpack.
   halt
}
set %daggerID #findid

;~~~~~~~~~~~~~~~~~~~~~~~~Runebooks~~~~~~~~~~~~~~~~~~~~~~
gosub TM_AddUnderscore #CHARNAME
set %charname #RESULT
set %rune1 1
set %rune2 2
GoSub setup_runebook
GoSub setup_travel
GoSub setup_secure

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Main loop
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
repeat
GoSub Harpies
until #false




;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;subs
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


sub harpies
    set %runebook %runebookid
     GoSub TM_TravelFromRunebook %travel_method %rune2 %rune2 %runebook
return


sub setup_runebook
display Target your Rune Book.
   wait 1
   set #targcurs 1
   while #targcurs = 1
     wait 0
set %runebookid #ltargetid
return


sub setup_travel
   set %travel_method SJ
   display YESNO Travel by Sacred Journey?
   if #dispres = NO
   {
   set %travel_method RE
   }
return

sub setup_secure
   display  Target your secure container.
   wait 5
   set #targcurs 1
   target
   while #targcurs = 1
     wait 0
   set %secure #ltargetid #findx #findy #findz
return



;=================================================================
; Script Name: TrailMyx's Runebook/Spellcast Subs
; Author: TrailMyx
; Version: 2.5
; Shard OSI / FS: OSI / FS
; Revision Date: 09/27/2007
; Purpose:
;   Runebook subs to manage your runebook travel needs.  You need either to know
;   the runebook ID or runebook name.
;
; Subroutines:
;     TM_NewCastSpell - casts spells with appropriate waits, delays, retrys.
;     TM_TravelFromRunebook - Uses specified runbook #FINDID to travel from .  If a location is blocked
;                             the next location will be tried until success.
;     TM_TravelFromNamedRunebook - Same as TM_TravelFromRunebook, but allows you to specify a runebook name
;
;  Examples:
;     gosub TM_NewCastSpell 31 !rbook 10 20 20 ; recall
;     gosub TM_TravelFromRunebook RE 1 3 %runebookid ; travel (recall) to location from #FINDID runebook using slots 1-3
;     gosub TM_TravelFromNamedRunebook GA 1 2 LUMBERJACKING1 ; gate using LUMBERJACKING1 runebook starting at rune 1
;     gosub TM_RandomRunebookTravel SJ 1 6 %runebookid  ; Randomly choose a rune from 1-6 in runebook
;     gosub TM_TravelFromObject RE %runeid ; travels to rune specified by %runeid
;
;  Use of these subrountes is allowed, but please give me (TrailMyx) credit somewhere in your script.
;
;  Release History:
;     2.0 - Initial public release
;     2.1 - Bug in TM_FindValidTextNoAdvance, added return value to TM_TravelFromNamedRunebook
;     2.2 - Bug in TM_NewCastSpell when mana gets too low
;     2.3 - Better spellcasting for chivalry, necro
;           Added TM_TravelFromNamedRunebook
;           Added TM_RandomRunebookTravel
;     2.4 - Little fix for journal handler
;     2.5 - Hack to allow for transport through a red moongate.
;
;  Requirements:
;
;    This script requires that you have your character name
;    setup in a variable called %charname.  Place this bit of code
;    in your script initialization somewhere:
;
;   gosub TM_AddUnderscore #CHARNAME
;   set %charname #RESULT
;=================================================================
;-------------------------------------------------------------------------------
; %1 = spell number
; %2 = #TARGETID or SELF or NONE
; %3 = retry count (-1 = cast until successful)
; %4 = cast delay
; %5 = recovery delay
sub TM_NewCastSpell
  namespace push
  namespace local NCS
  set !lpc #LPC
  set #LPC 100
  set !whichspell %1
  set !whichtarget %2
  set !castretrymax %3
  set !waitdelay %4
  set !recovery_delay %5

  set !castretry 0
  set !temp_ltargetid #LTARGETID
  set !temp_ltargetkind #LTARGETKIND

  NewCastSpell_loop1:
    if !castretrymax < 0
      goto NewCastSpell_cont1
    if !castretry > !castretrymax
      goto NewCastSpell_end1
    NewCastSpell_cont1:
      gosub TM_AdvJournalSync SPELLCAST
      set #LTARGETKIND 1
      set #LTARGETID !whichtarget
      set !tempmana #MANA
      event macro 15 !whichspell ; cast the spell
      wait !waitdelay
      set !targettimeout #SCNT + 7
      NewCastSpell_wait1:
        gosub TM_AdvJournalScan SPELLCAST VALID you_have_not_yet mana your_spirit more_reagents
        if #RESULT = #TRUE || #SCNT > !targettimeout
        {
          set !casttimeout #SCNT2 + !recovery_delay
          repeat
          until #SCNT2 > !casttimeout     ; finish up cast delay
          set !castretry !castretry + 1
          goto NewCastSpell_loop1
        }
        if !whichtarget = NONE
          goto NewCastSpell_skip1
        if #TARGCURS = 1
          goto NewCastSpell_targ1
        goto NewCastSpell_wait1 ; wait for target cursor

  NewCastSpell_targ1:
    if !whichtarget = SELF
      event macro 23
    else
      event macro 22

  NewCastSpell_skip1:
    wait 5
    set !casttimeout #SCNT2 + !recovery_delay
    NewCastSpell_skip2:
      if !whichspell >= 0 && !whichspell <= 63 ; Magery
      {
        gosub TM_AdvJournalScan SPELLCAST VALID spell_fizzles there_is_already mana your_spirit more_reagents
      }
      else
      {
        set !cont #FALSE  ; Chivalry, Necromancy, etc
        finditem !whichtarget *
        if !whichtarget in SELF_NONE || #FINDKIND <> -1
          set !cont #TRUE

        if #MANA >= !tempmana && !cont = #TRUE ; check if target is still there
          set #RESULT #TRUE
        else
          set #RESULT #FALSE
      }
      repeat
      until #SCNT2 > !casttimeout     ; finish up cast delay
      if #RESULT = #TRUE
      {
        if !castretrymax > -1
        {
          set !castretry !castretry + 1 ; %castretrymax of -1 will cast until successful
          if !castretry > !castretrymax
            goto NewCastSpell_end1
        }
        goto NewCastSpell_loop1
      }
      if #SCNT2 <= !casttimeout     ; finish up cast delay
        goto NewCastSpell_skip2
  NewCastSpell_end1:
    set #LTARGETID !temp_ltargetid
    set #LTARGETKIND !temp_ltargetkind
    set #LPC !lpc
    namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = index location within runebook (1-16)
; %3 = index location within runebook (1-16), try up to this point
; %4 = runebook item id
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromRunebook
  namespace push
  namespace local RFR
  set #LTARGETKIND 1
  set !method %1
  set !locindex %2
  set !locindexend %3
  set !rbook %4

  finditem !rbook C_ , #BACKPACKID
  if !method notin RE_GA_SJ || #FINDKIND = -1
  {
    namespace pop
    return #TRUE
  }
  if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }

  TravelFromRunebook_loop1:
    set #LOBJECTID !rbook
    set #LTARGETKIND 1
    event macro 17 0
    gosub GumpWait generic_gump generic_gump

    set !runeclickx 140 ; page 1, rune 1
    set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
    if !locindex > 8
    {
      set !runeclickx 310 ; page 2, rune 1
      set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
    }
    set !runeclicky #CONTPOSY + 196
    click !runeclickx !runeclicky
    wait 5

    set !runeclicky #CONTPOSY + 24
    set !runeclickx #CONTPOSX + 164 ; page 1 set to default
    if !locindex % 2 = 0
    {
      set !runeclickx #CONTPOSX + 305 ; page 2 set to default
    }
    click !runeclickx !runeclicky
    wait 5
    set !oldx #CHARPOSX
    set !oldy #CHARPOSY
    if !method = RE
      gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful
    if !method = GA
    {
      gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful
      set !temp_cnt #SCNT + 10
      repeat
        finditem KEF_OTF_JEF G_0
      until #FINDKIND <> -1 || #SCNT > !temp_cnt
      if #FINDKIND <> -1
      {
        set #LOBJECTID #FINDID
        wait 10
        event macro 17 0
        wait 20
        if #CONTNAME = generic_gump && #CONTSIZE = 420_280
        {
          gosub TM_AdvJournalSync SPELLCAST
          set !clickx #CONTPOSX + 26
          set !clicky #CONTPOSY + 261
          click !clickx !clicky ; click ok
        }
      }
    }

    if !method = SJ
      gosub TM_NewCastSpell 210 !rbook -1 10 30 ; sacred journey until successful
    wait 30

    set !tempscnt #SCNT + 10
  WaitforTravel_loop1:
    gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking you_spirit_lacks
    if #RESULT = #TRUE
    {
      gosub TM_AdvJournalSync SPELLCAST
      set !locindex !locindex + 1
      if !locindex > !locindexend
      {
        namespace pop
        return #TRUE
      }
      goto TravelFromRunebook_loop1
    }
    if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
      goto WaitforTravel_loop1

  if #CONTNAME = generic_gump && #CONTSIZE = 452_236 ; RunUO close runebook
  {
    set !clickx #CONTPOSX + 120
    set !clicky #CONTPOSY + 60
    click !clickx !clicky mc r
    wait 5
  }
  namespace pop
  click 401 254 n
return #FALSE
;------------------------------------------------
; %1 method
; %2 starting index
; %3 ending index
; %4 runebook name
sub TM_TravelFromNamedRunebook
  namespace push
  namespace local TFNR
  set !method %1
  set !start_index %2
  set !end_index %3
  set !runbook_name %4
  if !method notin RE_GA_SJ
  {
    namespace pop
    return #TRUE
  }
  if !start_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  if !end_index notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  locatenamedrunebook:
    finditem ZBN C_ , #BACKPACKID
    if #FINDKIND <> -1
    {
      event property #FINDID
      if !runbook_name in #PROPERTY
      {
        gosub TM_TravelFromRunebook !method !start_index !end_index #FINDID ; recall to location
      }
      else
      {
        ignoreitem #FINDID rbook
        goto locatenamedrunebook
      }
    }
    else
    {
      display ok Cannot locate specified runebook named , #SPC , !runbook_name
      stop
    }
  ignoreitem reset rbook
  namespace pop
return
;-------------------------------------------------------------------------------
sub TM_RandomRunebookTravel
  namespace push
  namespace local RRT
  set !travelmethod %1
  set !rune1 %2
  set !rune2 %3
  set !runebook %4
  if !rune1 > !rune2
  {
    set !temp !rune2
    set !rune2 !rune1
    set !rune1 !temp
  }
  RunebookTravel_loop1:
    set !random #RANDOM
    set !rune ( ( !random % ( !rune2 - !rune1 + 1 ) ) + !rune1 )
    gosub TM_TravelFromRunebook !travelmethod !rune !rune !runebook
    if #RESULT = #TRUE
      goto RunebookTravel_loop1
  namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = Object Findid
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromObject
  namespace push
  namespace local RFR
  set !method %1
  set !object %2

  finditem !object C_ , #BACKPACKID
  if !method notin RE_GA_SJ || #FINDKIND = -1
  {
    namespace pop
    return #TRUE
  }

  set !oldx #CHARPOSX
  set !oldy #CHARPOSY
  TravelFromObject_loop1:
    if !method = RE
      gosub TM_NewCastSpell 31 !object -1 10 10 ; recall until successful
    if !method = GA
    {
      gosub TM_NewCastSpell 51 !object -1 10 20 ; gate until successful
      set !temp_cnt #SCNT + 10
      repeat
        finditem KEF_OTF_JEF G_0
      until #FINDKIND <> -1 || #SCNT > !temp_cnt
      if #FINDKIND <> -1
      {
        set #LOBJECTID #FINDID
        wait 10
        event macro 17 0
        wait 20
        if #CONTNAME = generic_gump && #CONTSIZE = 420_280
        {
          gosub TM_AdvJournalSync SPELLCAST
          set !clickx #CONTPOSX + 26
          set !clicky #CONTPOSY + 261
          click !clickx !clicky ; click ok
        }
      }
    }

    if !method = SJ
      gosub TM_NewCastSpell 210 !object -1 10 30 ; sacred journey until successful
    wait 30

    set !tempscnt #SCNT + 10
  WaitforTravel2_loop1:
    gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking your_spirit_lacks
    if #RESULT = #TRUE
    {
      gosub TM_AdvJournalSync SPELLCAST
      set !locindex !locindex + 1
      if !locindex > !locindexend
      {
        namespace pop
        return #TRUE
      }
      goto TravelFromObject_loop1
    }

    if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
      goto WaitforTravel2_loop1
  namespace pop
return #FALSE
;-------------------------------------------------------------------------------
; %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
  if !_jindex = N/A
    set !_jindex #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 <= #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 #LPC !temp_lpc
  namespace pop
  set !TM_FunctionCalled #TRUE
return #FALSE
;-------------------------------------------------------------------------------
; %1 = Gumpname 1
; %2 = Gumpname 2
; #TRUE gump occured before timeout
sub GumpWait
  namespace push
  namespace local GW
  wait 10
  set !timedelay #SCNT
  while #SCNT <= !timedelay + 7
  {
    if #CONTNAME = %1 || #CONTNAME = %2
    {
      namespace pop
      return #TRUE
    }
  }
  namespace pop
return #FALSE



;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;End of TM subs
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





 
Title: Re: the beginnings
Post by: Scrripty on July 30, 2009, 12:44:57 AM
You need to put TM's Advanced Journal Scanner in there I believe just at a quick glance.  You have a check weight gosub without a check weight SUB.  Also, you're calling TM_TravelFromRuneBook with a gosub, but the name doesn't match, the closest is, TM_TravelFromNamedRunebook.  That should help fix some of your problems. :)
Title: Re: the beginnings
Post by: Cerveza on July 30, 2009, 05:19:09 AM
Code: [Select]
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Main loop
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MAIN_LOOP
    GoSub Harpies

Try this instead

Code: [Select]
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Main loop
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
repeat
gosub Harpies
until #false

Your mainloop isn't code and falls through....
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 07:56:24 AM
Also, you're calling TM_TravelFromRuneBook with a gosub, but the name doesn't match, the closest is, TM_TravelFromNamedRunebook.  That should help fix some of your problems. :)

thats because i kept trying different ways, from in my script using runebook and using TMs runebook, and using namedrunebook and TMs namedrunebook. i couldn't get either to work, and i got so frustrated last night that i wasn't paying attention when i posted. sorry.
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 08:01:43 AM
For my runebooks subs to work, you need these:

TM_AdvJournalSync
TM_AdvJournalScan
at least TM_TravelFromRunebook
and TM_NewCastSpell

That's why I suggested you loading your code up into ScriptUO (the program) and then going to the Tools tab and selecting Syntax Error Check

Here's the output from that:

Code: [Select]
Method count: 56
Command count: 56
*** Pass 1 - Label accounting:
*** Warning - GOSUB gumpwait - Line 79 has no matching SUBroutine
*** Warning - GOSUB check_weight - Line 441 has no matching SUBroutine
*** Warning - SUBROUTINE tm_travelfromnamedrunebook - Line 165 unused
Subroutine labels = 10
Tag labels = 11
34 Code block(s).
3 Warnings(s) encountered.
*** Pass 2 - Execution [SYNTAXCHECK]
** Error - Line 1: Unknown command Setup

So it looks like you have the runebook stuff covered.  In fact you don't need tm_travelfromnamedrunebook.  But the script is looking for two other subs that aren't there yet.
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 08:07:05 AM
ahh, ok. Sorry about the syntax check, i thought you meant i was supposed to do that when i was done.  :(
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 08:08:09 AM
Once you get your code read to start testing, the next thing you'll want to learn is placing "pause" in places.  Then the script pauses, you may single step through the code to see what the execution is doing.

You can then use F7 (Step into), F8 (Step over - doesn't descent into subroutines to see the execution) and F6 (Step out - completes a subroutine execution)
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 08:09:57 AM
ahh, ok. Sorry about the syntax check, i thought you meant i was supposed to do that when i was done.  :(

It's a good tool to run as your are writing your script, especially when you start testing pieces of your code.  Sometimes your problems will be runtime bugs, and you'll have to use the method I described in the last post to slowly step through your code.
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 09:32:47 AM
Once you get your code read to start testing, the next thing you'll want to learn is placing "pause" in places.  Then the script pauses, you may single step through the code to see what the execution is doing.

You can then use F7 (Step into), F8 (Step over - doesn't descent into subroutines to see the execution) and F6 (Step out - completes a subroutine execution)


I feel very stupid, because I don't think I understand what you are saying. Do I need to put pauses after every sub, open the code in SUO, and then use F7 to run each sub individually? Do I highlight the sub I want to run?
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 09:37:10 AM
well, you can actually put a pause right at the beginning and step to wherever.  Really as you get better at script authoring, you'll start to know where the code is going wonky and that will tell you were you may have to put your pauses so you can single step and see what's happening.

Soon, you will wonder as you are single stepping, "gee, I wonder what value is in that variable..."  Have you wondered that yet?  :)
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 09:46:05 AM
yes, unfortunately. I look at advanced codes and think "what does that do? what does it have to do with anything?" and get super confused. Then, when I think I understand simple things, I really don't. I end up adding things like gosub check_weight, when i just wanted to put wait 5. you know, making things harder than they are.

I ran a syntax check, and everything looks good right now. I show no syntax errors, but I still am not recalling. I am going to work with the pausing and stepping through things, but I loaded up what I have right now for you to look at (when you have time).
Title: Re: the beginnings
Post by: Cerveza on July 30, 2009, 09:57:34 AM
Just curious, did you read the tutorials?

Did you make a written listing of what you want the script to do?

I find it MUCH easier to just write down steps you want to accomplish... including some "if this happens" and such.

1 - Recall to a gate (need to define a gate rune in a runebook)
2 - Walk to the gate (need some type of rail here that will search for the gate)
3 - Select the destination (gump check and click)
4 - Wait till I appear on the other side of the gate
5 - Rail over to the place I want to be using the safest path

etc....

Just write it out like your doing it. Or even take your char and do by hand just exactly what you want the script to do. Keep a notepad handy and write down each step along the way. Make comments about stuff while your doing it.

Just jumping into a script isn't always the best way to go.
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 10:01:08 AM
I've read each tutorial multiple times. I do have my step by step list, which is what I am doing now. Starting from the beginning, I want to make sure I have a dagger in my pack, I want to select all my variables (runebooks, secure, etc.), and I want to recall to where the harpies are. That is as far as I've gotten. Stuck at step 3.
Title: Re: the beginnings
Post by: Cerveza on July 30, 2009, 10:05:49 AM
Ok cool, post up what your doing, step by step, and we can help with each part as you get to it....

Of course if you want to, some like to resolve things on their own, and thats cool.
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 10:17:04 AM
ehh, I will post up what I eventually want the stupid thing to do, step by step, so that you know where I am going with this.

as for resolving it on my own, that is how I usually roll, but this has me so flustered that I have to ask for help. I usually like to do things on my own so that I'm not being annoying or bothering anyone or anything.


Newest version is under the old post
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 10:36:20 AM
You can probably get your script to start working by replacing your line 38 with:

Code: [Select]
GoSub TM_TravelFromRunebook %travel_method %currentRune 16 %featherrunebookid

Also you need to be sure you have a valid valud in %travel_method and %currentRune

%currentRune should be a number from 1-16 and denotes what rune number is were page 1 runes are numbered 1-8 and page 2 runes are numbered 9-16.

%travel_method should be set to RE, SJ or GA.

Your code:
Code: [Select]
set %currentBookID %_runebook . %currentSet

this will probably leave %currentBookID uninitialized.  You'll know this because the value in this variable will be N/A
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 10:38:19 AM
Probably the BEST thing you can do when you are debugging is to be sure that you have variables that are initialized.  Also a great debugging things to do is to single step to your

Code: [Select]
GoSub TM_TravelFromRunebook %travel_method %currentRune 16 %currentBook

and be sure there is valid values for all of these variables listed.  Any N/A in any of those variables will cause things to not work.
Title: Re: the beginnings
Post by: Scrripty on July 30, 2009, 11:17:53 AM
ehh, I will post up what I eventually want the stupid thing to do, step by step, so that you know where I am going with this.

as for resolving it on my own, that is how I usually roll, but this has me so flustered that I have to ask for help. I usually like to do things on my own so that I'm not being annoying or bothering anyone or anything.


Newest version is under the old post


It might be easier for you to write your OWN sub to recall to harpies at first.  And do it very simply.  You already have your rune book, so just use event macro *sacred journey* then explicitly target your books id or whatever.  Much easier for you to do that than try to make someone elses more advanced sub do that for you. :)  I always try to keep everything VERY simple, then add more advanced features/subs as I go.  I'll write out a whole scipt using VERY simple euo code, then I'll upgrade it and upgrade it till its what I wanted.  It's not hard to add things once you know how they work, and starting with the simple basics gets you that experience. :)  Don't try to reinvent the wheel at first, just work with what you can.  If this is going to be a personal script, you don't need an elaborate setup for anyone to use, just make it work for you for now.
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 11:20:50 AM
I'm not sure I agree with you there Twinkle McNugget.  There are so  many issues regarding recalling with runebooks.  Regs? Mana? Blocked locations? Fizzles? etc, etc, etc.  For a new scripter, it's MUCH easier to just use something that works.

When you start getting cool at the scripting thing, then it's a better idea to branch out into the additional logic required to handle everything that can go wrong while runebook traveling.
Title: Re: the beginnings
Post by: Scrripty on July 30, 2009, 11:25:11 AM
I'm not sure I agree with you there Twinkle McNugget.  There are so  many issues regarding recalling with runebooks.  Regs? Mana? Blocked locations? Fizzles? etc, etc, etc.  For a new scripter, it's MUCH easier to just use something that works.

When you start getting cool at the scripting thing, then it's a better idea to branch out into the additional logic required to handle everything that can go wrong while runebook traveling.

What I was trying to say, is when you have NO experience whatsoever, just doing things as simply as possible to get them working is a good way for me to do it.  I like things to just work, then I'll add another feature, and another feature, and another, until it's what I want.  Then I actually understand how it all works, and it makes using a more advanced sub a lot easier.  You gotta start somewhere and if you have no idea how things work its best to learn the basics, which is, get id of runebook, use event macro to cast recall, then target the book. haha  You know what I'm saying. :)  Gotta crawl before you can run in an Ironman...
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 12:00:32 PM
Twinkle McNugget is essentially correct in his assessment of simplicity.  However, what if you can boil down runebook recalling to 6 lines?  That's pretty simple.  If you can just take the whole recalling/SJ/Gating for granted, then try this:

Just be sure you have a valid rune in the first location of your runebook and replace your #FINDID.

Get this bit of code to work and then you can add onto it.  Give it a try!  I just tested it and it works fine.

Code: [Select]
set %travel_method RE ; RE, GA, or SJ
set %rune1 1
set %rune2 1
set %runebook XXYYZZ1 ; <- replace this with your #FINDID of your runebook
gosub TM_TravelFromRunebook %travel_method %rune1 %rune2 %runebook
stop

;-------------------------------------------------------------------------------
;    Runebook subs -------------------------------------------------------------
;-------------------------------------------------------------------------------
; %1 = spell number
; %2 = #TARGETID or SELF or NONE
; %3 = retry count (-1 = cast until successful)
; %4 = cast delay
; %5 = recovery delay
sub TM_NewCastSpell
  namespace push
  namespace local NCS
  set !lpc #LPC
  set #LPC 100
  set !whichspell %1
  set !whichtarget %2
  set !castretrymax %3
  set !waitdelay %4
  set !recovery_delay %5
  set !castretry 0
  set !temp_ltargetid #LTARGETID
  set !temp_ltargetkind #LTARGETKIND
  
  repeat
  until #LLIFTEDKIND = 0 && #TARGCURS = 0 && A notin #CHARSTATUS
  
NewCastSpell_loop1:
  if !castretrymax < 0
    goto NewCastSpell_cont1
  if !castretry > !castretrymax
    goto NewCastSpell_end1
NewCastSpell_cont1:
  gosub TM_AdvJournalSync SPELLCAST
  set #LTARGETKIND 1
  set #LTARGETID !whichtarget
  set !tempmana #MANA
  event macro 15 !whichspell ; cast the spell
  wait !waitdelay
  repeat
  until A notin #CHARSTATUS
  set !targettimeout #SCNT + 7
NewCastSpell_wait1:
  gosub TM_AdvJournalScan SPELLCAST VALID spell_fizzles you_have_not_yet mana your_spirit
  if #RESULT = #TRUE || #SCNT > !targettimeout
  {
    set !casttimeout #SCNT2 + !recovery_delay
    repeat
    until #SCNT2 > !casttimeout     ; finish up cast delay
    set !castretry !castretry + 1
    goto NewCastSpell_loop1
  }
  gosub TM_AdvJournalScan SPELLCAST VALID more_reagents
  if #RESULT = #TRUE
    goto NewCastSpell_end1 ; fail
  
  if !whichtarget = NONE
    goto NewCastSpell_skip1
  if #TARGCURS = 1
    goto NewCastSpell_targ1
  goto NewCastSpell_wait1 ; wait for target cursor
  
NewCastSpell_targ1:
  if !whichtarget = SELF
    event macro 23
  else
    event macro 22
  
NewCastSpell_skip1:
  wait 5
  set !casttimeout #SCNT2 + !recovery_delay
NewCastSpell_skip2:
  if !whichspell >= 0 && !whichspell <= 63 ; Magery
  {
    gosub TM_AdvJournalScan SPELLCAST VALID spell_fizzles there_is_already mana your_spirit more_reagents
  }
  else
  {
    set !cont #FALSE  ; Chivalry, Necromancy, etc
    finditem !whichtarget *
    if !whichtarget in SELF_NONE || #FINDKIND <> -1
      set !cont #TRUE
    
    if #MANA >= !tempmana && !cont = #TRUE ; check if target is still there
      set #RESULT #TRUE
    else
      set #RESULT #FALSE
  }
  repeat
  until #SCNT2 > !casttimeout     ; finish up cast delay
  if #RESULT = #TRUE
  {
    if !castretrymax > -1
    {
      set !castretry !castretry + 1 ; %castretrymax of -1 will cast until successful
      if !castretry > !castretrymax
        goto NewCastSpell_end1
    }
    goto NewCastSpell_loop1
  }
  if #SCNT2 <= !casttimeout     ; finish up cast delay
    goto NewCastSpell_skip2
NewCastSpell_end1:
  set #LTARGETID !temp_ltargetid
  set #LTARGETKIND !temp_ltargetkind
  set #LPC !lpc
  namespace pop
return
;-------------------------------------------------------------------------------
; %1 = Method (RE, GA, SJ)
; %2 = index location within runebook (1-16)
; %3 = index location within runebook (1-16), try up to this point
; %4 = runebook item id
; returns #TRUE if error, #FALSE for no error
sub TM_TravelFromRunebook
  namespace push
  namespace local RFR
  set #LTARGETKIND 1
  set !method %1
  set !locindex %2
  set !locindexend %3
  set !rbook %4
  
  finditem !rbook C_ , #BACKPACKID
  if !method notin RE_GA_SJ || #FINDKIND = -1
  {
    namespace pop
    return #TRUE
  }
  if !locindex notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  if !locindexend notin 1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16
  {
    namespace pop
    return #TRUE
  }
  
TravelFromRunebook_loop1:
  set #LOBJECTID !rbook
  set #LTARGETKIND 1
  event macro 17 0
  gosub GumpWait generic_gump generic_gump
  set !tempcontx #CONTPOSX
  set !tempconty #CONTPOSY
  
  set !runeclickx 140 ; page 1, rune 1
  set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 1 ) / 2 ) ) )
  if !locindex > 8
  {
    set !runeclickx 310 ; page 2, rune 1
    set !runeclickx ( #CONTPOSX + !runeclickx + ( 35 * ( ( !locindex - 9 ) / 2 ) ) )
  }
  set !runeclicky #CONTPOSY + 196
  click !runeclickx !runeclicky
  wait 5
  
  set !runeclicky #CONTPOSY + 24
  set !runeclickx #CONTPOSX + 164 ; page 1 set to default
  if !locindex % 2 = 0
  {
    set !runeclickx #CONTPOSX + 305 ; page 2 set to default
  }
  click !runeclickx !runeclicky
  wait 5
  set !oldx #CHARPOSX
  set !oldy #CHARPOSY
  if !method = RE
    gosub TM_NewCastSpell 31 !rbook -1 10 10 ; recall until successful
  if !method = GA
  {
    gosub TM_NewCastSpell 51 !rbook -1 10 20 ; gate until successful
    set !temp_cnt #SCNT + 10
    repeat
      finditem KEF_OTF_JEF G_0
    until #FINDKIND <> -1 || #SCNT > !temp_cnt
    if #FINDKIND <> -1
    {
      set #LOBJECTID #FINDID
      wait 10
      event macro 17 0
      wait 20
      if #CONTNAME = generic_gump && #CONTSIZE = 420_280
      {
        gosub TM_AdvJournalSync SPELLCAST
        set !clickx #CONTPOSX + 26
        set !clicky #CONTPOSY + 261
        click !clickx !clicky ; click ok
      }
    }
  }
  
  if !method = SJ
    gosub TM_NewCastSpell 210 !rbook -1 10 30 ; sacred journey until successful
  wait 30
  
  set !tempscnt #SCNT + 10
WaitforTravel_loop1:
  gosub TM_AdvJournalScan SPELLCAST VALID location_is_blocked something_is_blocking you_spirit_lacks
  if #RESULT = #TRUE
  {
    gosub TM_AdvJournalSync SPELLCAST
    set !locindex !locindex + 1
    if !locindex > !locindexend
    {
      namespace pop
      return #TRUE
    }
    goto TravelFromRunebook_loop1
  }
  if ( ( #CHARPOSX = !oldx && #CHARPOSY = !oldy ) && #SCNT < !tempscnt )
    goto WaitforTravel_loop1
  
;  if #CONTNAME = generic_gump && #CONTSIZE = 452_236 ; RunUO close runebook
;  {
;    set !clickx #CONTPOSX + 120
;    set !clicky #CONTPOSY + 60
;    click !clickx !clicky mc r
;    wait 5
;  }
  namespace pop
return #FALSE
;-------------------------------------------------------------------------------
; %1 = Gumpname 1
; %2 = Gumpname 2
; #TRUE gump occured before timeout
sub GumpWait
  namespace push
  namespace local GW
  wait 10
  set !timedelay #SCNT
  while #SCNT <= !timedelay + 7
  {
    if #CONTNAME = %1 || #CONTNAME = %2
    {
      namespace pop
      return #TRUE
    }
  }
  namespace pop
return #FALSE
;-------------------------------------------------------------------------------
; %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
;-------------------------------------------------------------------------------
; %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
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 12:04:12 PM
if i have a piece of code, lets say
Code: [Select]
sub setup_travel
  set %travel_method SJ
  display YESNO Travel by Sacred Journey?
  if #dispres = NO
  {
    set %travel_method RE
  }
return

that set %travel_method SJ sets the travel method to SJ in the entire script, correct? so if I have the same set for my runebooks, doens't that set their ID for that particular runebook (feathers) in the entire script (when it is called for)? how can i check that these variables are actually being set?
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 12:07:51 PM
This is the part that sets up the #FINDID:

Code: [Select]
sub setup_feather_runebooks
display Target your feather Rune Book
  wait 1
  set #targcurs 1
  while #targcurs = 1
    wait 0
set %featherrunebookid #ltargetid
return

What you are doing is grabbing the #FINDID from the object you last targetted. 

You can also find this value by hand by just double clicking (opening) your runebook and then check to see what the value is in #LOBJECTID.  This stands for "last object id".  This is always the value of what you double clicked last.
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 12:11:24 PM
how can i check that these variables are actually being set?

ok, try my test code.  Put a pause right before the TM_TravelFromRunebook and let it run until it pauses.

Goto Tools/VarDump and look for these 4 values:
%travel_method
%rune1
%rune2
%runebook

They should all have something assigned to them.  Now go and do the same thing with your code and check to see that your variables you're using are also assigned with something.  If any one of them has an N/A or some nonsensical value, then you'll know where your bug is.
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 12:19:55 PM
You are going to find that you'll probably spend only about 15% of your time actually writing code.  The rest of the time you'll be debugging it.  So it's really best to write your code in little functional blocks so you can test the little pieces and assemble them into larger working scripts. 

The concept of debugging can be odd for someone who hasn't really done much.  Another problem is EUO doesn't give you much facility do actually debug easily.  So really you only have the VARDUMPs to look at, and also you can create your own variable watch list (Tools/Manage Varlist).  Frankly, this his how I normally do my debugging; I rarely use VARDUMPs.  It's cumbersome, but it does eventually show where your bugs are.

Many people start and fail scripting because they didn't realize the needed patience during that 85% debugging phase.  If it helps at all, we all go through the same thing.
Title: Re: the beginnings
Post by: Scrripty on July 30, 2009, 12:25:20 PM
Yea, try debugging my pvm script with all the timings.  Getting 10 spells to cast on time, when you want, under all the right conditions can be a pain.  But then when you make a mistake!?!??  haha I've spent TONS of time looking for ONE bracket out of place.  But strangely enough it didn't cause too much of a NOTICEABLE problem.  If I wouldn't have known my script inside and out, I wouldn't have found it.
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 02:53:43 PM
ok, when i step by step go through the script (good old F8), it seems to work just fine. Goes right through. I think the problem lies right here

Code: [Select]
sub harpies
set %currentBookID %_runebook . %currentSet
    GoSub TM_TravelFromNamedRunebook %travel_method %currentRune 16 %featherrunebookid
return

the variables are set, I checked. it is as if the travelfromnamedrunebook is not getting the travel method variable. also, the only N/A I have is the %currentbookID, and i don't know how to fix that
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 02:57:58 PM
Where are you setting %_runebook or %currentSet?  I don't think that means anything. 

Ohh, also you are using the NAMED runebook.  I didn't notice that before.  Replace TM_TravelFromNamedRunebook to TM_TravelFromRunebook.

This is because %featherrunebookid contains the ID of the runebook, and not the name.

Again, try my sample code to see how it works and then compare it to your own.
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 03:01:32 PM
well, i thought right there, where is says

set %currentBookID %_runebook . %currentSet

i thought that would move my ids into the gosub TM_travel
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 03:01:47 PM
Or if you don't want to swap out the routines, then just include the name as the argument....

Code: [Select]
GoSub TM_TravelFromNamedRunebook %travel_method %currentRune 16 your_runebook_name
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 03:09:04 PM
I'm not helping you help me, am I? I am sorry, I do appreciate your help.

I tried switching it from namedrunebook to runebook with runebok ids and with runebook names. It is as if it goes to your sub, and then just stops. but, i want to do a lot of F8s through your example to see how it goes through your subs. will let you know what i find
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 03:10:40 PM
you should update your code so I can see where you are at.
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 03:21:42 PM
well, i thought right there, where is says

set %currentBookID %_runebook . %currentSet

i thought that would move my ids into the gosub TM_travel

Well, you'll have to do some research on the "dot" operator.  Frankly, that's a bit more advanced subject so you should probably steer clear of that until you get some of the basics down.  So just delete that line.... ;)

I cleaned up your first few lines: 
Code: [Select]
;~~~~~~~~~~~~~~~~~~~~~~~~Runebooks~~~~~~~~~~~~~~~~~~~~~~
GoSub setup_secure_runebook
GoSub setup_feather_runebooks
GoSub setup_travel
GoSub setup_secure
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;Main loop
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
repeat
  GoSub Harpies
until #false
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;subs
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sub Harpies
  set %currentBookID %featherrunebookid
  GoSub TM_TravelFromRunebook %travel_method %currentRune 16 %currentBookID
return



Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 03:25:55 PM
Oh, take a look at your %currentRune value, it's not initialized.  You should probably set that in setup....
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 03:33:57 PM
ok, added the %currentrunevalue for the books. i am going to update my code in my original post. couldn't i use the example you gave me to put my two runes into one runebook, and just make whoever uses the script set their own runebookid? (or later write in a way so they just have to target their rune book?)
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 03:40:48 PM
Well you already have those setup routines in there to target the runebooks.  That's what this code does:

Code: [Select]
sub setup_secure_runebook
display Target your secure Rune Book
  wait 1
  set #targcurs 1
  while #targcurs = 1
    wait 0
set %securerunebookid #ltargetid
set %currentrunevalue 1
return

sub setup_feather_runebooks
display Target your feather Rune Book
  wait 1
  set #targcurs 1
  while #targcurs = 1
    wait 0
set %featherrunebookid #ltargetid
set %currentrunevalue 1
return

What you have is very close now.  Just tweak your harpies sub:

Code: [Select]

sub harpies
    set %currentbookid %featherrunebookid
    set %currentRune %currentrunevalue ; need to set %currentRune
    GoSub TM_TravelFromRunebook %travel_method %currentRune 16 %currentbookid
return
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 03:49:19 PM
TM, I did what you said, and of course it worked. But, I want to understand why it worked.


sub harpies
    THIS -> set %currentbookidcame from THIS -> %featherrunebookid which i set in my setup?
   same with this -> set %currentRune coming from this ->%currentrunevalue ; need to set %currentRune
       GoSub TM_TravelFromRunebook %travel_method %currentRune 16 %currentbookid
return


so, later when i want to go home i can use basically the same thing but change %featherrunebookid to %securerunebookid because it is using the securerunebookid to set the currentrunebookid, which is that specific sub?
Title: Re: the beginnings
Post by: SunTigress on July 30, 2009, 04:12:37 PM
after having that lightbulb come on, i get it. i changed my code so that i only have one runebook now. code updated  :D
Title: Re: the beginnings
Post by: Scrripty on July 30, 2009, 04:54:28 PM
after having that lightbulb come on, i get it. i changed my code so that i only have one runebook now. code updated  :D

We were just talking the other night about staring at code until you have divine intervention and you just, "get it." haha
Title: Re: the beginnings
Post by: _C2_ on July 30, 2009, 04:57:32 PM
if u stare long enough, it all turns green and letters and numbers start falling downward on the screen like matrix.  humm.. or was that from something else?
Title: Re: the beginnings
Post by: TrailMyx on July 30, 2009, 05:50:40 PM
after having that lightbulb come on, i get it. i changed my code so that i only have one runebook now. code updated  :D

I'm glad you got it!

I guess the best lesson you can take away from this is a script doesn't write itself.  If you don't initialize a variable, then it just won't have anything in it.  That's why I was stressing KNOWING what a variable has in it before you rely on that value for anything.  Frankly, I have problems all the time when I *think* I have a value in a variable only to find it wasn't what I thought.

Also since scripts run in a linear fashion, just because you have the variable set somewhere in the code doesn't mean it was executed yet.  So you start at line 1, then to line 2, and so forth.  You might take diversions because of a gosub, goto, while, for or repeat.

Just remember that a script or program execute in a linear fashion and it ALWAYS does just what you tell it.  Even when you tell it to do the wrong thing.  Bugs suck that way.

Scripts and programs have a flow, and you are in total control over that flow.
Title: Re: the beginnings
Post by: Scrripty on July 30, 2009, 06:28:10 PM
You should really start with basics.  That helped me a ton.  Write simple scripts.  Like first start with attacking a harpy and killing it.  Then skin the corpse.  Then get that working, then open the corpse and loot the feathers.  At that point you have a fully functioning feather farmer.  It will attack harpy's and loot them of feathers.  Now just start adding the features you like, one at a time.  Recalling, rails, all that.  And don't make rails difficult... you can make explicit rails that do what you want them to do EASILY. :)  They aren't hard.  I'd have started with what I want the script to DO first.  That's kill harpies and loot feathers. :)  Everything else is fluff.  When I started on my script I started with a bare bones casting sub.  That's it.
Title: Re: the beginnings
Post by: Endless Night on August 01, 2009, 06:40:48 AM
Scripts and programs have a flow, and you are in total control over that flow.


Just go with the Flow man..... (said while smoking a fat one)


... wait thats not it at all... you are the flow... feel the force Luke... (or in your case Leia)
Title: Re: the beginnings
Post by: Hoby on August 04, 2009, 12:12:31 AM
Congrats on your first script.  Sounds like your getting it down.  I'm almost tempted to try to write one myself, but, I get the outline of it done then lose interest.  My add (adhd) whatever it is kicks in.  Oh something shiny.......dam, did it agian.  JK.  Way to go on your scripting.