Some general questions.

itamaram

Member
Being the untrusting person I am, I've decided to make my own script. Sadly I've ran into a few difficulties. Can you good people answer my questions? Also, where do you get the answers for those questions? is it all in the documentation or something?

Anyway, to the questions!
(1)Is there a way to retrive the PRICE of the cheapest [item] in a mall without actually buying it?

(2)Is it possible to buy the second cheapest item in the mall? Or the first one not undercut?

(3)Is it possible to run one script out of another? (For example Illarion's excelent healing script. Go him!)

(4)How do I put on an outfit? (costum or ingame predefined)

(5)How do I summon toast?

(6)When comparing strings, (such as my_name()) am I to use "==" or ".isEqualto([string])" or something completely different?

(7)Is it possible to access some predefined functions of the KolMafia from my script? (eg train famliars, or more importantly run "between combat scripts").

(8)Is it possible to terminate the KolMafia upon completion? Not really all that important but it is quite cool...

Thats about it. If I will master all of this knowledge my bot would be complete...

Thanks, Itamar
 

Tirian

Member
1) No.
2) No.

Those would be key tools in writing mallbots in ASH, and one of the key declarations of KolMafia is that they don't want it to be easy for people to write evil scripts like mallbots and clan-raiders.

3) Um, maybe cli_execute("call script2.ash") would do something good. I've never tried it myself.

What is easier is running a function from another script from your own, which just takes an import <illarion_rocks.ash>; statement and then calling whatever functions he defines. You can't call the main() function of someone else's script (I don't think), but you can get around that by renaming their main function to foo and creating a new main function in their script that just calls foo.

4) cli_execute("outfit swashbuckling");

5) KolMafia automatically gets your toast and evil food for you as long as you have the tools equipped in your campsite when you log in.

6) Never having had to do it, I suspect it's ==. Keep in mind that ASH isn't object-oriented, and definitely isn't reference-oriented so that you wouldn't have the Java issues that require an isEqual function.

7) Check out the CLI reference page, because most of the quest-oriented functions are CLI commands. Familiar training, mushroom plot management, quests, it's mostly all there.

eight) Heh, you can't even close all the open Mafia windows with one GUI command, much less from a script. ;)
 

itamaram

Member
Cool thanks a lot.
Just a clarification about outfits, should a costum outfit be: cli_execute("outfit costum outfit: name") or something else?

And where is the CLI reference page? Sounds useful...

And just a clarification my first 2 questions where purely innocent. I was wondering if I can determine which of the 3 chow mein types is the cheapest to buy, and then buy it. I will now have to use the lesser method of checking whether or not it is a certain stat day and just avoid the corresponding chow mein...
 
