Hidden Temple Basic Script

codster62

Member
Hello, I am Cody Hawken, and I have come to Kolmafia hoping to spice up somthing for kol. This is my first basic script ever, and i have created this on my own. I am 14 and have no one to help me script. If anybody has any suggestions, please help me out. I need a good tutorial if anyone has one for me. But for now, here it is. :)

Equip Nurse's hat
Equip Sponge Pants
Equip Spongy shield
Equip acc1 ring of half-assed generation
adventure 40 hidden temple
if health =< 20
buy Doc Galaktik's Ailment Ointment
use Doc Galaktik's Ailment Ointment

It's not much and really had no clue what in the world I was doing. I know this can be much improves, and if you do improve, tell me what I should have done, and teach me the ways of ash scripting.
 

Attachments

  • hiddentemple.ash
    222 bytes · Views: 71

codster62

Member
Howdy y'all. I am the maker of this script. I need to do some learning, by I have made this and threw it out for anyone to add on to and fix, because I'm pretty sure this won't work. I thank everyone who contribute's. Also, for anyone who wants to gain levels with their 40 adventures per day, the hidden temple is a good place for most people in lower levels. This script also tries to equip you with some hp/mp regeneration items if you have them. :) Made mostly for higher levels.
 
It's not a bad script, but I have some suggestions from a gameplay point of view. The optimal way to level in the hidden temple is to heal only when at 0 hp, and heal using Doc Galaktik's on tap curative nostrum (it's cheaper!).
Try this for healing.
Code:
 visit_url("galaktik.php?pwd&action=curehp&quantity=1");
 

codster62

Member
Realistically, in the script, I have chosen those items for a reason, but either way, thanks for your input. You should not ever need to heal much with those items equipped. I have no idea, however, how to do advanced scripting, so I thankyou for that line of code. :)
 

Grotfang

Developer
Can I suggest you take a look here if you want to learn some basic ash stuff (along with more complicated elements):

http://wiki.kolmafia.us/index.php?title=Main_Page

It won't tell you much about how to write a script from scratch, but it will tell you valid variables and the like. For example, "Equip Nurse's hat" doesn't do anything.

What might help you is to use mafia's "verify" command in the CLI to test whether or not a script is likely to work. Simply type (in this case) "verify hiddentemple.ash" to see whether it is valid.

I haven't given this a trial run, but it should work. It will prompt you to enter a number of adventures (adv_to_use) that you wish to spend, instead of restricting yourself to 40 every time you use the script. I also assumed that you meant "Square sponge pants" when you said "Sponge pants".

