hatter.ash - Tea anyone!?

hatter.ash - Tea anyone!?
Enjoying tea the mafia way.

I was admiring the usage function in bounty.ash and was inspired to write this. Also, I saw a feature request regarding this. Also, my CS1400 professor is accepting this as extra credit. Also, I love tea! Well, at least the FUZE - Black & Green Tea with Acai Berry. That stuff is addictive! :D


Usage:

call hatter.ash [argument]
or
hatter.ash [argument]
or
alias tea => ashq import<hatter.ash> hatter($string[%%])

Arguments:

an integer value
Visits the hatter with a hat that has the number of non-space characters specified.

current
equipped

Visits the hatter with the hat you are currently wearing.

hat
Where hat is the name of the hat to use. Visits the hatter with the hat specified.

buff
Where buff is the name of the buff to get. Uses mafias fuzzy matching.
(i.e. "pep" = "Assaulted with Pepper")

Other arguments:

ml, monster level, fe, fam exp, familiar experience, moxie, muscle, myst, mysticality, wd, weapon, weap dam, weapon damage, %spell, %spell dam, %spell damage, hp, max hp, maximum hp, mp, max mp, maximum mp, sleaze, sleaze dam, sleaze damage, spell, spell dam, spell damage, cold, cold dam, cold damage, spooky, spooky dam, spooky damage, stench, stench dam, stench damage, hot, hot dam, hot damage, %wd, %weapon, %wep dam, %weapon damage, meat, %moxie, %muscle, %myst, %mysticality, fw, fam weight, familiar weight, stats, stat, stat gain, item, items

Note: It is case insensitive. So, meat = Meat = MEAT

If you forget or need a reminder of the arguments and what they do just call the script with one of the help arguments (h, ?, help, usage) to display a table of valid arguments and what they do.

Also, the help arguments now display the hats associated with a particular buff. They are printed in blue if you own them or if they are easily obtained. They are printed in red if you have access to them but cannot equip them. Their location is also printed. This includes hats located in your closet, display, starter hats from gum on a string, NPC hats, etc. Here are a few screen shots:

hatter 1.PNG hatter 2.PNG

Examples:

call hatter.ash 22
Gets the buff corresponding to the hat whose length (excluding white space) is 22.

hatter.ash dances
Does a fuzzy match on hat buffs to see if one matches dances and gets that buff.

hatter.ash meat
Gets the buff that will increase meat drops

To utilize this script from within another script import it and use the hatter() function:
import<hatter.ash>
hatter("meat");

or use cli_execute() like so:
cli_execute("call hatter.ash meat");


If you find this script useful, donations in the form of in-game ninja paraphernalia are always appreciated! Thanks and enjoy the script.

Change log:
05.25.2010 - Re-equips the hat you were wearing when the script was called.
05.30.2010 - The help function can now be called even if you've already got your buff for the day.
01.16.2011 - Added a can_equip() check to the hat selection logic. Thanks slyz.
06.16.2011 - Re-factored code. Eliminated global variables and maps. Changed functions to have more useful return values.
06.26.2011 - v1.4 Extend the help command to list all hats. They are printed in blue (along with their location) if you own them or if they are easily obtained.
 

Attachments

  • hatter.ash
    16.9 KB · Views: 233
Last edited:
Heres what I would recommend:

It would be great if you could run the script with no arguments at all. It would do the following,

1) Go through every hat in your inventory and figure out how many letters are in it. Store all the unique values into a Map.
2) Go through every unique value in the Map, printing a synopsis of the buff that you can get.
3) Query the user, asking them to input the number of the desired buff.
4) Equip the appropriate hat and get the buff.
5) Reequip whatever hat they had started with.

I think this would be a LOT more user-friendly. Looking at your script, you seem to already have the knowledge of how to do Maps and get the Length of an item, get hats owned, etc. So I think its just a matter of rearranging your code some.
In fact, you could still retain all of the functionality of the script as is. Running it with no params would simply make it do items 1,2, and 3 first. Then you'd call your function as if you were calling the script with an integer input, based on what they entered.

This would be friggin awesome!
 
Last edited:

mredge73

Member
3) There has been much debate about it but the ability to query the user for an integer input has been turned down by the devs numerous times.
The only way to do it is with two script files were one accepts an integer argument and returns that argument back to the main. I have seen it done somewhere in these forums.

Anyway, good script ideas!
 
Last edited:

Bale

Minion
Just checking if people know the CLI command: hatter

This script does several things that the CLI command does not, but the command will tell you the effects of all the hats you have. Just felt that the command needs to be mentioned since hatter does do one thing that this script does not accomplish.
 
@ Bale
Thanks for the input. I actually wrote this script with the built-in hatter command in mind, sort of as an extension of that command.

@ SinginSally
As Bale pointed out, the hatter cli command already completes the first two items in your list. As for querying the user, I do not what to do that other than the way it is now. If you call the script without an argument it will prompt you for one. As far as re-equipping the previous hat, that is functionality that is unduly missing and I will upload that change right after this post. Thank you for the advice.

@mredge
An example of the functionality you are referring to is my in_control.ash located here.
 
