Author Topic: Having issue with my runebook code.  (Read 11307 times)

0 Members and 1 Guest are viewing this topic.

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Having issue with my runebook code.
« on: July 03, 2008, 03:49:14 PM »
0
Hoping that someone can help me here.

This script is for finding and shearing sheep, killing, and when over weight dropping to a secure. Everything seems to work fine, except changing from one rune toanother within a runebook and I do not know if it will go to the next book, because I keep getting stuck in the first one.

Code: [Select]

;==============================================================
; Script Name: Sheep Shear, Kill and Repeat
; Author: Ramses
; Version: 1.0
; Client Tested with:
; EUO version tested with: 141
; Shard OSI / FS: OSI
; Revision Date:
; Public Release:
; Purpose: To gather wool for making cloth
;
;==============================================================
;
; Acknowledgements:
; Drak for testing
; Nicar for support and help
;
;==============================================================
;
; Script Notes:
; Rune Books must be labeled with the word Sheep, multiple books are ok.
; One Rune book must be labeled House or Home with your house as rune #1
;
;==============================================================
;==============================================================
;==============================================================
; Inits & Setup GoSubs
;==============================================================
finditem TSF c
if #findkind = -1
   {
   display ok you do not have a dagger in your backpack, please get
   + one and then restart the script.
   halt
   }
set %daggerID #findid

GoSub setup
GoSub setup_runebooks
GoSub setup_opperation

;===============================================================
; Begin Main Loop
;===============================================================
 MAIN_LOOP:
GoSub to_sheep
GoSub find_sheep ;%sheeptypes G_16
if %overweight = YES
{
 GoSub to_house
}
goto main_loop

halt
;===============================================================
; End Main Loop
;===============================================================
;===============================================================
; Kill sheep
;===============================================================
Sub kill
;set #lobjectid %sheepID
event macro 27 0
wait 3
return
;===============================================================
; Check to ensure dead
;===============================================================
Sub check_death
 SCAN:
event macro 27 0
finditem #ltargetid
if #findkind = -1
   return
