ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: seeriusly on August 08, 2009, 05:01:08 PM

Title: My first Script, looking to pick your brains.
Post by: seeriusly on August 08, 2009, 05:01:08 PM
  I am currently undergoing my first script ever.  Boy oh boy I don't know what I got myself into...  But I got the idea down and seems like it could be good.  I have been reading EVERYTHING I can that pertains to what I want to do in this script...  Been at it for over 30 hours almost straight... lol   I have used a few peoples subs, and need to get a few more subs in to finish it.  If there is anyone that wants to let me pick their brains, I promise I will figure most of it out, and I am not looking for a handout.  I'd like to msg through pm's if possible, so I can keep my lack of knowledge on the down-low for now. :-X HAHA  Credit will be acknowledged of course.  I am in it for the challenge, and I am pretty smart.  Give me a hollar if you want to help me out, thanks.

Title: Re: My first Script, looking to pick your brains.
Post by: Superslayer on August 08, 2009, 08:12:52 PM
You can certainly PM me for anything. Namespace is a topic I'm only slightly comfortable with, but most anything else is good with me.
Title: Re: My first Script, looking to pick your brains.
Post by: DeadIssue2 on August 08, 2009, 09:05:46 PM
Let us know what you are working on and maybe what your stuck on and we can see what we can do to help.
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 15, 2009, 07:06:11 PM
Thankyou guys.  Well for the moment, basically it's a fishing script...  I know, I know... lame, but wait until it's finished before you knock it eh. :)  I will provide more info once I can get the hang of this part of the script.  Right now I need to figure out how I loop a section of it. 

Which means I need a couple things...

I got it to recall off of a certain rune in the book.  (I will have 16 locations to do this from)  What I want to do is have it fish until "the fish don't seem to be biting here".  To do that I will need to use a journal scan, and I have found a couple subs from other people, but don't know how to implement it.

I will then need to let it go to each rune and fish until I am nearly overweight. There again, I seen many subs, and snips of scripts, but am stuck on where and how to put it in play.

Here's some code I am working with:

Code: [Select]
mainloop:
gosub clickRunebookLocation FMALJRD 1 M #TRUE  ;gosub clickRunebookLocation [BookID] [RuneNumber] [RecallMethod] [FailOverride #TRUE/#FALSE]

;find fishing pole
FindItem XHF 1

gosub fish

....

sub fish
set #LObjectID #FindID
set #LTargetKind 2
set #LTargetX -1 + #CharPosX
set #LTargetY 4 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 9s ;maybe 8s ???

;;Fishing Target 2
set #LTargetX -3 + #CharPosX
set #LTargetY 4 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 9s

;;Fishing Target 3
set #LTargetX -4 + #CharPosX
set #LTargetY 2 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 9s
return


gosub clickRunebookLocation FMALJRD 2 M #TRUE
 

So I need it to loop that sub, keeping track of weight, and checking for journal to see when they aren't biting anymore.  Then go to the next rune.
Any hints?
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 15, 2009, 07:18:44 PM
Code: [Select]
set %MyRunebook FMALJRD

Repeat
  For %Runeon 1 16
     {
      gosub clickRunebookLocation %MyRunebook %Runeon M #TRUE
      FindItem XHF     ; This seems lacking in details where is the rod at your hand backpack floor ?
      gosub Fish  
     }
Until <PLace some condition here
Halt

Put repeat fishing of the same spot (loop) + journal checking and wieght checking inside fish sub
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 15, 2009, 08:07:01 PM
Thankyou so much!!  Well, it arms fishing pole when it's clicked.  I am guessing it clicks it when FINDITEM is used?  It would work just like you wrote I'd imagine, if it did the way I had it?

and like this?

