View Full Version : auto-equip sugar shield using a consult?
huvanile
01-19-2011, 04:29 PM
I'm trying to get a consult script going that auto-equips my familiar with a sugar shield after the one equipped shatters through use. I've got the code to actually equip the item (below), but I'm wondering if there's a way in ash to see if one is already equipped first.
Is there a function that I can call that would do something like an "is_equipped()" or "wearing()"? I'm thinking that checking to see if one is already equipped first might be quicker than trying to equip one each and every battle. I know I could probably check to see how many sugar shards I have in inventory, but is there a more elegant way to do this?
Thanks!
# equipSugarShield.ash
# called from the CSS using: consult equipSugarShield.ash
void main() {
cli_execute("equip familiar sugar shield");
}
There are several ways to look for ASH functions. The first one is typing
ashref <partial name>
in the gCLI, like this:
> ashref equip
boolean can_equip( item )
boolean equip( item )
boolean equip( slot, item )
int equipped_amount( item )
item equipped_item( slot )
item familiar_equipment( familiar )
item familiar_equipped_equipment( familiar )
boolean have_equipped( item )
You can also search the KoLMafia Wiki (http://wiki.kolmafia.us/). There is a shortcut: typing
ashwiki familiar_equipment
in the gCLI will also bring up the wiki page for you.
Regarding your script, Mafia can already automatically re-equip breakable equipment (Adventure tab -> Choice Advs middle tab -> Item side tab -> Breakable Equipment).
Oh, and just so you know, the term "consult script" is used for scripts that manage fights. Trying to equip something during a fight is unlikely to work ^^
huvanile
01-19-2011, 05:12 PM
sweet, this helps a great deal. "teach a man to fish..." or something. :D thanks!
Winterbay
01-19-2011, 07:50 PM
Isn't there a preference for re-equipping the same kind of thing that just broke?
Ahh, found it: breakableHandling.
Typing "set breakableHandling4183 = 3" in the CLI should make it so that Mafia reequips sugar shields until they are all out and then aborts.
That said, making a script also works :)
First of all, exactly what slyz and Winterbay just said. I'd also like to point out that this is in the KoLmafia wiki FAQ (http://wiki.kolmafia.us/index.php?title=Help:Frequently_Asked_Questions#In terface)
Secondly, please don't try to do that with a consult script. Consult scripts run during combat. You shouldn't try to equip gear during combat. I could think of a way to make it work, but it is still extremely bad form.
huvanile
01-19-2011, 09:53 PM
Thanks for weighing in on this Bale, PMslyz and Winterbay. (The more I mess around with mafia the less noob-ish questions I'll post.) Setting the preference in the GUI achieved what I was trying to do with ease.
@Bale: Thanks for all the great scripts btw. Your OCD inventory control and your universal_recovery scripts have been a huge help.
Being told you like my scripts doesn't make me at all happy, you bastard.
http://a.imagehost.org/0624/happy.png
Quick, tell Bale you hate the way Universal Recovery handles items that restore full health before he gets too unhappy!
Theraze
01-19-2011, 10:27 PM
Have we reached the point where we get to rail at how it actually considers healing beaten up: how and when it will happen instead of just doing it in a somewhat random fashion?
huvanile
01-19-2011, 10:31 PM
Is this a joke? Whatever, I'll send you a stuffed hodgmen instead when I get one. Note to self: shut up on forums. (facepalm)
Is this a joke?
Yes. Apparently not a very well received one. Ah well, at least slyz seemed to understand it was a joke. It actually makes me very happy to hear people are pleased with my scripts, but that seemed a bit obvious to point out so I went full reverse.
Theraze
01-20-2011, 12:10 AM
I was trying to join in too. :( Apparently it failed. Referring to mafia's attempt at curing BU before it actually lets recovery scripts do it, if people misset their preferences, and... Anyways, sadness.
Did you know that removeMalignantEffects is a global pref, so if I wanted my script to turn off that property and take over the function itself it would strand other characters who might not be using Universal Recovery? Maybe I could consider that if it was a user property, but global?
Theraze
01-20-2011, 01:09 AM
Depressing... if a global pref is put into a local pref file (is that even possible?) would it stick there?
I doubt it. Changing this would require a chnage to KoLmafia.
Theraze
01-20-2011, 02:26 AM
Ah well... so it goes. Unfortunate that it hits before the recovery script, so it can't just be depreciated while using it...
huvanile
01-20-2011, 03:59 PM
Hey do any of you know if there's an ash function I can call to check to see if I'm currently wearing one of my custom outfits or not?
Taking slyz's advice, I did an "ashref outfit", "ashwiki outfit" and "ashref equipped" but I can't really find what I'm looking for. I'm thinking something like a "my_outfit()" would do it if such a thing exists. I see there's a "have_outfit()" function, but I think that just checks to see if I have an outfit available but not necessarily if I'm wearing it or not.
I know I could use "have_equipped()" for one of the pieces of my custom outfit, but I don't want to have to change my script if I improve my custom outfit later on down the line.
Any thoughts?
You could always do outfit( "outfit name" ). If you were using it, nothing happens. If you weren't using it, it will equip it.
Theraze
01-20-2011, 05:32 PM
If the patch for my_outfit gets added, you could use that. Otherwise, you have to try to wear the outfit and see if it changes your gear.
Winterbay
01-20-2011, 05:36 PM
But your patch still doesn't return the name of eventual custom outfit I may or not be wearing. I guess without Mafia storing which outfit contains what that would be difficult.
Theraze
01-20-2011, 05:39 PM
It should... doesn't it pull custom outfit names? <Goes to check>
Edit: True... I wanted it to parse those as well. Guess that's something to see if it's possible to work on. Might be, might not.
And if you do *that*, you can actually be wearing up to 9 custom outfits at the same time.
Theraze
01-20-2011, 07:30 PM
Nice... so, guess that will get ignored, since there isn't really a good way to give the response... Could give a "equipped_outfit(String)" variable if it's wanted... that shouldn't be too difficult to work, and would work with customs as well as official outfits.
Bale to the rescue!
Hey do any of you know if there's an ash function I can call to check to see if I'm currently wearing one of my custom outfits or not?
The function you're looking for is string_modifier("outfit")
outfit_name = "my custom outfit"
if(string_modifier("outfit") == outfit_name)
print("Yay! I'm wearing "+ outfit_name +".", "green");
else print("I'm not wearing "+ outfit_name +".", "red");
Unfortunately, string_modifier("outfit") will only return something if you are wearing one of the outfits listed in outfits.txt. If you really wanted to, you could put outfits.txt in your /data folder and add you custom outfits at the end of the file (giving them fake IDs).
Powered by vBulletin® Version 4.2.0 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.