Goto scan
;===============================================================
; Find the Sheep
;===============================================================
sub find_sheep
set %new_startposx #CHARPOSX
set %new_startposy #CHARPOSY
set %new_startposz #CHARPOSZ
set %moveinitposy %new_startposy + 1
    {
        event pathfind %new_startposx %moveinitposy %new_startposz
    {
finditem %sheeptypes G_16
for #findindex 1 #findcnt
{
set %sheepID #findid
set %x #charposx - 1
set %y #charposy - 1
set %x_limit #charposx + 16
set %y_limit #charposy + 16
While #finddist > 2
  {
    event pathfind #findx #findy #findz
    wait 1
  }
GoSub check_weight
GoSub shear_sheep
GoSub kill
GoSub check_death
}
return
;===============================================================
; Shear Sheep
;===============================================================
sub shear_sheep
wait 1
set #lobjectid %daggerID
event macro 17 0
target
wait 5
set #ltargetid %sheepID
;set #ltargetkind 1
event macro 22 0
return
;===============================================================
; Sub Setup_Opperation for method of travel
;===============================================================
sub setup_opperation

; DEFAULT VALUES
set %method_of_travel RECALL
set %use_invis NO
set %use_hiding NO
display YESNO Do you wish to use sacred journaey rather than recalling?
if #dispres = YES
   {
    set %method_of_travel SACRED
   }
SETUP_OF_OPPERATION_COMPLETE:
GoSub setup_secure
return
;===============================================================
; Check Weight
;===============================================================
sub check_weight
if #weight > #maxweight - 30
 set %overweight YES
if #weight > 390
 set %overweight YES
if %overweight = YES
   {
    GoSub to_house
   }
return
;===============================================================
; Drop Wool
;===============================================================
sub drop_off
finditem %wool C_ , %packid
if #findkind <> -1
   {
   exevent drag #findid #findstack
   exevent dropc %secure
   wait 5s
   }
set %overweight NO
return
;===============================================================
; To Sheep Pen
;===============================================================
sub to_sheep
GoSub use_runebook %sheep_runebook . %book %method_of_travel %rune
wait 1s
return
;===============================================================
; Movement with runebook
; Runebook subs came from Peragins LJ script (2005)
;===============================================================
sub use_runebook

;%1 - Runebook ID
;%2 - Method used on book - Use runebook charge / Recall / Sacred Journey or Gate
;%3 - Index number of rune to use

;Useage - gosub use_runebook RUNEBOOKID METHOD RUNE#

;===============================================================
; ERROR CHECKS
;===============================================================
if %3 < 1 || %3 > 16
{
 display OK Rune number outwith perameters.
 halt
}
finditem %1
if #findkind = -1
{
 display OK Specified Runebook not found, Check that the container is open.
 halt
}
set #lobjectid #findid
set %methods RECALL_CHARGES_SACRED_JOURNEY_GATE_TRAVEL
if %2 NOTIN %methods
{
 display OK Method to travel not set correctly, please refer to documentation in the subroutine header.
 halt
}
set %charposx #charposx ; next 3 lines set current postion to check to see if you have recalled
set %charposy #charposy
set %charposz #charposz
;===============================================================
; Opening Runebook
;===============================================================
 OPEN_RUNEBOOK:
if #charposx <> %charposx || #charposy <> %charposy
{
 return
}
set %error #scnt + 3
event macro 17 0
wait 5
 OPENING_RUNEBOOK:
if #contsize <> 452_236
{
 if #scnt > %error
 {
  goto open_runebook
 }
 goto opening_runebook
}
set %test_X 137 + #contposx ;X co-ord of pixel to colour check for page turns
set %test_Y 31 + #contposy ;Y co-ord for above
;===============================================================
; SET CO-ORDS OF TAB FOR PAGE TO TURN TO
;===============================================================
set %index_tab %3 * 10 / 2 ;Rune # * 2 / 3 gives the runebook page index tab
str len %index_tab
if #strres = 1
{
 set %index_tab 1
 goto index_tab_set
}
str right %index_tab 1
if #strres = 5
{
 set %index_tab %index_tab / 10
 set %index_tab %index_tab + 1
 goto index_tab_set
}
if #strres = 0
{
 set %index_tab %index_tab / 10
 goto index_tab_set
}
display OK Error proccessing Index tab, please check passed rune number.
 INDEX_TAB_SET:
set %index_tab_offset 35 ;Pixels between page index tabs on the runebook GUMP
set %index_tab_X %index_tab * %index_tab_offset ; Number of TAB offsets
set %index_tab_offset 105 ;Pixels between GUMP edge and the first TAB
set %index_tab_X %index_tab_X + %index_tab_offset ; Number of TAB offsets + distance from edge of GUMP
if %index_tab > 4
{
 set %index_tab_X %index_tab_X + 28   ;set for gap between page 1 and 2
}
set %index_tab_X %index_tab_X + #contposx ;Distance from edge of screen

set %index_tab_Y 196 ;Y co-ord from TOP of GUMP
set %index_tab_Y %index_tab_Y + #contposy ; Y co-ord from TOP of screen
;===============================================================
; Turn to page of Rune Book
;===============================================================
if CHARGE NOTIN %2
{
 click %index_tab_X %index_tab_Y f
 wait 10
 set %page 1
;===============================================================
; SET IF THE JEWEL TO CLICK IS ON THE LEFT OR RIGHT PAGE
;===============================================================
 set %jewel_offset_X 140 ; X CO-ORD OF JEWEL ON LEFT PAGE
 if %rune = 2 || %rune = 4 || %rune = 6 || %rune = 8 || %rune = 10 || %rune = 12 || %rune = 14 || %rune = 16
 {
  set %page 2
  set %jewel_offset_X 300 ; X CO-ORD OF JEWEL ON RIGHT PAGE
 }
 set %jewel_X %jewel_offset_X + #contposx
}
;===============================================================
; SACRED JOURNEY
;===============================================================
if SACRED IN %2
 set %jewel_offset_Y 181
;===============================================================
; GATE TRAVEL
;===============================================================
if GATE IN %2
 set %jewel_offset_Y 161
;===============================================================
; RECALL
;===============================================================
if RECALL IN %2
 set %jewel_offset_Y 141

set %jewel_Y %jewel_offset_Y + #contposy ; Y CO-ORD OF JEWEL DEPENDING ON METHOD CHOSEN
;===============================================================
; RUNEBOOK CHARGES
;===============================================================
if CHARGE IN %2
{
 set %page 1
 set %jewel_offset_X 134
 set %jewel_offset_Y %jewel_offset_Y * %rune
 if %rune > 8
 {
  set %page 2
  set %jewel_offset_X 294
  set %jewel_number %rune - 8
  set %jewel_offset_Y %jewel_offset_Y * %jewel_number
 }
 set %jewel_X %jewel_offset_X + #contposx
 set %jewel_offset_Y 15
 set %jewel_Y 55 + #contposy
 set %jewel_Y %jewel_Y + %jewel_offset_Y
}

click %jewel_X %jewel_Y f ; THIS CLICK ACTIVATES THE RUNE
set %jindex #jindex
set %error #scnt + 10
 RECALLING:
if GATE IN %2
{
 finditem OTF G_1
 if #findkind <> -1
 {
  return
 }
}
if #scnt > %error
{
 goto open_runebook
}
for %line %jindex #jindex
{
 scanjournal %line
 if FIZZLES IN #journal
 {
  goto open_runebook
 }
 if INSUFFICIENT IN #journal
 {
  goto open_runebook
 }
 if REAGENTS IN #journal
 {
  display ok Not enough reagents to travel, an LRC suit is required for this script to work properly.
  halt
 }
 if TITHING IN #journal
 {
  display OK You have run out of tithing points, you'd better get some more.
  halt
 }
 if SOMETHING_IS_BLOCKING_THE_LOCATION IN #journal
 {
  set %3 %3 + 1
  if %3 > 16
  {
   set %3 1
   set %book %book + 1
   if %book > %number_of_sheep_runebooks
   {
    set %book 1
   }
   set %1 %sheep_runebook . %book
  }
  goto open_runebook
 }
}
if #charposx = %charposx && #charposy = %charposy
{
 goto recalling
}

return
;===============================================================
; Return Home
;===============================================================
sub to_house
GoSub use_runebook %HOUSE_RUNEBOOK_ID %method_of_travel 1
wait 2s
_pathfind:
event pathfind %start_x %start_y %start_z
wait 2s
if #charposx <> %start_x
 goto _pathfind
if #charposy <> %start_y
 goto _pathfind
if #charposz <> %start_z
 goto _pathfind
GoSub drop_off
GoSub to_sheep
return
;===============================================================
; Setup the Secure at house
;===============================================================
sub setup_secure

event sysmessage Now click on your secure container
wait 5
set #targcurs 1
target
while #targcurs = 1
      wait 0
set %secure #ltargetid
set %securex #cursorx
set %securey #cursory
GoSub check_weight
wait 2
return
;===============================================================
; Setup runebooks in pack
;===============================================================
sub setup_runebooks
;========================
; setting house runebook
;========================
 find_house_runebook:
finditem ZBN C_ , %packid
wait 1
if #findkind = -1
{
 event sysmessage auto find runebook failed, set runebook names as indicated in the Docs and restart.
 halt
}
event property #findid
wait 1
if HOUSE notin #property
{
 if HOME notin #property
 {
  ignoreitem #findid house_runebooks
  goto find_house_runebook
 }
}
set %house_runebook_id #findid
ignoreitem reset house_runebooks
;========================
; setting sheep runebooks
;========================
set %number_of_sheep_runebooks 0
 find_sheep_runebook:
finditem ZBN C_ , %packid
if #findkind = -1
{
 if %number_of_sheep_runebooks = 0
 {
  display OK Sheep runebook not found, make sure that the book has the word 'SHEEP' in the title.
  halt
 }
 ignoreitem reset sheep_runebooks
 return
}
event property #findid
if SHEEP notin #property
{
 ignoreitem #findid sheep_runebooks
 goto find_sheep_runebook
}
set %number_of_sheep_runebooks %number_of_sheep_runebooks + 1
set %sheep_runebook , %number_of_sheep_runebooks #findid
ignoreitem #findid sheep_runebooks
goto find_sheep_runebook
return
;===============================================================
; Main Setup
;===============================================================
sub setup

set #lpc 100
set %wool OFF_
set %start_x #charposx
set %start_y #charposy
set %start_z #charposz
set %sheeptypes FG_PF_
set %book 1
set %rune 1

set %runebooksize 452_236
set %runebookkind KJCB
set %runebook_test_colour_x 134
set %runebook_test_colour_y 31
set %runebook_test_colour 1052787

event macro 31 0 ; CLOSES ALL GUMPS

event macro 8 1
 wait_for_paperdoll_to_open:
if #contname <> paperdoll_gump
{
 goto wait_for_paperdoll_to_open
}
contpos 850 2 ;643 -193 (if normal screen size)
set %packx 781
set %packy 30
set %paperdoll #contid
set %paperdollx 750
set %paperdolly 64
wait 15

event macro 8 2
 wait_for_status_to_open:
if #contname <> status_gump
{
 goto wait_for_status_to_open
}
contpos 700 300 ;-24 493 (if normal screen size)
wait 15

event macro 8 7
 wait_for_pack_to_open:
if #contid <> #backpackid
{
 goto wait_for_pack_to_open
}
set %packid #contid
contpos 812 500 ; 612 118 (if normal screen size)
wait 15

return
;===============================================================
; End of Sheep Shearing, Killing, Rinse Repeating Script !!!!!!!
;===============================================================
;
;                             RAMSES
;
;===============================================================


looking for all the help I can get...

Thank you,

Ramses
« Last Edit: July 09, 2008, 03:43:29 PM by Ramses »

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #1 on: July 03, 2008, 04:08:29 PM »
0
TM,
I see that you have a runebook script. How can I add that to my script so that everything is functional?

I have tried to insert your script, however, I am obviously doing something wrong because I cannot get it to work.  :(

Thanks for the help.

Offline Hardyz

  • Jr. Member
  • **
  • Posts: 86
  • Activity:
    0%
  • Reputation Power: 0
  • Hardyz has no influence.
  • Respect: +14
  • Referrals: 0
    • View Profile
Re: Having issue with my runebook code.
« Reply #2 on: July 03, 2008, 05:36:50 PM »
0
did you put this in the initialization of your code?

Code: [Select]
gosub TM_AddUnderscore #CHARNAME
set %charname #RESULT

That's what TM's script says you have to put in somewhere.

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #3 on: July 03, 2008, 06:12:54 PM »
0
Yep, sure did.

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: Having issue with my runebook code.
« Reply #4 on: July 03, 2008, 06:22:05 PM »
0
Well, it looks like your runebook stuff has this format:

Code: [Select]
GoSub use_runebook %HOUSE_RUNEBOOK_ID %method_of_travel 1

It's a bit different than mine:

Code: [Select]
  gosub TM_TravelFromNamedRunebook !method !bank1 !bank2 !runebook

When I'm setting the !method from a Combo box, I run something like this:

Code: [Select]
  menu get EUOComboTravelMethod
  if #MENURES = 1
    set !method RE
  if #MENURES = 2
    set !method SJ
  if #MENURES = 3
    set !method GA
But you need the !method (arg 1) which can be RE, SJ or GA.  You need to set a range of runes (args 2 & 3)  in your rune book; in this example !bank1 & !bank2, and finally the runebook ID (arg4).  Other than that, be sure to include all the subs in the runebook script and it should work for you.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #5 on: July 03, 2008, 08:36:20 PM »
0
Hrm,
OK TM, it has been a long time since I have programmed like this so you lost me there.  :(


I have made some changes trying to get the loop for finding sheep work better and well, I broke it. LOL  :(
Nicar, thank you for the input....I plan on completing this dang thing so keep the info flowing...

thanks guys...night.

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: Having issue with my runebook code.
« Reply #6 on: July 03, 2008, 08:55:04 PM »
0
No worries, we'll go slow then.

What my last post was about is trying to tell you what you need in order to interface with my routines if that's what you were originally looking for.  So I was just explaining what the arguments for the "gosub TM_TravelFromNamedRunebook".  Really, there's 4 things you need:

1) method (RE, SJ, or GA)
2) starting runebook index (1-16)
3) ending runebook index (1-16)
4) runebook #FINDID

From your information, you have just aboue everything you need, your information has; for this example I'm going to assume you will be using Recalling.  So from what you said, a call to my routines using your information would be:

1) method = RE
2) starting index = 1
3) ending index = 1
4) runebook id = %HOUSE_RUNEBOOK_ID

