ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Dude1598 on June 08, 2010, 05:36:19 AM

Title: Quick question
Post by: Dude1598 on June 08, 2010, 05:36:19 AM
I am trying to write my first script which is to use wool from a container, make yarn and then use yarn on loom to make cloth. The problem I am having is using the wool from the container. Also I have read the tutorials here and over at Easyuo and I cant find a way to use this item on this item.


Code: [Select]

This is the code so far for the yarn onto the loom

  findItem *** C_ , #backpackID
    if #findKind = -1
      halt
  set #lobjectID #findID
  set #ltargetKind 1
  event macro 17 0
  target 3
  event macro 22 0
  wait 20
return

Title: Re: Quick question
Post by: Masscre on June 08, 2010, 05:45:58 AM
I am assuming for this code snippet you have the Wool ID and with this you are trying to find the wool and then place it on thespinning wheel.  You will need the id of a spining wheel to actually place it on the spinning wheel this part you are missing from here.
Title: Re: Quick question
Post by: Dude1598 on June 08, 2010, 05:57:57 AM
FindItem *** C_ , #ContainerID

Will it be alright if I use this and have the container open with the wool in it ?
Title: Re: Quick question
Post by: 12TimesOver on June 08, 2010, 06:21:19 AM
FindItem *** C_ , #ContainerID

Will it be alright if I use this and have the container open with the wool in it ?
Yes, should be fine.

A couple pointers -

I would recommend "declaring" your variable values at the top of the script to make your life easier among other things. Also, you will need a loop to go through an entire stack of wool and yarn. Below is an example where I loop throught the wool then loop through the yarn. This is very basic with no error or syntax checked because I'm at work and am simply avoiding working ;) hopefully this at least gives you something to chew on.

Code: [Select]
 set %WoolTypes XXX_XX2_XX3 ;whatever the types are
  set %YarnTypes XXX_XX2_XX3 ;whatever the types are
  set %LoomTypes XXX_XX2_XX3 ;whatever the types are
  set %SpinningWheelTypes XXX_XX2_XX3 ;whatever the types are
  set %BoltTypes XXX_XX2_XX3 ;whatever the types are, you will likely want to move these back to the secure at some point in the script
  set %NoYarn #FALSE
  set %NoWool #FALSE

;MainLoop
Repeat
  gosub Wool2Yarn
  gosub Yarn2Bolt
Until %NoYarn = #TRUE && %NoWool = #TRUE

sub Wool2Yarn
  Repeat
    findItem %WoolTypes C_ , #backpackID
    if #findkind = -1
      set %NoWool #TRUE
    else
      {
      set #lobjectID #findID
      event macro 17 0
      findItem %SpinningWheelTypes G_4 ;first you have to find the Loom, change 4 to whatever you need for radius
      set #lobjectID #findID ;then prep the Last Target event by loading the Loom as last target
      set #ltargetKind 1
      event macro 22 0
      wait 20
      }
  Until %NoWool = #TRUE
return

sub Yarn2Bolt ;now do the same thing with your Yarn on Loom
  Repeat
    findItem %YarnTypes C_ , #backpackID
    if #findkind = -1
      set %NoYarn #TRUE
    else
      {
      set #lobjectID #findID
      event macro 17 0
      findItem %LoomTypes G_4
      set #lobjectID #findID
      set #ltargetKind 1
      event macro 22 0
      wait 20
      }
  Until %NoYarn = #TRUE
return

Like I said, I'm at work and typing quickly so hopefully I didn't miss anything there. Does that make sense?

X
Title: Re: Quick question
Post by: Dude1598 on June 08, 2010, 11:12:34 AM
Thanks, this makes sense to me I want to start out small and understand the basics before I tackle bigger things
Title: Re: Quick question
Post by: Dude1598 on June 09, 2010, 12:34:24 PM
Now when trying to use the loom it still has the spinning wheel as the last object. Can I use this to make sure it uses the loom ?
Code: [Select]
FindItem %LoomType
Title: Re: Quick question
Post by: NObama on June 09, 2010, 02:21:33 PM
Yes, absolutely.