Until (this where i'd put until weight, or until they arent biting?)
Halt

gosub getRIDofFISH
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 15, 2009, 09:03:10 PM
nope.  It does not click the pole when finditem is used.
If clicks the pole when you do event macro 17 0
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 15, 2009, 09:24:09 PM
oh, allright.  event 17 0 is in the fish sub so must be how it's working.

I got the journal script called so it loops the fish sub when it finds "you_pull_out".  Was so stoked when it actually worked! woohoo!!

Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 15, 2009, 09:40:17 PM
Good job man. :)  This is a scripting BOARD, so don't be afraid to ask for help... Everyone started somewhere.  My advice is to look at someone else's fishing script.  You'll gain a lot of insight by doing that.
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 15, 2009, 09:51:09 PM
 :) thanks.... I have been looking at AT LEAST 20 different scripts to accomplish the script I want to finish.  I think I have got a good start with the help from a few people here.
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 16, 2009, 06:31:37 AM
good stuff glad i could help in some way if you get stuck again post in this same thread again :)
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 16, 2009, 07:48:28 AM
Thanks, but I am going to plug EVERYTHING I can figure out into it, then I will see what's left to correct.  Appreciate your help.  I have learned ALOT already.
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 16, 2009, 12:29:47 PM
okay, minor bump in the road...  Spent 3 hours trying to figure this layout, and it's come down this...

I got it to go through all locations of my runebook and fish this sub.  checking journal successfully moving when they arent' biting.  I have placed the if #weight > 300 in every possible place, and cant figure it out.  I need to be able move to next sub in the mainloop when weight > 300

Code: [Select]
;==============FISH SUB============
sub fish
baithook:
set #LObjectID #FindID
set #LTargetKind 2
set #LTargetX -1 + #CharPosX
set #LTargetY 3 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 8s




journal1:
call ScanForJournalMsg.txt you_pull_out 1 20
     if #result = #true
{
goto baithook
}
else
{
goto journal2
}

journal2:
call ScanForJournalMsg.txt biting_here 1 20
     if #result = #true

return
Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 16, 2009, 12:59:20 PM
okay, minor bump in the road...  Spent 3 hours trying to figure this layout, and it's come down this...

I got it to go through all locations of my runebook and fish this sub.  checking journal successfully moving when they arent' biting.  I have placed the if #weight > 300 in every possible place, and cant figure it out.  I need to be able move to next sub in the mainloop when weight > 300

Code: [Select]
;==============FISH SUB============
sub fish
GOSUB CHECKWEIGHT
baithook:
set #LObjectID #FindID
set #LTargetKind 2
set #LTargetX -1 + #CharPosX
set #LTargetY 3 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 8s

journal1:
call ScanForJournalMsg.txt you_pull_out 1 20
     if #result = #true
{
GOSUB CHECKWEIGHT
goto baithook
}
else
{
GOSUB CHECKEIGHT
goto journal2
}

journal2:
call ScanForJournalMsg.txt biting_here 1 20
     if #result = #true

return
;==================WEIGHT CHECK====================
SUB CHECKWEIGHT

if #weight >= 300
  {DO WHAT YOU NEED TO HERE, GOSUB TO DROP LOOT MAYBE?}
return

Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 16, 2009, 01:05:10 PM
Hmmm...  Thankyou, but that didn't seem to work.


I am pretty sure I resolved my weight code problem.  Thanks
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 16, 2009, 02:04:45 PM

Code: [Select]
set %MyRunebook FMALJRD
FindItem XHF     ; This seems lacking in details where is the rod at your hand backpack floor ?
set %FishingPole #Findid

Repeat
  For %Runeon 1 16
     {
      gosub clickRunebookLocation %MyRunebook %Runeon M #TRUE
      gosub Fish   
      IF #Weight > 300
           gosub SecureDropoff
     }
Until #False   ; Set a script ending condition here..
Halt

;==============FISH SUB============
sub fish
  Repeat
     set #LObjectID %FishingPole
     set #LTargetKind 2
     set #LTargetX -1 + #CharPosX
     set #LTargetY 3 + #CharPosY
     event macro 17 0
     target
     event macro 22 0
     wait 8s
     call ScanForJournalMsg.txt you_pull_out 1 20
     set !Exit #Result
     call ScanForJournalMsg.txt biting_here 1 20
     set !Exit #Result || !Exit
  Until  #weight >= 300  || ( ! !Exit)
Return

Sub SecureDropoff
   ; Do your secure drop off code here or what ever you do when 2 heavy