So using my routines with your code, you'd call:

Code: [Select]
gosub TM_TravelFromNamedRunebook RE 1 1 %HOUSE_RUNEBOOK_ID

You can use a variable for the method, but since you have different values contained in your meaning of "%method_of_travel", then you'd have to change to what my routines expect which are RE, SJ, GA.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline Nicar

  • Full Member
  • ***
  • Posts: 198
  • Activity:
    0%
  • Reputation Power: 0
  • Nicar has no influence.
  • Respect: +20
  • Referrals: 0
    • View Profile
Re: Having issue with my runebook code.
« Reply #7 on: July 03, 2008, 10:06:25 PM »
0
Ok, I was going to look at some code, edit some and post, but too late, then I saw lots of things. Fist of all, with

Code: [Select]
for #findindex 1 #findcnt
you do not need to try to index #findindex, it increases with each pass, also, this is finding each sheep, you want to handle them one at a time. The line after for #findindex should include bracket, next line shoud set %sheepID #findid.

Code: [Select]
set %findindex %findindex - 1
 if %findindex > 0
    goto scan_loop

Also, I do not believe you want to do this. The purpose of the for findindex is to be your loop per sheep, if you're overweight, it should call to_house, and once returns, it should pick up where it left off.

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #8 on: July 04, 2008, 03:58:31 PM »
0
Ok...
I have updated the code. In trying to get this "for #findindex 1 #findcnt" to work I have broken it again. LOL