[quote author=itamaram link=topic=105.msg389#msg389 date=1145651224]
Being the untrusting person I am, I've decided to make my own script. Sadly I've ran into a few difficulties. Can you good people answer my questions? Also, where do you get the answers for those questions? is it all in the documentation or something[/quote]
When kolmafia is running, click help, then end user manual. most info is contained there or on pages linked to on that page.
Anyway, to the questions!
(1)Is there a way to retrive the PRICE of the cheapest [item] in a mall without actually buying it?
Nope, that would allow creation of a mallbot which is definately not the intended use of kolmafia.
(2)Is it possible to buy the second cheapest item in the mall? Or the first one not undercut?
Not that I know of.
(3)Is it possible to run one script out of another? (For example Illarion's excelent healing script. Go him!)
Ash
Code:
cli_execute("call scriptname.ext");
or for access to functions in the script from inside the script add
Code:
import <scriptname.ext>
non-ash
Code:
call scriptname.ext
(4)How do I put on an outfit? (costum or ingame predefined)
Ash
Code:
cli_execute("outfit outfitname");
Non-ash
Code:
outfit outfitname
(5)How do I summon toast?
kolmafia does it for you at logon
(6)When comparing strings, (such as my_name()) am I to use "==" or ".isEqualto([string])" or something completely different?
ash only:
Code:
if(my_name == "someone")
{
//do something here
}
(7)Is it possible to access some predefined functions of the KolMafia from my script? (eg train famliars, or more importantly run "between combat scripts").
mafia uses between battle scripts while running scripts, it also uses your auto-restore settings. I've never tried the familiar trainer, so I cannot give you exact code. I'm pretty sure it is though.
(8)Is it possible to terminate the KolMafia upon completion? Not really all that important but it is quite cool...
ash
Code:
cli_execute("exit");
non-ash
Code:
exit

Check out the many scripts that have been uploaded to this repository. They can be a great source of information, and ideas. Myself and several others don't mind if you copy functions or import our entire scripts into yours, so that can even save you a ton of time.

Code:
Just a clarification about outfits, should a costum outfit be: cli_execute("outfit costum outfit: name") or something else?
nope, just the name.
And where is the CLI reference page? Sounds useful...
In the user manual is a scripting link.
And just a clarification my first 2 questions where purely innocent. I was wondering if I can determine which of the 3 chow mein types is the cheapest to buy, and then buy it. I will now have to use the lesser method of checking whether or not it is a certain stat day and just avoid the corresponding chow mein...
if you are farming the ICY peak for meat, then knob sausage chow mein gives the most adv, and if you have a good outfit, and effects list, it pays the added price and give more profits to use it.
 

Tirian

Member
[quote author=itamaram link=topic=105.msg397#msg397 date=1145653558]
And just a clarification my first 2 questions where purely innocent.
[/quote]

Oh, don't worry about it! We're not keeping notes on you. ;D It is completely natural to want these extensions. God, if I had a nickle for every time I wrote a line that said "take_clan($item[...])" and banged my head against the desk, I'd have enough money to get a doctor to look into my frequent headaches.

If your outfit shows up in the drop-down list as "Custom: pajamas", then all you need is "outfit pajamas". Notice that using substrings is fine too as long as there is just one possible match. For instance, my original example was "outfit swashbuckling" even though it is actually the Swashbuckling Getup. "outfit shbuc" would probably do just as well, although it would piss off anyone who tried to read your script.

The online user manual is at http://kolmafia.sourceforge.net/manual.html, and the CLI reference is in the "Scripting with KolMafia" link.
 
Oh, don't worry about it!  We're not keeping notes on you.    It is completely natural to want these extensions.  God, if I had a nickle for every time I wrote a line that said "take_clan($item[...])" and banged my head against the desk, I'd have enough money to get a doctor to look into my frequent headaches.
From the reference
int stash_amount( [item])
[item] the item to count
Returns the amount of [item] in your clan's stash.

boolean put_stash( [int], [item])
[int] The amount of [item] to put
[item] The item to put
Puts [int] of [item] in your Clan's Stash.

look at the code contained in the thread http://kolmafia.us/index.php/topic,53.0.html it contains a neat trick dealing with display cases which can easily be re-written by using the mini browser to obtain links. The stash_amount function makes it possible to safely write the code. The code hasn't been updated for the 7.1 release of kolmafia yet. There is no need to import the item to int script.
 

Tirian

Member
[quote author=efilnikufecin link=topic=105.msg403#msg403 date=1145655495]
From the reference
int stash_amount( [item])
[item] the item to count
Returns the amount of [item] in your clan's stash.

boolean put_stash( [int], [item])
[int] The amount of [item] to put
[item] The item to put
Puts [int] of [item] in your Clan's Stash.
[/quote]

Right. You can see how many there are, you can put more in, but you can't take anything out. That keeps me from doing friendly clan things like:

Code:
stash take * smart skull
stash take * disembodied brain
create * brainy skull
stash put * smart skull
stash put * disembodied brain
stash put * brainy skull

because someone might use that functionality and a nightmist-esque library to write:

Code:
item booty;
booty=$item[seal-clubbing club]
while(!booty==$item[oily mushroom wine]);
{
  take_stash($stash_amount(booty), booty);
  booty = next_item(booty);
}
 

itamaram

Member
While I am at it, a completely different question.
How does KolMafia interact with off-hand weapons and dual weilding?
If I will write:"equip($item[seal-clubbing club]);"
I am guessing it will automatically put it in my weapon hand rather than my off-hand. How do I change it?
 

itamaram

Member
More questions!
Well actually only one.
Are variables case sensitive? Can I have a boolean "saucesphere" and a final int "SAUCESPHERE"?
 
[quote author=itamaram link=topic=105.msg407#msg407 date=1145668439]
More questions!
Well actually only one.
Are variables case sensitive? Can I have a boolean "saucesphere" and a final int "SAUCESPHERE"?
[/quote]

My best answer is yes and no.

Yes they are case sensitive when regarding function names and such. So I would figure that variables themselves would be case sensitive.

And a big resounding NO when it comes to programming practice. Aside from syntax, you should never consider case sensitive acceptable. In other words, knowing that if you capitalize the first letter of a variable / function name you should do it for all calls to that function / variable. But actually planning a situation when you have a variable or function called saucesphere, and another called SAUCESPHERE is just poor practice.

Not that I am the worlds most etiquette savvy programmer. (I hate commenting my scripts by the way. That is a no-no.) But it is a good idea to get into practice calling things distinctly different names. Like saucesphere, and totalsaucesphere. Or some such.

I can not answer your question about off-hand weapons since I do not have the skill yet.
 
[quote author=Tirian link=topic=105.msg404#msg404 date=1145657085]
Right.  You can see how many there are, you can put more in, but you can't take anything out.  That keeps me from doing friendly clan things like:

Code:
stash take * smart skull
stash take * disembodied brain
create * brainy skull
stash put * smart skull
stash put * disembodied brain
stash put * brainy skull

because someone might use that functionality and a nightmist-esque library to write:

Code:
item booty;
booty=$item[seal-clubbing club]
while(!booty==$item[oily mushroom wine]);
{
   take_stash($stash_amount(booty), booty);
   booty = next_item(booty);
}
[/quote]
Did you look at the file contained in the thread http://kolmafia.us/index.php/topic,53.0.html ?? It generates the php command needed to put stuff in a display case or take it out. What I was trying to tell you is that you could write the following just as easily as I could.
Code:
void Take_Stash(int Quant, item totake)
{
//clan_stash.php?pwd=&action=takegoodies&quantity=1&whichitem=440
string header;
string middle;
string footer;
header = "./clan_stash.php?pwd=&action=takegoodies&quantity=";
middle = "&whichitem=";
cli_execute(header + int_to_string(Quant) + middle + ItemToStringNumber(totake));
cli_execute("inv refresh");
}

Equipping of off-hand weapons is not currently supported that I know of. The same method seen above can be used just obtain the link from the mini browser.
 

Veracity

Developer
Staff member
[quote author=efilnikufecin link=topic=105.msg410#msg410 date=1145678966]Equipping of off-hand weapons is not currently supported that I know of.[/quote]
It's supported in the regular CLI and thus in ASH via cli_execute.

equip <slot> <item>
unequip <slot>

where <slot> can be

hat, weapon, off-hand, shirt, pants, acc1, acc2, acc3, familiar, fakehand
 
[quote author=Veracity link=topic=105.msg412#msg412 date=1145679758]
It's supported in the regular CLI and thus in ASH via cli_execute.

equip <slot> <item>
unequip <slot>

where <slot> can be

hat, weapon, off-hand, shirt, pants, acc1, acc2, acc3, familiar, fakehand
[/quote]

Thank you Veracity! Runs off to modify one of my scripts to remove all those special functions that contain cli_execute then build a link allowing kolmafia to do just that :)
 

Tirian

Member
[quote author=efilnikufecin link=topic=105.msg410#msg410 date=1145678966]
What I was trying to tell you is that you could write the following just as easily as I could.
[/quote]

Oh.

(goes on to other thoughts for a few days)

:eek:

[size=30pt]OH![/size]

Yes, that does very very nicely. Thank you for explaining it to me again.
 
Top