Return
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 16, 2009, 02:13:35 PM
I snatched this tidbit from someones script.  It works & looks like this... 
Code: [Select]
sub fish
gosub checkweight
baithook:
set #LObjectID #FindID
set #LTargetKind 2
set #LTargetX -1 + #CharPosX
set #LTargetY 3 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 8s


journal1:
call ScanForJournalMsg.txt you_pull_out 1 20
     if #result = #true
{
gosub checkweight
goto baithook
}
else
{
gosub checkweight
goto journal2
}

journal2:
call ScanForJournalMsg.txt biting_here 1 20
     if #result = #true

return



;===============CHECK WEIGHT============
sub checkweight
  if #weight > #maxweight - 30
    set %overweight YES
  if #weight > 390
    set %overweight YES
  if %overweight = YES
  {
        GoSub gobank
        GoSub dumptrash
  }
return

@Endless:
Yours looks a lot cleaner :)  Just wish I understood the different symbols LOL...  Will that make it faster? or just neater
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 16, 2009, 02:42:45 PM
Your posted bit has a serious flaw

Code: [Select]
journal2:
call ScanForJournalMsg.txt biting_here 1 20
     if #result = #true

return


So what about if the Result is false... what does the script do .. i suspect it goes to end of the script then line 1 and starts over.


What symbols in my version are you stuck on ?
Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 16, 2009, 03:14:23 PM
Oh so now you understand what I was getting at because this is nearly EXACTLY what I put. :) Also, I wouldn't have written this like you did.  I was just using what you did and trying to keep it as simple as I could so you would see a way to do it.  I do things VERY simply at first, then I make them better and better as I "see" a better way. :)  If that makes sense.  EN:  I think he is wondering about this:  
Code: [Select]
    set !Exit #Result
     call ScanForJournalMsg.txt biting_here 1 20
     set !Exit #Result || !Exit
  Until  #weight >= 300  || ( ! !Exit)
Return

Basically the ! symbol just means the OPOSITE of whatever the result is.  So if the #result is true, and you typed ( ! !exit) that would mean, if #FALSE !exit... basically.  So if you ScanForJournal and the message "biting_here" appears in the string the result would be #true I'm guessing? :)  The two || symbols just mean "OR"  so until #weight >= 300 OR ( ! !Exit )

I snatched this tidbit from someones script.  It works & looks like this...  
Code: [Select]
sub fish
gosub checkweight
baithook:
set #LObjectID #FindID
set #LTargetKind 2
set #LTargetX -1 + #CharPosX
set #LTargetY 3 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 8s


journal1:
call ScanForJournalMsg.txt you_pull_out 1 20
     if #result = #true
{
gosub checkweight
goto baithook
}
else
{
gosub checkweight
goto journal2
}

journal2:
call ScanForJournalMsg.txt biting_here 1 20
     if #result = #true

return



;===============CHECK WEIGHT============
sub checkweight
   if #weight > #maxweight - 30
     set %overweight YES
   if #weight > 390
     set %overweight YES
   if %overweight = YES
   {
        GoSub gobank
        GoSub dumptrash
   }
return

@Endless:
Yours looks a lot cleaner :)  Just wish I understood the different symbols LOL...  Will that make it faster? or just neater

I probly would write this in a very logical way.  Just a stupid simple example of how I'd order the subs.  If you loop that and have the subs all squared away with what each does... that would work fine I'm guessing.  It would setup a secure, recall to each rune, drop garbage, and drop loot in bank.  What else do you need? :)

like this:

gosub checkbankorsecure
gosub checkforpole
gosub doallskillchecks
gosub setup
loop:
gosub recalltofirstrunethennextruneforeachbook
gosub fish
gosub killserpsiffound
gosub loot
gosub checkweight
gosub droplootandgarbage
goto loop
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 16, 2009, 04:24:26 PM
Twinkle McNugget, Endless... you are very kind to take the time, as is everyone else. 
Bear with me, I am learning and have learned a lot. :)