I changed the subs so that the majority of the subs are called from the "find_sheep" sub in hopes that the "FOR" will contain everything and loop. The loop is still not working, so I have not even tried to correct the runebook issues yet.
Right now, we can recall into a sheep pen, find and shear one sheep, kill it, and then we are stuck. I think my brain is going to explode.

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: Having issue with my runebook code.
« Reply #9 on: July 04, 2008, 04:10:36 PM »
0
Hi Ramses,

You had your braces out of wack again; there were 2 extra opening braces without closing braces, so that might lead to issues.  He're the fixed version:

Code: [Select]

;==============================================================
; Script Name: Sheep Shear, Kill and Repeat
; Author: Ramses
; Version: 1.0
; Client Tested with:
; EUO version tested with: 141
; Shard OSI / FS: OSI
; Revision Date:
; Public Release:
; Purpose: To gather wool for making cloth
;
;==============================================================
;
; Acknowledgements:
; Drak for testing
; Nicar for support and help
;
;==============================================================
;
; Script Notes:
; Rune Books must be labeled with the word Sheep, multiple books are ok.
; One Rune book must be labeled House or Home with your house as rune #1
;
;==============================================================
;==============================================================
;==============================================================
; Inits & Setup GoSubs
;==============================================================
finditem TSF c
if #findkind = -1
{
  display ok you do not have a dagger in your backpack, please get
  + one and then restart the script.
  halt
}
set %daggerID #findid