Code:
void main( int adv_to_use )
{
	equip( $slot[hat] , $item[Nurse's hat] );
	equip( $slot[pants] , $item[Square sponge pants] );
	equip( $slot[off-hand] , $item[Spongy shield] );
	equip( $slot[acc1] , $item[ring of half-assed regeneration] );
	
	while( my_adventures() > 0 && adv_to_use > 0 )
	{
		if ( my_hp() < 20 )
		{
			buy( 1, $item[Doc Galaktik's Ailment Ointment] );
			use( 1, $item[Doc Galaktik's Ailment Ointment] );
		}		
		adventure( 1 , $location[Hidden Temple] );
		adv_to_use = adv_to_use - 1;
	}
}

Assuming this script does do what you were wanting, feel free to ask for more detail on what I put and why. I'm not very experienced in the world of ASH scripting, but I'm fairly comfortable with coding in general, so I should hopefully be able to help. If I can't, I'm sure there are other, better qualified people around who can do more!
 

Bale

Minion
That won't work because you need to tell it which square to adventure in at the hidden temple. It just isn't a conveniently simple zone.
 

Grotfang

Developer
What do you mean tell it which square you want? Are you sure you aren't thinking of the Hidden City as opposed to the Hidden Temple?
 

codster62

Member
Ok, looks good. But may I ask why the Equip Nurse's hat doesn't do anything? It is because of the apostrophe? Anyways, thanks for the input.
 

Grotfang

Developer
Not really. It's just that ASH works a little differently from the CLI commands you may be used to. In the CLI, "Equip" will show you your equipment and "Equip <item>" will equip whatever the item is you tell it to equip. In ASH, "Equip" is not a defined variable and you have to tell it what to equip in the right way.

What you may find easier as you try to work out ASH, is to use the CLI commands you know within your scripts until you work out their counterparts. However, again this must be done following the rules.

Code:
cli_execute("CLI command");

will do this for you. So, again, your script written in ASH, but using the CLI commands you may be more familiar with, would appear as:

Code:
cli_execute( "Equip Nurse's hat" );

cli_execute( "Equip Sponge Pants" );

cli_execute( "Equip Spongy shield" );

cli_execute( "Equip acc1 ring of half-assed generation" );

cli_execute( "adventure 40 hidden temple" );

if health =< 20 

cli_execute( "buy Doc Galaktik's Ailment Ointment");

cli_execute( "use Doc Galaktik's Ailment Ointment" );

Please note though, this script will not do what you want it to at this point. All I have done is turned your CLI commands into a form that ASH understands (in principle). Next you must think about the order you want the script to do things in. For example, you are telling mafia to adventure 40 times in the hidden temple, then check to see if your health is less than 20 and act accordingly. Surely you want to do this after every adventure?

A side note: notice that every statement/line ends with a semi-colon. This is crucial. The semi-colon is a programming way of adding a full stop. In the same way you would close every full sentence with a "." when writing letters, do the same for coding with a ";".

So, thinking in a logical order, I reasoned that you would want to be checking your health after every adventure. A quick check on the wiki tells my that my_hp() is the correct function to return an integer value for health, so I used that instead of "health". Phrasing that statement correctly gave me:

Code:
if ( my_hp() < 20 )
{
cli_execute( "buy Doc Galaktik's Ailment Ointment");
cli_execute( "use Doc Galaktik's Ailment Ointment" );
}

Putting that into the code, I reasoned that the first thing you would want to do would be to equip the relevant items, then think about starting to adventure. This gave me:

Code:
cli_execute( "Equip Nurse's hat" );
cli_execute( "Equip Sponge Pants" );
cli_execute( "Equip Spongy shield" );
cli_execute( "Equip acc1 ring of half-assed generation" );

int adv_to_use = 40;

while( adv_to_use > 0 )
{
  if ( my_hp() < 20 )
  {
   cli_execute( "buy Doc Galaktik's Ailment Ointment");
   cli_execute( "use Doc Galaktik's Ailment Ointment" );
  }
  cli_execute( "adventure 1 hidden temple" );
  adv_to_use = adv_to_use - 1;
}

You can see, I hope, how this is starting to look like the script presented above. Important and hitherto unseen additions in this example are my use of "int adv_to_use" and also "while()". I'll explain these now, at least superficially. You said the intention was to adventure for 40 turns. However, you also wish to check your health between each adventure, which means that if you do not wish to use mafia's inbuilt ability to recover health, you have to treat each adventure as a separate event.

I therefore invoked an integer called (in short) adventures to use. I said that this would be forty. However, notice that after adventuring, the script subtracts 1 from this integer, meaning that after 40 adventures, adv_to_use will equal 0.

This is where "while" comes in. I have told mafia that it is only to adventure and check health while our integer adv_to_use is greater than 0. When it hits 0 (after the fortieth adventure) the script will stop.

Now, on to the more interesting stuff. I have already pointed to the kolmafia wiki; well worth a read! All of the CLI commands listed here can be turned into sensible ASH commands. They need to make sense, however and this means following the rules. All items should be designated as such by calling them "$item[item name]". Slots need to be alluded to with "$slot[equipment slot]" and locations need to be referred to with "$location[location name]". These are fairly simple and there's nothing too ambiguous. If you ever need clarification, check the wiki! See Datatype Constants for a more comprehensive list, including what can be entered within them.

My final addition to the script was to include your own adventure number in the script. This means that when your adventures (invoked using my_adventures()) gets to 0 the script will stop instead of failing. In addition, I also decided not to define adv_to_use within the script and allow the user to do so themselves according to their requirements. I therefore encapsulated the script within a function (called main) that took an integer as an argument and worked off that.

I really would recommend you try out more simple scripts. Try editing your own hiddentemple.ash script and see if you can make it work (maybe using a different technique from the one I described here). Also, read up on the wiki as you create - don't read it in a book-like manner and expect to remember it. Finally, please feel free to post more of your scripts as you make them (maybe in this thread instead of spamming too much!). Getting other people to look at your code will give you pointers on different directions and approaches you can take, as well as learning basic can and can'ts of ASH scripting.

Hope this has helped!
 

codster62

Member
Wow, this is very helpfull. i will have to read this script several times and memorize all of the functions. Some of the things are very easy to understand, such as the semi-colon after each line of code to end a statement. That is also used in C#. Also, thanks for creating this. I have been looking around for another tutorial. I will try and modify my script to make it more efficient and user-friendly. ;)
 
Top