ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: NObama on December 24, 2010, 02:02:46 PM

Title: Why the *bleep* isn't this working...
Post by: NObama on December 24, 2010, 02:02:46 PM
This makes me want to scream.  It was working, then it stopped.  Argh.

Code: [Select]
  display ok Now, target the container$ with unfilled deeds in your pack
  set #TARGCURS 1
  repeat
  until #TARGCURS = 0
  set %deedbag #LTARGETID
  finditem EWH C_ , %deedbag ; Deeds
  if #FINDKIND = -1
  {
    display ok No Commodity deeds.$Please get some.
    halt
  }

Keep getting -1 on #findkind...why? WHY!

And before you ask, YES there are deeds in there and YES the item type is EWH.
Title: Re: Why the *bleep* isn't this working...
Post by: _C2_ on December 24, 2010, 02:21:35 PM
if the container is not preopened... it will tell you no deeds becasue u never last object it t open it
Title: Re: Why the *bleep* isn't this working...
Post by: Dixie Wrecked on December 24, 2010, 02:25:25 PM
Tested code and it worked fine (looked fine, but never trust my own eyes!).  The only other thing that I can think of right now besides having an unopened container is not having EUO set to the right client, which is something I do all the time, especially when I have all 4 accounts scripting at once.
Title: Re: Why the *bleep* isn't this working...
Post by: NObama on December 24, 2010, 02:42:21 PM
if the container is not preopened... it will tell you no deeds becasue u never last object it t open it

Give the man a prize.  Thanks C2.
Title: Re: Why the *bleep* isn't this working...
Post by: Scrripty on December 24, 2010, 05:32:05 PM
It's also more proper to use if #findcnt > 0 instead of #findkind.
Title: Re: Why the *bleep* isn't this working...
Post by: NObama on December 24, 2010, 06:55:31 PM
It's also more proper to use if #findcnt > 0 instead of #findkind.

Okay.  Why?
Title: Re: Why the *bleep* isn't this working...
Post by: manwinc on December 24, 2010, 07:08:34 PM
Well think about it logically. 

Finditems in a container
Okay if the kind returns its not in a container then great. What?

Or better yet
If the number of that item in the container is 0

I never understoodwhat the point of findkind is.
Title: Re: Why the *bleep* isn't this working...
Post by: _C2_ on December 24, 2010, 07:09:15 PM
It is more of a preference between scripters.  I don't think that there is any particular reason that it is better.  I use them interchangably depending on if there is a remote chance that  I will find more than one.  in your case... there will never be more than one secure.  If you were looking for many items and started by using findkind... you next step might be if findcnt.  then findindex.  

You code is fine either way.  maddog uses findcnt religiously as does endless i believe.  tm uses findkind a lot.  both are stable especially in your case.  findcnt > 0 is basically the same thing as findkind <> -1 except that now you start with the count
Title: Re: Why the *bleep* isn't this working...
Post by: Scrripty on December 24, 2010, 07:59:25 PM
Cheffe - "#Findkind is not the preferred method to check whether an item was found or not because it is harder for humans to debug. Please use #FINDCNT instead, whenever possible." 
Title: Re: Why the *bleep* isn't this working...
Post by: Dixie Wrecked on December 24, 2010, 08:02:13 PM
Cheffe - "#Findkind is not the preferred method to check whether an item was found or not because it is harder for humans to debug. Please use #FINDCNT instead, whenever possible." 

Hmmmm...so if I can get some monkeys to do my coding for me, I can have them use #FINDKIND?  One more reason I need a monkey army!!!
Title: Re: Why the *bleep* isn't this working...
Post by: Masscre on December 24, 2010, 09:11:35 PM
Cheffe - "#Findkind is not the preferred method to check whether an item was found or not because it is harder for humans to debug. Please use #FINDCNT instead, whenever possible." 

Hmmmm...so if I can get some monkeys to do my coding for me, I can have them use #FINDKIND?  One more reason I need a monkey army!!!

This is prolly true since Monkeys use a different way of debugging !! So us humans better not use #FindKind !!

Title: Re: Why the *bleep* isn't this working...
Post by: manwinc on December 24, 2010, 09:21:18 PM
Army of Monkeys!!!!!!!!!!!!

ARMY OF HELL MONKEYS!!!!!!!!!!!BUAHAHAHAHAHAHAHAHAHAHAHAHAHAH

They are actually in the works!
Title: Re: Why the *bleep* isn't this working...
Post by: TrailMyx on December 24, 2010, 09:57:52 PM
Try to open the bag before you search.  As for findcnt vs. Findkind? Potato, potato. 6 or 1/2 dozen. Tomato, tomato.  Just because Cheffe says so, doesn't make it gospel. Use whatever works and whatever your comfortable using.

Edit:
Ah, I see you got the right suggestion below.  Darn phone surfin
Title: Re: Why the *bleep* isn't this working...
Post by: Scrripty on December 24, 2010, 10:27:41 PM
Try to open the bag before you search.  As for findcnt vs. Findkind? Potato, potato. 6 or 1/2 dozen. Tomato, tomato.  Just because Cheffe says so, doesn't make it gospel. Use whatever works and whatever your comfortable using.

Edit:
Ah, I see you got the right suggestion below.  Darn phone surfin

I'll choose to use things the way they're designed and at the developers request over a users suggestion every time. :)  It's much simpler to use #findcnt, easier for a noob to understand.  Use #findcnt.  It's the future.  It's less letters also.  So a tad faster overall.  I win. :)
Title: Re: Why the *bleep* isn't this working...
Post by: NObama on December 24, 2010, 11:19:46 PM
I switched to #findcnt halfway through the script, just to confuse everybody.

