Alias: Difference between revisions
imported>Bumcheekcity |
imported>Fredg1 how aliases are handled (priority), and other minor things |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 3: | Line 3: | ||
An alias is a shortcut for complex CLI command(s) that are too long to type every time you want to. To create a new alias, type | An alias is a shortcut for complex CLI command(s) that are too long to type every time you want to. To create a new alias, type | ||
alias ''[alias_name]'' => ''[actual_command]'' | alias ''[alias_name]'' => ''[actual_command]'' | ||
into the CLI, where <code>''[alias_name]''</code> and <code>''[alias_command]''</code> are replaced with the shortcut string you want to use and the actual command string. For example, to create an alias "f" for the <code>[[familiar]]</code> CLI command, type: | into the CLI, where <code>''[alias_name]''</code> and <code>''[alias_command]''</code> are replaced with the shortcut string you want to use and the actual command string. It is necessary to add a space on both sides of "=>" (<code>alias ''[alias_name]''=>''[actual_command]''</code> won't work). For example, to create an alias "f" for the <code>[[familiar]]</code> CLI command, type: | ||
<pre>alias f => familiar</pre> | <pre>alias f => familiar</pre> | ||
Now, instead of typing <code>familiar pixie</code> or <code>familiar sandworm</code>, you can just type <code>f pixie</code> or <code>f sandworm</code>. | Now, instead of typing <code>familiar pixie</code> or <code>familiar sandworm</code>, you can just type <code>f pixie</code> or <code>f sandworm</code>. | ||
Line 9: | Line 9: | ||
To see the list of aliases that you have created so far, type <code>alias</code> into the CLI without any arguments. | To see the list of aliases that you have created so far, type <code>alias</code> into the CLI without any arguments. | ||
Aliases are preserved across multiple characters. You can remove existing aliases by using the <code>[[unalias]]</code> command. | Aliases are preserved across multiple characters. You can remove existing aliases by using the <code>[[unalias]]</code> command (does not return whether it was successful or not). | ||
Aliases are handled by the preprocessor. This means that if you make an alias for an existing GCLI command, the alias will have priority. Because of this, if you were to ever input <code>alias unalias => ''[text of any kind]''</code>, you would need to manually edit your aliases through the Settings/GLOBAL_aliases.txt text file to remove it. | |||
== Complex Examples == | == Complex Examples == | ||
Line 18: | Line 20: | ||
===Open Beach=== | ===Open Beach=== | ||
<pre style="white-space:pre-wrap;">alias openbeach => ash if(item_amount($item[sweet rims]) < 1 && item_amount($item[bitchin' meatcar]) < 1) hermit(1, $item[sweet rims]); retrieve_item(1, $item[bitchin' meatcar]); if(item_amount($item[Degrassi Knoll shopping list]) < 1) visit_url("guild.php?place=paco"); if(item_amount($item[Degrassi Knoll shopping list]) > 0) use(1, $item[Degrassi Knoll shopping list]); visit_url("guild.php?place=paco"); visit_url("forestvillage.php?place=untinker"); if( | <pre style="white-space:pre-wrap;">alias openbeach => ash if(item_amount($item[sweet rims]) < 1 && item_amount($item[bitchin' meatcar]) < 1) hermit(1, $item[sweet rims]); retrieve_item(1, $item[bitchin' meatcar]); if(item_amount($item[Degrassi Knoll shopping list]) < 1) visit_url("guild.php?place=paco"); if(item_amount($item[Degrassi Knoll shopping list]) > 0) use(1, $item[Degrassi Knoll shopping list]); visit_url("guild.php?place=paco"); visit_url("forestvillage.php?place=untinker"); if(knoll_available()) {visit_url("knoll.php?place=smith"); visit_url("forestvillage.php?place=untinker"); cli_execute("untinker bitchin' meatcar");}</pre> | ||
This opens the beach, getting the rims from the hermit and accounting for the muscle sign correctly. | This opens the beach, getting the rims from the hermit and accounting for the muscle sign correctly. | ||
Line 32: | Line 34: | ||
=== See How Many Substats we need to Level === | === See How Many Substats we need to Level === | ||
<pre style="white-space:pre-wrap;">alias level => ashq stat s; switch(my_primestat()){case $stat[muscle]:s=$stat[submuscle];break;case $stat[mysticality]:s=$stat[submysticality];break;case $stat[moxie]:s=$stat[submoxie];break;default: } int s_left =(my_level() | <pre style="white-space:pre-wrap;">alias level => ashq stat s; switch(my_primestat()){case $stat[muscle]:s=$stat[submuscle];break;case $stat[mysticality]:s=$stat[submysticality];break;case $stat[moxie]:s=$stat[submoxie];break;default: } int s_left =(my_level()**2+4)**2 - my_basestat(s);print("Missing "+s_left+" substat for level "+(my_level()+1));</pre> | ||
Prints something similar to: | Prints something similar to: | ||
Line 38: | Line 40: | ||
Missing 2839 substat for level 12</pre> | Missing 2839 substat for level 12</pre> | ||
==Get a Pagoda== | |||
<pre style="white-space:pre-wrap;">alias pagoda => ashq if(!can_interact()) print("Wait for aftercore!"); else if(get_campground() contains $item[pagoda plans]) print("You already own a Pagoda, surely one is enough for any man.", "red"); else if(item_amount($item[Hey Deze map]) < 1) print("You need Hey Deze map from The Pandamonium Slums to continue.", "red"); else {foreach doodad in $items[guitar pick, heavy metal sonata, heavy metal thunderrr guitarrr, Elf Farm Raffle ticket, ketchup hound] retrieve_item(1, doodad); if(!in_bad_moon()) retrieve_item(1, $item[ten-leaf clover]); use(1, $item[Elf Farm Raffle ticket]); use(1, $item[Hey Deze map]); use(1, $item[ketchup hound]);} | |||
</pre> | |||
==Make Key Lime Pies== | |||
<pre style="white-space:pre-wrap;">makeKLP => ash foreach i in $items[Jarlsbergs Key Lime Pie, Boris's Key Lime Pie, Sneaky Pete's Key Lime Pie, digital key lime pie, star key lime pie] { if (creatable_amount(i) > 0) create(creatable_amount(i),i); }</pre> | |||
[[Category:CLI Commands]] | [[Category:CLI Commands]] | ||
Line 46: | Line 55: | ||
This calls EatDrink with a set of defaults, allowing you to have a shortcut for aftercore or other situations where you want to use as much organ as appropriate. | This calls EatDrink with a set of defaults, allowing you to have a shortcut for aftercore or other situations where you want to use as much organ as appropriate. | ||
==Adding An Argument== | |||
By adding %% to an alias, you can pass an argument to the alias. However, specifying it as a data type is needed to properly use it with ash functions. Consider the following 2 aliases: | |||
<pre style="white-space:pre-wrap;">alias testing => ash print("%%:"+length("%%")); | |||
alias testing2 => ash print($string[%%]+":"+length($string[%%])); | |||
</pre>The two aliases are written to take an input and print it with a colon followed by the number of characters. Both are technically correct as they will work without error. However, they output different results. | |||
<pre style="white-space:pre-wrap;">> testing four | |||
four :5 | |||
Returned: void | |||
> testing2 four | |||
four:4 | |||
Returned: void</pre>In the first example, an extra space is added. It is currently unknown what is causing this. |
Latest revision as of 21:07, 31 October 2019
Creates a new alias in the KoLmafia CLI or displays the list of registered aliases. An alias is a shortcut for complex CLI command(s) that are too long to type every time you want to. To create a new alias, type
alias [alias_name] => [actual_command]
into the CLI, where [alias_name]
and [alias_command]
are replaced with the shortcut string you want to use and the actual command string. It is necessary to add a space on both sides of "=>" (alias [alias_name]=>[actual_command]
won't work). For example, to create an alias "f" for the familiar
CLI command, type:
alias f => familiar
Now, instead of typing familiar pixie
or familiar sandworm
, you can just type f pixie
or f sandworm
.
To see the list of aliases that you have created so far, type alias
into the CLI without any arguments.
Aliases are preserved across multiple characters. You can remove existing aliases by using the unalias
command (does not return whether it was successful or not).
Aliases are handled by the preprocessor. This means that if you make an alias for an existing GCLI command, the alias will have priority. Because of this, if you were to ever input alias unalias => [text of any kind]
, you would need to manually edit your aliases through the Settings/GLOBAL_aliases.txt text file to remove it.
Complex Examples
Automatically Getting Dentures
alias dentures => checkpoint; equip frilly skirt; ash visit_url("inv_use.php?which=3&whichitem=2951&pwd"); visit_url("choice.php?whichchoice=188&option=3&choiceform3=Catburgle&pwd"); cli_execute("outfit checkpoint");
This equips a frilly skirt, chooses the right choice in the Orcish Frat House Blueprints adventure, and then re-equips whatever pants you had on when you type dentures into the CLI.
Open Beach
alias openbeach => ash if(item_amount($item[sweet rims]) < 1 && item_amount($item[bitchin' meatcar]) < 1) hermit(1, $item[sweet rims]); retrieve_item(1, $item[bitchin' meatcar]); if(item_amount($item[Degrassi Knoll shopping list]) < 1) visit_url("guild.php?place=paco"); if(item_amount($item[Degrassi Knoll shopping list]) > 0) use(1, $item[Degrassi Knoll shopping list]); visit_url("guild.php?place=paco"); visit_url("forestvillage.php?place=untinker"); if(knoll_available()) {visit_url("knoll.php?place=smith"); visit_url("forestvillage.php?place=untinker"); cli_execute("untinker bitchin' meatcar");}
This opens the beach, getting the rims from the hermit and accounting for the muscle sign correctly.
See How many charges left on Bartender/Chef
alias boxen => ashq if(have_chef()) print("Chef turns used: "+get_property("chefTurnsUsed"),"green"); else print("No chef-in-a-box","gray"); if(have_bartender()) print("Bartender turns used: "+get_property("bartenderTurnsUsed"),"green"); else print("No bartender-in-a-box","gray");
This prints something similar to:
> boxen Chef turns used: 5 Bartender turns used: 10
See How Many Substats we need to Level
alias level => ashq stat s; switch(my_primestat()){case $stat[muscle]:s=$stat[submuscle];break;case $stat[mysticality]:s=$stat[submysticality];break;case $stat[moxie]:s=$stat[submoxie];break;default: } int s_left =(my_level()**2+4)**2 - my_basestat(s);print("Missing "+s_left+" substat for level "+(my_level()+1));
Prints something similar to:
> level Missing 2839 substat for level 12
Get a Pagoda
alias pagoda => ashq if(!can_interact()) print("Wait for aftercore!"); else if(get_campground() contains $item[pagoda plans]) print("You already own a Pagoda, surely one is enough for any man.", "red"); else if(item_amount($item[Hey Deze map]) < 1) print("You need Hey Deze map from The Pandamonium Slums to continue.", "red"); else {foreach doodad in $items[guitar pick, heavy metal sonata, heavy metal thunderrr guitarrr, Elf Farm Raffle ticket, ketchup hound] retrieve_item(1, doodad); if(!in_bad_moon()) retrieve_item(1, $item[ten-leaf clover]); use(1, $item[Elf Farm Raffle ticket]); use(1, $item[Hey Deze map]); use(1, $item[ketchup hound]);}
Make Key Lime Pies
makeKLP => ash foreach i in $items[Jarlsbergs Key Lime Pie, Boris's Key Lime Pie, Sneaky Pete's Key Lime Pie, digital key lime pie, star key lime pie] { if (creatable_amount(i) > 0) create(creatable_amount(i),i); }
Calling ASH Files
EatDrink Shortcut
alias eatdrinkquick => ashq import <EatDrink.ash>; void main(int advmeat, boolean overdrink) { eatdrink(fullness_limit(), inebriety_limit(), spleen_limit(), overdrink, advmeat, 100, 10, 1000, false); }
This calls EatDrink with a set of defaults, allowing you to have a shortcut for aftercore or other situations where you want to use as much organ as appropriate.
Adding An Argument
By adding %% to an alias, you can pass an argument to the alias. However, specifying it as a data type is needed to properly use it with ash functions. Consider the following 2 aliases:
alias testing => ash print("%%:"+length("%%")); alias testing2 => ash print($string[%%]+":"+length($string[%%]));
The two aliases are written to take an input and print it with a colon followed by the number of characters. Both are technically correct as they will work without error. However, they output different results.
> testing four four :5 Returned: void > testing2 four four:4 Returned: void
In the first example, an extra space is added. It is currently unknown what is causing this.