ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Cerveza on August 22, 2011, 06:13:20 AM

Title: Question: selecting the right finditem.
Post by: Cerveza on August 22, 2011, 06:13:20 AM
Whats a good way of looking through a bunch of items that have the same TYPE but are different colors?

I'm trying this but it always chooses the first one found:

Code: [Select]
finditem %thingy G_3
if #findCOl <> %1
  return
set #lobjectID #findID
event macro 17
wait 20
set #menubutton N/A
return

I guess I'll have to ignore any that aren't right... would something like this work?

Code: [Select]
sub find_use
finditem %thingy G_3
for %i 1 #findCnt
{
if #findCol <> %1
  ignoreitem #findID
}
event macro 17
wait 20
ignoreitem reset
return
Title: Re: Question: selecting the right finditem.
Post by: Crome969 on August 22, 2011, 06:33:33 AM
Try:

Code: [Select]
Sub FindUseful
set %Types %1
set %Color %2
Finditem %Type G_3
for #findindex 1 #findcnt
{
if %Color in #findid
{
;YourCode here
}
}
}
;More Code here
return

Hope its what u are Looking fore;)

Crome
Title: Re: Question: selecting the right finditem.
Post by: Cerveza on August 22, 2011, 06:38:05 AM
That's probably what I'll need to do. I was looking at it from a "find item THEN see if it's the right color" instead of your "find the right color in the items" example.
Title: Re: Question: selecting the right finditem.
Post by: Endless Night on August 22, 2011, 06:51:39 AM
Well do you only want to find ONE item with the right color are all items with the right color  (use above for multi-items .. add the break as below for single item)

Code: [Select]
Sub FindFirstITemByColor   ; Type Color
  Finditem %1 G_3
  if #findcnt > 0
     {
     for #findindex 1 #findcnt
        {
        if %2 in #findid
          {
          ;YourCode here
          break  ; exit loop
          }
        }
      }
;More Code here
return
Title: Re: Question: selecting the right finditem.
Post by: Cerveza on August 22, 2011, 07:01:34 AM
There will be multiple colored items available, but I have to use just ONE of the colors.

So lets say there are Red, White and Blue hammers on the ground. I *only* want to click the White hammer and not the Red or the Blue. They are all the same item TYPE and have the same PROPERTY, so can't use that. The only difference is the items color.
Title: Re: Question: selecting the right finditem.
Post by: Endless Night on August 22, 2011, 07:14:08 AM
2 methods for your consideration.. both should perform the same function

Code: [Select]
gosub find_use %thingy 5566_5567
gosub find_use %thingy 101

Code: [Select]
Sub find_use   ; 1=Type  2=Color
  Finditem %1 G_3
  set #findindex 1
  while #findindex <= #Findcnt
    {
    if %2 in #findid
      {
      event macro 17
      wait 20
      set #Findindex #findcnt + 20  ; exit loop
      }
    set #findindex #findindex + 1
    }
return
Code: [Select]
Sub find_use   ; 1=Type  2=Color
  Finditem %1 G_3
  if #findcnt > 0
     {
     for #findindex 1 #findcnt
        {
        if %2 in #findid
          {
          event macro 17
          wait 20
          break  ; exit loop
          }
        }
      }
return


Title: Re: Question: selecting the right finditem.
Post by: Cerveza on August 22, 2011, 07:21:15 AM
Cool, I'll play with that tonight *if* I get some time. Thanks!
Title: Re: Question: selecting the right finditem.
Post by: Crome969 on August 22, 2011, 07:47:51 AM
Or if you want to add more securehandler:

Code: [Select]
Sub GetItem
Finditem %1 G_3
if #findcnt > 0
{
for #findcnt 1 #findindex
{
if #fincol in %2
{
return #findid
}
}
}
return #false

Then u could do
Code: [Select]
GoSub GetItem %Type %Color
if #result <> #false
{
;Your Code here
}