Well, there is a lot more to this script than this.  The fishing part is just the beginning.  I had it working, seriously working perfect, then I merged my 3 or 4 pages of garbled code, and now it doesnt work again, and I've been working on it all day and week for that matter.  I would like to share the full script, but I want to figure out as much as possible first, and just let you guys know when I am stuck.  That will give me a clearer train of thought so I don't get TOO many things and codes going at once.

Ummm... I am stuck, but I think I need to take a break and come back refreshed.

I will probably learn later that there is already a script that does what I am wanting to do... LOL... not funny.

But what I want it to do... FOR NOW...  is:

setup:
  bank
  bank secure
  trash
  runebook to bank
  and more...
-----------------
setup is probably 99% complete.
----------------- 
  fishing location runebook (all spots are from shore)
gosub fish
  rune1-16 until fish not biting
  journal to tell when not biting
  weight check
go bank when heavy
  dump trash (footwear, mess of fish)

----------------
I had it working until here, with the help from you guys...
----------------
  dump pearls in secure  (pretty sure this will be easy)
go to the next part of the script. 3 or 4 more subs (pretty sure this will be a nightmare)
go continue fishing where I left off
rinse repeat.


I wont be dumping fish into bank secure or any secure for that matter.

My final thought is, my mind is pooped.  You guys have given me a great start, and I just need to put in a little more until this part is done.

But I think for tonight, I am done. I need a break.

Thanks again guys
I'll post any progress, if I can muster some up. :)
Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 16, 2009, 04:47:35 PM
I guess this is a bad time to tell you that TrailMyx is an avid fisher and has a GREAT fishing script that does all that.  But no need to recall as it does it on a boat... :)  Recalls to bank, drops loot, recalls back, drops all the junk on the serpents body so you have portable garbage cans basically. :)  It's very nice.  I would continue with what you are doing though because it will make your life way easier in the long run.  You'll be able to adapt anything to your purpose which is a very usefull skill to have when running scripts. :)

Twinkle McNugget, Endless... you are very kind to take the time, as is everyone else. 
Bear with me, I am learning and have learned a lot. :)


Well, there is a lot more to this script than this.  The fishing part is just the beginning.  I had it working, seriously working perfect, then I merged my 3 or 4 pages of garbled code, and now it doesnt work again, and I've been working on it all day and week for that matter.  I would like to share the full script, but I want to figure out as much as possible first, and just let you guys know when I am stuck.  That will give me a clearer train of thought so I don't get TOO many things and codes going at once.

Ummm... I am stuck, but I think I need to take a break and come back refreshed.

I will probably learn later that there is already a script that does what I am wanting to do... LOL... not funny.

But what I want it to do... FOR NOW...  is:

setup:
  bank
  bank secure
  trash
  runebook to bank
  and more...
-----------------
setup is probably 99% complete.
----------------- 
  fishing location runebook (all spots are from shore)
gosub fish
  rune1-16 until fish not biting
  journal to tell when not biting
  weight check
go bank when heavy
  dump trash (footwear, mess of fish)

----------------
I had it working until here, with the help from you guys...
----------------
  dump pearls in secure  (pretty sure this will be easy)
go to the next part of the script. 3 or 4 more subs (pretty sure this will be a nightmare)
go continue fishing where I left off
rinse repeat.


I wont be dumping fish into bank secure or any secure for that matter.

My final thought is, my mind is pooped.  You guys have given me a great start, and I just need to put in a little more until this part is done.

But I think for tonight, I am done. I need a break.

Thanks again guys
I'll post any progress, if I can muster some up. :)
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 16, 2009, 06:59:25 PM
I second what script said.. even though thier probably are scripts out thier that do everything you want .. thiers nothing quiet like the empowerment that comes from creating your own.
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 16, 2009, 07:20:41 PM
word....   I couldn't agree more.

So I lied my previous post said I needed a break...  pfft!!!  I couldn't take a break, and reverted the script to do a few things the way i chickenscratched it out.  It works, even though it doesn't look as professional as you guys would do it.  Nor does it take those extra steps to keep it stable.  You guys will have to help me iron out those parts.  I have one more sub until it does EVERYTHING I want it to.  Just about 1000 Lines!!!  MUHAHAHA  And I thought this would be the nightmare part!! 