GoSub setup
GoSub setup_runebooks
GoSub setup_opperation

;===============================================================
; Begin Main Loop
;===============================================================
MAIN_LOOP:
GoSub to_sheep
GoSub find_sheep ;%sheeptypes G_16
if %overweight = YES
{
  GoSub to_house
}
goto main_loop

halt
;===============================================================
; End Main Loop
;===============================================================
;===============================================================
; Kill sheep
;===============================================================
Sub kill
  ;set #lobjectid %sheepID
  event macro 27 0
  wait 3
return
;===============================================================
; Check to ensure dead
;===============================================================
Sub check_death
SCAN:
  event macro 27 0
  finditem #ltargetid
  if #findkind = -1
  return
Goto scan
;===============================================================
; Find the Sheep
;===============================================================
sub find_sheep
  set %new_startposx #CHARPOSX
  set %new_startposy #CHARPOSY
  set %new_startposz #CHARPOSZ
  set %moveinitposy %new_startposy + 1
  event pathfind %new_startposx %moveinitposy %new_startposz
  finditem %sheeptypes G_16
  for #findindex 1 #findcnt
  {
    set %sheepID #findid
    set %x #charposx - 1
    set %y #charposy - 1
    set %x_limit #charposx + 16
    set %y_limit #charposy + 16
    While #finddist > 2
    {
      event pathfind #findx #findy #findz
      wait 1
    }
    GoSub check_weight
    GoSub shear_sheep
    GoSub kill
    GoSub check_death
  }
return
;===============================================================
; Shear Sheep
;===============================================================
sub shear_sheep
  wait 1
  set #lobjectid %daggerID
  event macro 17 0
  target
  wait 5
  set #ltargetid %sheepID
  ;set #ltargetkind 1
  event macro 22 0
return
;===============================================================
; Sub Setup_Opperation for method of travel
;===============================================================
sub setup_opperation
 
  ; DEFAULT VALUES
  set %method_of_travel RECALL
  set %use_invis NO
  set %use_hiding NO
  display YESNO Do you wish to use sacred journaey rather than recalling?
  if #dispres = YES
  {
    set %method_of_travel SACRED
  }
SETUP_OF_OPPERATION_COMPLETE:
  GoSub setup_secure
return
;===============================================================
; Check Weight
;===============================================================
sub check_weight
  if #weight > #maxweight - 30
    set %overweight YES
  if #weight > 390
    set %overweight YES
  if %overweight = YES
  {
    GoSub to_house
  }
return
;===============================================================
; Drop Wool
;===============================================================
sub drop_off
  finditem %wool C_ , %packid
  if #findkind <> -1
  {
    exevent drag #findid #findstack
    exevent dropc %secure
    wait 5s
  }
  set %overweight NO
return
;===============================================================
; To Sheep Pen
;===============================================================
sub to_sheep
  GoSub use_runebook %sheep_runebook . %book %method_of_travel %rune
  wait 1s
