Talk:Use familiar

From Kolmafia
Jump to navigation Jump to search

This always seems to return false for me, can anyone confirm?
--Slyz 20:56, 9 April 2010 (UTC)


> ash use_familiar($familiar[sandworm])
Putting Mexicana the Hovering Sombrero back into terrarium...
Taking Hecho en Mexico the Baby Sandworm out of terrarium...
Returned: true

I assume that the ash command should be enough to check return value; correct me if I'm wrong. --Heeheehee 21:03, 9 April 2010 (UTC)

I'll have to recheck after RO, but here is what I was getting (doing things slightly differently):

> ash print( use_familiar($familiar[slimeling]) )
Putting Dusty the Baby Sandworm back into terrarium...
Taking Yuk the Slimeling out of terrarium...
false
Returned: void

--Slyz 03:33, 10 April 2010 (UTC)


Huh. Using that method, I get:

> ash print( use_familiar($familiar[sombrero]) )
Putting Hecho en Mexico the Baby Sandworm back into terrarium...
Taking Mexicana the Hovering Sombrero out of terrarium...
true
Returned: void

--Heeheehee 07:51, 10 April 2010 (UTC)

I'm also seeing expected behavior; true most of the time, false if I try a familiar I don't have. --StDoodle (#1059825) 14:52, 10 April 2010 (UTC)


I find the syntax as described on this page confusing. With other functions I do not have to specify the datatype, for example:
outfit($string[Backup]);
outfit("Backup");
both work identically. However, use_familiar("hobo");
returns the error "Function 'use_familiar( string )' undefined..."
This just happened to be the first function I looked up on this wiki, and if the discussion with examples had not been here, I don't think I would have worked it out at all.--RogerMexico 12:04, 25 September 2010 (UTC)

By default, supplying something inside of quotes is considered of the "string" datatype. So, $string[hello] is the same as "hello". However, use_familiar() needs the familiar datatype. You can't just supply a string (ie "hobo"); you need to supply a familiar. Since datatypes like familiar, element, etc. aren't "normal" datatypes used in programming, we have to use an explicit datatype constant call (the dollar-sign thing) or a function that converts from a string to that datatype. --StDoodle (#1059825) 18:42, 25 September 2010 (UTC)

I've done some further reading on this wiki (which is absolutely superb documentation by the way) and came to understand why it is that way. But for non-programmers like myself who are looking for a quick answer, I think an example on the page would help. I'll try adding one, hope I don't screw it up :) Oh, and is there a page that discusses syntax in general? The whole reason I went and looked at the outfit() function was to try and understand the syntax of the function (specifically, why is the word familiar inside the parentheses there?).The datatype page was helpful, I think something like that on syntax would be nice. --RogerMexico 13:26, 26 September 2010 (UTC)

The word "familiar" inside the parentheses indicates the type of argument that this function accepts. An additional note: the functions for Datatype Conversions might help.
Also, this page might be what you're looking for; I dunno. --Heeheehee 22:10, 26 September 2010 (UTC)