Well I shouldn't speak so soon.   :-X
Title: Re: My first Script, looking to pick your brains.
Post by: TrailMyx on August 16, 2009, 07:28:50 PM
Looks like seeriusly has been bitten by the scripting bug.  heh.  Nice!
Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 16, 2009, 07:37:33 PM
From my limited experience man, adding logic to a script is an ongoing and frustrating thing. :)  Just when you think you have EVERY single thing that could possibly happen covered... you find 10 more.  Or some noob uses it some way you never thought of and comes up with 10 more features you HAVE to add. haha  Gah.  I think I read TM saying somewhere that actual script writing is like 20 percent of the time, the other 80 is debugging. :)  So true.  I've spent HOURS hunting down a freaking bracket out of place.  ONE, LITTLE, BRACKET.   >:(  ONE THING TO ALWAYS REMEMBER:  ALWAYS WORK ON A BACKUP OF YOUR MOST RECENT AND WORKING VERSION.  If you add something and it WORKS, SAVE IT AND WORK ON A BACKUP OF THAT ALSO. haha  When you first start scripting you forget and work on the main script and do too much, then screw it all up and can't get it back to what it was. haha  I've done it a few times... I know...  Trust me...  :)


Also, I think EN was trying to get you to look at Journal2:.  You have an if statement that does nothing but return... :)  I'll post my edit and see if it works for you.  I'm assuming that any other result other than biting_here means you want to fish again?  I'm not a big fisher... I have no idea... I think that would do the trick wouldn't it?  Now any other result besides biting_here takes you right back to baithook: until you get biting_here in #result which will return you out of the fish sub, and everything else will keep you fishing.   

Code: [Select]
sub fish
gosub checkweight
baithook:
set #LObjectID #FindID
set #LTargetKind 2
set #LTargetX -1 + #CharPosX
set #LTargetY 3 + #CharPosY
event macro 17 0
target
event macro 22 0
wait 8s

journal1:
call ScanForJournalMsg.txt you_pull_out 1 20
     if #result = #true
{
gosub checkweight
goto baithook
}
else
{
gosub checkweight
goto journal2
}

journal2:
call ScanForJournalMsg.txt biting_here 1 20
     if #result = #true
        return
goto baithook

;===============CHECK WEIGHT============
sub checkweight
  if #weight > #maxweight - 30
    set %overweight YES
  if #weight > 390
    set %overweight YES
  if %overweight = YES
  {
        GoSub gobank
        GoSub dumptrash
  }
return
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 17, 2009, 04:33:27 PM
ok, so I only want it to do 2 things. 

When it fishes, it says "you pull out fish, pearl, boots, etc..."  So i want it to run that over and over until fish aren't biting.

if it ever says "fish aren't biting here"  that's when I will move to next rune.  I am fishing from shore, so it will never say anything else. like sea serpents kraken or chest...  I dont think.

what this did make me think about though, is if an NPC or smoething came into screen at that precise moment when it checks journal...  I guess it would keep fishing? and loop back down to not biting anyhow.  Right???



OOOOoooo.....  I think I know what you mean now.

 I thought that the if statement after journal2 would do this.

check journal for "biting here"

if true, then would return me to mainloop.

which is this:
Code: [Select]
mainloop:

Repeat
  For %Runeon 9 13
     {
      gosub clickRunebookLocation %MyRunebook %Runeon M #TRUE
      FindItem kdf_vmf_xhf     ; This seems lacking in details where is the rod at your hand backpack floor ?
      gosub Fish
     }
Until #False ; Set a script ending condition here..

Halt

Goes to next rune and continues fishing.

It DOES work how I had it above.  And I will investigate adding that line to see what it does.


BTW Twinkle McNugget...  I don't use brackets anywhere, except places where I copied snips from other scripts.  What are their purpose?
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 17, 2009, 04:44:18 PM
And I have yet to figure out what Endless is saying  about the 2 "commented-out" pieces of that mainloop section.

"this seems lacking..."   It always uses the fishing rod when I press play.

"script ending condition here" I don't know what that means.  I have looked all over and have found nothing about the "Until" command or whatever it is.