return
;===============================================================
; Movement with runebook
; Runebook subs came from Peragins LJ script (2005)
;===============================================================
sub use_runebook
 
  ;%1 - Runebook ID
  ;%2 - Method used on book - Use runebook charge / Recall / Sacred Journey or Gate
  ;%3 - Index number of rune to use
 
  ;Useage - gosub use_runebook RUNEBOOKID METHOD RUNE#
 
  ;===============================================================
  ; ERROR CHECKS
  ;===============================================================
  if %3 < 1 || %3 > 16
  {
    display OK Rune number outwith perameters.
    halt
  }
  finditem %1
  if #findkind = -1
  {
    display OK Specified Runebook not found, Check that the container is open.
    halt
  }
  set #lobjectid #findid
  set %methods RECALL_CHARGES_SACRED_JOURNEY_GATE_TRAVEL
  if %2 NOTIN %methods
  {
    display OK Method to travel not set correctly, please refer to documentation in the subroutine header.
    halt
  }
  set %charposx #charposx ; next 3 lines set current postion to check to see if you have recalled
  set %charposy #charposy
  set %charposz #charposz
  ;===============================================================
  ; Opening Runebook
  ;===============================================================
OPEN_RUNEBOOK:
  if #charposx <> %charposx || #charposy <> %charposy
  {
    return
  }
  set %error #scnt + 3
  event macro 17 0
  wait 5
OPENING_RUNEBOOK:
  if #contsize <> 452_236
  {
    if #scnt > %error
    {
      goto open_runebook
    }
    goto opening_runebook
  }
  set %test_X 137 + #contposx ;X co-ord of pixel to colour check for page turns
  set %test_Y 31 + #contposy ;Y co-ord for above
  ;===============================================================
  ; SET CO-ORDS OF TAB FOR PAGE TO TURN TO
  ;===============================================================
  set %index_tab %3 * 10 / 2 ;Rune # * 2 / 3 gives the runebook page index tab
  str len %index_tab
  if #strres = 1
  {
    set %index_tab 1
    goto index_tab_set
  }
  str right %index_tab 1
  if #strres = 5
  {
    set %index_tab %index_tab / 10
    set %index_tab %index_tab + 1
    goto index_tab_set
  }
  if #strres = 0
  {
    set %index_tab %index_tab / 10
    goto index_tab_set
  }
  display OK Error proccessing Index tab, please check passed rune number.
INDEX_TAB_SET:
  set %index_tab_offset 35 ;Pixels between page index tabs on the runebook GUMP
  set %index_tab_X %index_tab * %index_tab_offset ; Number of TAB offsets
  set %index_tab_offset 105 ;Pixels between GUMP edge and the first TAB
  set %index_tab_X %index_tab_X + %index_tab_offset ; Number of TAB offsets + distance from edge of GUMP
  if %index_tab > 4
  {
    set %index_tab_X %index_tab_X + 28   ;set for gap between page 1 and 2
  }
  set %index_tab_X %index_tab_X + #contposx ;Distance from edge of screen
 
  set %index_tab_Y 196 ;Y co-ord from TOP of GUMP
  set %index_tab_Y %index_tab_Y + #contposy ; Y co-ord from TOP of screen
  ;===============================================================
  ; Turn to page of Rune Book
  ;===============================================================
  if CHARGE NOTIN %2
  {
    click %index_tab_X %index_tab_Y f
    wait 10
    set %page 1
    ;===============================================================
    ; SET IF THE JEWEL TO CLICK IS ON THE LEFT OR RIGHT PAGE
    ;===============================================================
    set %jewel_offset_X 140 ; X CO-ORD OF JEWEL ON LEFT PAGE
    if %rune = 2 || %rune = 4 || %rune = 6 || %rune = 8 || %rune = 10 || %rune = 12 || %rune = 14 || %rune = 16
    {
      set %page 2
      set %jewel_offset_X 300 ; X CO-ORD OF JEWEL ON RIGHT PAGE
    }
    set %jewel_X %jewel_offset_X + #contposx
  }
  ;===============================================================
  ; SACRED JOURNEY
  ;===============================================================
  if SACRED IN %2
    set %jewel_offset_Y 181
  ;===============================================================
  ; GATE TRAVEL
  ;===============================================================
  if GATE IN %2
    set %jewel_offset_Y 161
  ;===============================================================
  ; RECALL
  ;===============================================================
  if RECALL IN %2
    set %jewel_offset_Y 141
 
  set %jewel_Y %jewel_offset_Y + #contposy ; Y CO-ORD OF JEWEL DEPENDING ON METHOD CHOSEN
  ;===============================================================
  ; RUNEBOOK CHARGES
  ;===============================================================
  if CHARGE IN %2
  {
    set %page 1
    set %jewel_offset_X 134
    set %jewel_offset_Y %jewel_offset_Y * %rune
    if %rune > 8
    {
      set %page 2
      set %jewel_offset_X 294
      set %jewel_number %rune - 8
      set %jewel_offset_Y %jewel_offset_Y * %jewel_number
    }
    set %jewel_X %jewel_offset_X + #contposx
    set %jewel_offset_Y 15
    set %jewel_Y 55 + #contposy
    set %jewel_Y %jewel_Y + %jewel_offset_Y
  }
 
  click %jewel_X %jewel_Y f ; THIS CLICK ACTIVATES THE RUNE
  set %jindex #jindex
  set %error #scnt + 10