Bale, one step ahead of me again. :) That is great to know about the new Hatter mafia command.

In that case Id suggest the following: If the user does enter one of the Help/?/whatever arguments, you might want to even cli_execute("hatter") before typing out your text.

I was unaware of the limitation of entering an integer. Ive seen pop up boxes and just assumed you could input anything.
 

Bale

Minion
I was unaware of the limitation of entering an integer. Ive seen pop up boxes and just assumed you could input anything.

Perhaps mredge73 was unclear. Any soft of variable can be entered at the start of a script. Those are the many pop up boxes you may have seen. However, after a script has started, only yes/no can be asked of the user. The problem is that you wish to enter an integer after the script already began.
 

fronobulax

Developer
Staff member
It would be nice if the script (or hatter, but that would be a feature request) knew about hats in a display case or Hagnk's or a closet. As a Display Case completest I am always trading off the utility of an item in game vs. the completeness of my collection vs. the cost of a duplicate. This lets me make a more informed choice in an easier way than using the wiki and the display case manager. But I am an edge case ;)
 

slyz

Developer
I haven't tried this script, but after having a look I would have a small feature request: could it re-equip the currently equipped hat after getting the buff?
 

slyz

Developer
Code:
[COLOR="#808000"]> call hatter meat[/COLOR]

Buff selected: Dances with Tweedles
[COLOR="#ff0000"]You can't equip a Uncle Hobo's stocking cap[/COLOR]

I simply added this to lines 123 and 147:
PHP:
&& can_equip(itm)
 

fianor

Member
I'm using this as part of my daily farming scripting and right now am calling it with cli_execute because main() does so much I'm not sure how to run it via import. Is this possible or am I stuck with doing calling it via cli? I know it doesn't really matter it just annoys me to use cli_execute inside my ash scripts for some reason.
 

Bale

Minion
If you import a script it will not execute anything in main(). However, taking a look at the script you don't need to use main() if you already know what effect you want, like this...

PHP:
import "hatter.ash";

if(get_property("_madTeaParty") == "false")
   hatCheck($effect[Quadrilled]);
 
I'm using this as part of my daily farming scripting and right now am calling it with cli_execute because main() does so much I'm not sure how to run it via import. Is this possible or am I stuck with doing calling it via cli? I know it doesn't really matter it just annoys me to use cli_execute inside my ash scripts for some reason.

I decided to make the script more import friendly for those who dislike using cli_execute for whatever reason. :confused:

To utilize this script from within another script you can now import it and use the hatter() function:
import<hatter.ash>
hatter("meat");


Also, it helps that the code was just horrible, I mean, who makes functions that all return void and set global variable flags for other functions to check instead of just returning a useful value in the first place? And what was with the global hats map that went through every item in the game even if you were just using the help command?? Come on guys, if the code sucks, please let me know. :eek:

Update

  • Re-factored code.
  • Eliminated global variables and maps.
  • Changed functions to have more useful return values.

This is an extensive overhaul that has only been tested once so let me know if I screwed anything up.
 

Bale

Minion
Also, it helps that the code was just horrible, I mean, who makes functions that all return void and set global variable flags for other functions to check instead of just returning a useful value in the first place? And what was with the global hats map that went through every item in the game even if you were just using the help command?? Come on guys, if the code sucks, please let me know. :eek:

LoL! I'm sorry. I never actually looked at the code for this script until I tried to answer fianor's question. I hadn't even found all those problems yet! Isn't it wonderful that prompted you to refactor everything now?
 
LoL! I'm sorry. I never actually looked at the code for this script until I tried to answer fianor's question. I hadn't even found all those problems yet! Isn't it wonderful that prompted you to refactor everything now?

Yeah, it's actually quite amusing to look at code that you wrote in the past and realize how much you've learned. More amusing yet is the idea that in six months or so I'm probably going to be looking at the code I just wrote for this update and be thinking about how horrible it is.
 

fianor

Member
That FN Ninja said:
I decided to make the script more import friendly for those who dislike using cli_execute for whatever reason.

It just feels wrong. It's like speaking English to a translator who understands Spanish but just says the same English words to the other guy cause he speaks English too. Stop looking at me like that ...

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

Not sure whether to be extremely happy that you fixed all this, or to be really angry at either myself for spending the time trying, or myself for failing to make it better before you beat me to it.

I think I'll choose the first option.

Oh, and it of course worked perfectly.
 
Last edited:
Update

The help arguments now display the hats associated with a particular buff.

They are printed in blue if you own them or if they are easily obtained. They are printed in red if you have access to them but cannot equip them. Their location is also printed. This includes hats located in your closet, display, starter hats from gum on a string, NPC hats, etc. Here's a screen shot.


It would be nice if the script (or hatter, but that would be a feature request) knew about hats in a display case or Hagnk's or a closet. As a Display Case completest I am always trading off the utility of an item in game vs. the completeness of my collection vs. the cost of a duplicate. This lets me make a more informed choice in an easier way than using the wiki and the display case manager. But I am an edge case ;)

Gotta give some love to the edge cases every once in awhile. ;)
 
Top