I have one more tidbit to complete with this script, one or 2 that will require some MASSIVE process of elimination, then I will post the full thing.  Its a mess... lol  But it's wierd that it works because I know it isn't written right.
Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 17, 2009, 05:01:19 PM
Brackets just enclose if statements that are larger than one line.  

Code: [Select]
if !seeriously = #bittenbyscriptbug
    set !seeriously = #kookoo
return

In this instance you don't need brackets.  The above example would check if seeriously is bitten by script bug, and if he WAS it would set his variable to #kookoo.  If it's FALSE it would just skip the set part and execute the return.  But if you made it longer...:

Code: [Select]
if !seeriously = #bittenbyscriptbug
{
    if !seeriously = #needsmentalhelp
    {  
        set !he'slooney
        yada yada yada
        yada yada yada
    }
}
return

So with more than one line needing to be included in the if statement you'd need to enclose it in brackets...  I'm sure there's other rules but I only really know of this one...  Unless you're doing some form of a math problem and you're using () there's rules for those too...

I like to use this as a horrible example of using if's:  It made my brain hurt when I first did it, but it's a great way to learn how to use brackets and helped me to learn how they work really well. :)  Basically it checks if the Use Lightning Strike menu button is checked, if it IS it checks if the MANA CHECK menu item is checked, if it's NOT, it defaults to just using ls, and if it IS it defaults to only using ls when your mana is above a certain point AND it checks to see which dropdown menu item is active on a 3 item list... haha  it looks so funny...  There's probly a WAY better way to do this, but when I first did it, I just wrote it in the only way I knew how... :)

Code: [Select]
 sub ls
    menu get 13 ;Lightning Strike;Primary:Secondary
    if #menures = #true
    {
      menu get 14 ; WS Mana Check
      if #menures = #true
      {
        menu get specials
        if #menures = 1
        {
          if #mana > ( #maxmana * !LSManaPercentage ) / 10
          {
            gosub lsSpecial
          }
          return
        }
        menu get specials
        if #menures = 2
        {
          if #mana > ( #maxmana * !LSManaPercentage ) / 10 && #mana >= !PrimaryMana
          {
            gosub execPrimary
          }
          return
        }
        menu get specials
        if #menures = 3
        {
          if #mana > ( #maxmana * !LSManaPercentage ) / 10 && #mana >= !SecondaryMana
          {
            gosub execSecondary
          }
        }
        return
      }
      menu get specials
      if #menures = 1
      {
        gosub lsSpecial
        return
      }
      menu get specials
      if #menures = 2
      {
        if #mana >= !PrimaryMana
        {
          gosub execPrimary
        }
        return
      }
      menu get specials
      if #menures = 3
      {
        if #mana >= !SecondaryMana
        {
            gosub execSecondary
        }
      }
     }
    }
  return

And I have yet to figure out what Endless is saying  about the 2 "commented-out" pieces of that mainloop section.

"this seems lacking..."   It always uses the fishing rod when I press play.

"script ending condition here" I don't know what that means.  I have looked all over and have found nothing about the "Until" command or whatever it is.