RECALLING:
  if GATE IN %2
  {
    finditem OTF G_1
    if #findkind <> -1
    {
      return
    }
  }
  if #scnt > %error
  {
    goto open_runebook
  }
  for %line %jindex #jindex
  {
    scanjournal %line
    if FIZZLES IN #journal
    {
      goto open_runebook
    }
    if INSUFFICIENT IN #journal
    {
      goto open_runebook
    }
    if REAGENTS IN #journal
    {
      display ok Not enough reagents to travel, an LRC suit is required for this script to work properly.
      halt
    }
    if TITHING IN #journal
    {
      display OK You have run out of tithing points, you'd better get some more.
      halt
    }
    if SOMETHING_IS_BLOCKING_THE_LOCATION IN #journal
    {
      set %3 %3 + 1
      if %3 > 16
      {
        set %3 1
        set %book %book + 1
        if %book > %number_of_sheep_runebooks
        {
          set %book 1
        }
        set %1 %sheep_runebook . %book
      }
      goto open_runebook
    }
  }
  if #charposx = %charposx && #charposy = %charposy
  {
    goto recalling
  }
 
return
;===============================================================
; Return Home
;===============================================================
sub to_house
  GoSub use_runebook %HOUSE_RUNEBOOK_ID %method_of_travel 1
  wait 2s
_pathfind:
  event pathfind %start_x %start_y %start_z
  wait 2s
  if #charposx <> %start_x
    goto _pathfind
  if #charposy <> %start_y
    goto _pathfind
  if #charposz <> %start_z
    goto _pathfind
  GoSub drop_off
  GoSub to_sheep
return
;===============================================================
; Setup the Secure at house
;===============================================================
sub setup_secure
 
  event sysmessage Now click on your secure container
  wait 5
  set #targcurs 1
  target
  while #targcurs = 1
    wait 0
  set %secure #ltargetid
  set %securex #cursorx
  set %securey #cursory
  GoSub check_weight
  wait 2
return
;===============================================================
; Setup runebooks in pack
;===============================================================
sub setup_runebooks
  ;========================
  ; setting house runebook
  ;========================
find_house_runebook:
  finditem ZBN C_ , %packid
  wait 1
  if #findkind = -1
  {
    event sysmessage auto find runebook failed, set runebook names as indicated in the Docs and restart.
    halt
  }
  event property #findid
  wait 1
  if HOUSE notin #property
  {
    if HOME notin #property
    {
      ignoreitem #findid house_runebooks
      goto find_house_runebook
    }
  }
  set %house_runebook_id #findid
  ignoreitem reset house_runebooks
  ;========================
  ; setting sheep runebooks
  ;========================
  set %number_of_sheep_runebooks 0
find_sheep_runebook:
  finditem ZBN C_ , %packid
  if #findkind = -1
  {
    if %number_of_sheep_runebooks = 0
    {
      display OK Sheep runebook not found, make sure that the book has the word 'SHEEP' in the title.
      halt
    }
    ignoreitem reset sheep_runebooks
    return
  }
  event property #findid
  if SHEEP notin #property
  {
    ignoreitem #findid sheep_runebooks
    goto find_sheep_runebook
  }
  set %number_of_sheep_runebooks %number_of_sheep_runebooks + 1
  set %sheep_runebook , %number_of_sheep_runebooks #findid
  ignoreitem #findid sheep_runebooks
  goto find_sheep_runebook