So there.

 :P

Script is done.  I will never commoditify anything by hand ever again.  I will, however, continue to invent new words as the whim takes me.  Post it as soon as TM grants me my own script section. 

(going to be a lonely script until I LEARN HOW TO DO ARRAYS)
Title: Re: Why the *bleep* isn't this working...
Post by: TrailMyx on December 25, 2010, 12:06:15 AM
... I win. :)

Says the lemming to the other lemming just before plummeting to the rocky surf below.  lol.

(going to be a lonely script until I LEARN HOW TO DO ARRAYS)

Would you hurry up and learn those things already...  hehehe

Good to use both the #findcnt and #findkind.  That'll really melt their butter!
Title: Re: Why the *bleep* isn't this working...
Post by: TrailMyx on December 25, 2010, 12:43:35 AM
Hey, NB.  Here's a little explanation I whipped up for someone we all know and adore here at SUO a while back that wasn't shared publically that explains arrays a bit.  Hopefully it'll give you a little context since I compare a classical programming language with how to do the same thing in EUO.

-----------------------------------------------------------------------------

OK, well if you'd like to think about arrays here's something to think about.

First of all, perhaps a little bit about what arrays are.

Classically, arrays are a method of storing information so that the information can be addressed by indexing it.  So for example (psudocode):

Code: [Select]
set Members[0] = "TrailMyx";
set Members[1] = "Cerveza";
set Members[2] = "Khameleon";
set Members[3] = "12X";

So after this, you could address all the members names by using an index within the array such as:

Code: [Select]
for (int i=0; i<=3; i++)
{
  print("The member name is ",Members[i]);
}

But sometimes it's nice to be able to hold specific information about each member, and still be able to index it.  Again classically, you might think about 2-dimensional arrays, or:

Code: [Select]
set Members[0][0] = "TrailMyx";
set Members[0][1] = "San Diego";
set Members[0][2] = "41";
set Members[1][0] = "Cerveza";
set Members[1][1] = "Back East";
set Members[1][2] = "Unk";

for (int i=0; i<=1; i++)
{
  print("Member ",Members[i][0]," lives in ",Members[i][1], " and is ", Members[i][2], " years old."
}

However, you see how numerical indicies are not very descriptive.  But this is the gist of arrays. You can have 1D, 2D, 3D, nD arrays.  It really just depends on how you want to store your information.

So when people talk about "arrays" in EUO, they automatically CAN'T talk about arrays in the classical sense because there is no language construct for it.  However, by using creative use of the concatenation, and even more creative use of namespaces, you can form a data structure that functions EXACTLY the same as an array.

From the first example (now in EUO)

Code: [Select]
set %Members_0 TrailMyx
set %Members_1 Cerveza
set %Members_2 Khameleon
set %Members_3 12X
for %i 0 3
{
  display The member name is , #SPC ,  %Members_ . %i
}
stop

And the second example in EUO is:

Code: [Select]
set %Members_0_0 TrailMyx
set %Members_0_1 San , #SPC , Diego
set %Members_0_2 41
set %Members_1_0 Cerveza
set %Members_1_1 Back , #SPC , East
set %Members_1_2 Unk
for %i 0 1
{
  set %member_index Members_ , %i , _
  set %name %member_index , 0 ; compute the variable name, I.E.  Members_0_0
  set %location %member_index , 1  ; compute the variable name, I.E.  Members_0_1
  set %age %member_index , 2 ; compute the variable name, I.E.  Members_0_2
  set %name % . %name ; now get the value at %Members_0_0
  set %location % . %location ; now get the value at %Members_0_1
  set %age % . %age ; now get the value at %Members_0_2
  display ok Member , #SPC , %name , #SPC , lives , #SPC , in , #SPC , %location , #SPC , and , #SPC , is , #SPC , %age
}

stop

If you'd like to see how to do this with namespaces and so that it makes more sense, lemme know.  I'll save the namespaces for another day.
Title: Re: Why the *bleep* isn't this working...
Post by: NObama on January 14, 2011, 08:58:59 PM
 :D  :D  :D  :D  :D  :D  :D

I get it.  AT LAST.

 8)
Title: Re: Why the *bleep* isn't this working...
Post by: dxrom on January 15, 2011, 12:10:54 PM
if the container is not preopened... it will tell you no deeds becasue u never last object it t open it

Give the man a prize.  Thanks C2.

xD
C2 beat me too it!

It's an annoying thing, but the bag needs to be open for the script to read anything in it, or maybe even RE-opened. I just know I get a bug when trying to chug pots sometimes where I  need to reopen my bag in order for razor to register that I have potions.
Title: Re: Why the *bleep* isn't this working...
Post by: dxrom on January 15, 2011, 12:19:46 PM
if the container is not preopened... it will tell you no deeds becasue u never last object it t open it

Give the man a prize.  Thanks C2.

xD
C2 beat me too it!

It's an annoying thing, but the bag needs to be open for the script to read anything in it, or maybe even RE-opened. I just know I get a bug when trying to chug pots sometimes where I  need to reopen my bag in order for razor to register that I have potions.

Actually this might be a VERY late reply >_>
Sorry just woke up xD

@TM: Arrays are so confusing, however I am in love with for loops, and how the can be used to step through arrays. :D
Title: Re: Why the *bleep* isn't this working...
Post by: Scrripty on January 15, 2011, 02:36:43 PM
If you guys would like to see a great easy example, look at my pseudo ignore script.  For loops and simple arrays made easy. :)