I have one more tidbit to complete with this script, one or 2 that will require some MASSIVE process of elimination, then I will post the full thing.  Its a mess... lol  But it's wierd that it works because I know it isn't written right.
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 17, 2009, 05:40:44 PM
Lookup "Repeat"  .. it will explain "Until"   (
Repeat
   <this code>
   <and this code>
   <and more code>
Until < Condition -- if condition is #true goto next line otherwise go back to the line rigth after the Repeat statment>

~~~~~~~~~~~~~~~~~~~`

FindItem kdf_vmf_xhf     ; This seems lacking in details where is the rod at your hand backpack floor ?

The pole just happens to be in your backpack so this is working... but say i run past you guy and drop a pole on the floor the script will find it and try to use that one ???

Better to do more specific
 FindItem kdf_vmf_xhf   C_ , #Backpackid ; Look for pole in a container (C_ ) in this case your backpack (#Backpackid)
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 17, 2009, 06:21:54 PM
holy crap! that's a lot of brackets...  *trys to follow them*    You called ME Looney?!?!?!  hahaha  :-\
I think I got the jist of it.  Thankyou for that.  Need to start a thread with JUST variables and commands etc..  Like a thread named "IF" statement.  And one called "use of brackets"...  Might be resourceful for noobs like me ^^

And one called "Return / Until".  I know, I know...  Us noobs gotta do our research if we want the fruits of scripting.

I gotcha now Endless, on both instances you covered.  Thankyou!  I'd keep giving you karma, but you both would have more than TM by now just on this thread... LOL   Thanks for putting up with me though.

So... from what I gather.  my mainloop:
Code: [Select]
mainloop:

Repeat
  For %Runeon 9 13
     {
      gosub clickRunebookLocation %MyRunebook %Runeon M #TRUE
      FindItem kdf_vmf_xhf     ; This seems lacking in details where is the rod at your hand backpack floor ?
      gosub Fish
     }
Until #False

If I set this to Until #true,  the return at the bottom of my sub fish would take me to whatever code that is on the next line after Until #true??
Title: Re: My first Script, looking to pick your brains.
Post by: TrailMyx on August 17, 2009, 06:32:39 PM
That's ok.  I can make my karma whatever I want.  :) 
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 17, 2009, 06:55:18 PM
LOL...  I know. :)
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 17, 2009, 08:18:24 PM
repeat
  blabla code
until #True

Would mean that you dont need the repeat as it would only ever ever ever run once so is the same as

blabla code

~~~~~~~~~

What you should do is something like this

Code: [Select]
Set %ExitScript NO
Repeat
    ; Scan the journal for a exit keyword
    ; such as   "bigJobs"
    ; If you find bigjobs in the journal set %exitScript YES
    ; ..
    ; All the code Between the repeat and until .. will keep looping until %exitscript = YES
Until %ExitScript = YES
Halt ; The script is over stop running.
Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 17, 2009, 10:35:48 PM
Or for the total noob.
Code: [Select]
start:

script

if #conditiontoexit = #true
   goto end

goto start

end:
halt

That will loop over and over also. :)  Just sayin... :)
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 18, 2009, 07:17:11 AM
yes script you could do that but personally i find that harder to read, and debug especially once your scripts start getting larger and larger.  If you can manage the logic of a repeat until loop you will be better off in the long run.  I have scripts 10k lines long without a single GOTO statment.

In fact   Until <Condition>   is basically codewise equialent of
   If NOT <condition>   goto <tag>    And Repeat is eqvialent to <Tag>

Its hard to do something like this with ifs.. and gotos..  , hard to read hard to debug

Code: [Select]
Repeat
   bla bla
   Repeat
      blba bla bal
      Repeat
          bla bla bla
      Until !ExitScript || InnerLoopCondition
   Until !ExitScript  || OtherCondition
Until !ExitScript
Halt


All that said you make your own bed and u lie in it. LOL take it from me thow trashing the gotos will save you tons of headaches.

Title: Re: My first Script, looking to pick your brains.
Post by: Scrripty on August 18, 2009, 11:37:56 AM
All that said you make your own bed and u lie in it. LOL take it from me thow trashing the gotos will save you tons of headaches.

I never use gotos.  But when you're new, they are easy to understand. :)
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 18, 2009, 04:07:11 PM
I havent been new to coding in sooooo long i've kinda forgotten what the umm initial viewpoint is  :o
Title: Re: My first Script, looking to pick your brains.
Post by: seeriusly on August 18, 2009, 06:21:29 PM
*rummages through script*  mmm... I got a bunch of goto statements...  :-[ I guess cause they are easy like you said.
Title: Re: My first Script, looking to pick your brains.
Post by: TrailMyx on August 18, 2009, 06:26:37 PM
*rummages through script*  mmm... I got a bunch of goto statements...  :-[ I guess cause they are easy like you said.

Don't worry about them too much.  If it works for you, then just use'em.  :)  I still do if they make sense for the task at hand.
Title: Re: My first Script, looking to pick your brains.
Post by: Endless Night on August 18, 2009, 07:35:20 PM
dont worry about it seeriusly  .. just keep that script moving forward what ever way you can.