return
;===============================================================
; Main Setup
;===============================================================
sub setup
 
  set #lpc 100
  set %wool OFF_
  set %start_x #charposx
  set %start_y #charposy
  set %start_z #charposz
  set %sheeptypes FG_PF_
  set %book 1
  set %rune 1
 
  set %runebooksize 452_236
  set %runebookkind KJCB
  set %runebook_test_colour_x 134
  set %runebook_test_colour_y 31
  set %runebook_test_colour 1052787
 
  event macro 31 0 ; CLOSES ALL GUMPS
 
  event macro 8 1
wait_for_paperdoll_to_open:
  if #contname <> paperdoll_gump
  {
    goto wait_for_paperdoll_to_open
  }
  contpos 850 2 ;643 -193 (if normal screen size)
  set %packx 781
  set %packy 30
  set %paperdoll #contid
  set %paperdollx 750
  set %paperdolly 64
  wait 15
 
  event macro 8 2
wait_for_status_to_open:
  if #contname <> status_gump
  {
    goto wait_for_status_to_open
  }
  contpos 700 300 ;-24 493 (if normal screen size)
  wait 15
 
  event macro 8 7
wait_for_pack_to_open:
  if #contid <> #backpackid
  {
    goto wait_for_pack_to_open
  }
  set %packid #contid
  contpos 812 500 ; 612 118 (if normal screen size)
  wait 15
 
return
;===============================================================
; End of Sheep Shearing, Killing, Rinse Repeating Script !!!!!!!
;===============================================================
;
;                             RAMSES
;
;===============================================================
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #10 on: July 04, 2008, 06:13:43 PM »
0
OHH, crap! Thanks TM...
Although, now I still need to look at my original one to see whre these brackets were at. Grrrr.

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #11 on: July 04, 2008, 06:16:43 PM »
0
Nope, still messed up...
I will keep working on it.  :)

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: Having issue with my runebook code.
« Reply #12 on: July 05, 2008, 05:11:21 PM »
0
One thing that might not be working for you is how you are using the #FINDCNT in your "for" loop:

Code: [Select]
  finditem %sheeptypes G_16
  for #findindex 1 #findcnt
  {
    set %sheepID #findid
    set %x #charposx - 1
    set %y #charposy - 1
    set %x_limit #charposx + 16
    set %y_limit #charposy + 16
    While #finddist > 2
    {
      event pathfind #findx #findy #findz
      wait 1
    }
    GoSub check_weight
    GoSub shear_sheep
    GoSub kill
    GoSub check_death
  }

When you do the finditem, the #FINDCNT is reporting zero, but since EasyUO doesn't know anything about what direction you will be counting for the FOR loop, it's assuming you want to count from 1 downto 0 ("for #findindex 1 #findcnt") instead of avoiding the loop all together.  So to fix this, you need to put a check to be sure #FINDCNT is greater than 0:

Code: [Select]
  finditem %sheeptypes G_16
  if #FINDCNT > 0
  {
    for #findindex 1 #findcnt
    {
      set %sheepID #findid
      set %x #charposx - 1
      set %y #charposy - 1
      set %x_limit #charposx + 16
      set %y_limit #charposy + 16
      While #finddist > 2
      {
        event pathfind #findx #findy #findz
        wait 1
      }
      GoSub check_weight
      GoSub shear_sheep
      GoSub kill
      GoSub check_death
    }
  }

Now it won't get stuck in that endless loop..

Your absolute best friend in situations like this is the PAUSE command.  When you are finding a bit of code that's not behaving the way you think it is supposed to, put a PAUSE in your code right before the code you are questioning starts to run.  From there, wait for the PAUSE to execute and then you can SINGLE-STEP through the code using the F8 key.  This will let you run each line individually and check variables to see that your code is executing correctly. 
« Last Edit: July 06, 2008, 02:30:46 AM by TrailMyx »
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #13 on: July 08, 2008, 03:52:59 AM »
0
TM,
Thanks for the heads up on this. I did not even think to use an "If #findcnt > 0" command. This just might be what I have been missing.!!!  Thank you.

I still have an issue with my runebook stuff. I have started over, and pulled your rune book subs, so I have some work to do when I get home from work today.  :)  But I plan on posting an update tonight (7/8/08).  :) 

Thanks again for the help!

Offline RamsesTopic starter

  • Jr. Member
  • **
  • Posts: 42
  • Activity:
    0%
  • Reputation Power: 0
  • Ramses has no influence.
  • Respect: +11
  • Referrals: 1
    • View Profile
Re: Having issue with my runebook code.
« Reply #14 on: July 09, 2008, 07:09:04 AM »
0
I was unable to post to the site last night. I will try again today when I get home from work.

Tags: