Broken script-ness. Help fix?

hippymon

Member
Sorry to the original creator of this script, but I do not remember nor am able to find who it was. :( But I deleted some things from it and now am not sure how to get it to work, I run 10.8 KoLmafia and when I attempt to use the script it says "Unable to invoke main." I have done this with multiple scripts and it usually comes up with this error, what is wrong with it?
 

Attachments

  • spiceloop.ash
    5.4 KB · Views: 48
Basically that script contains:

void trader()
{
item Bounty;
boolean trap;
trap = false;
if ( bounty_hunter_wants( $item[hippopotamus skin]))
{
Bounty = $item[hippopotamus skin];
trap = true;
}
if ( bounty_hunter_wants( $item[penguin skin]))
{
Bounty = $item[penguin skin];
trap = true;
}

//a crap load of invalid nested function declarations

}

see that last curly brace? It's at the very bottom of the file. it needs to be moved up close the function void trader(), then you need to write in the calls to all them functions unless that script is being imported.

What are your goals with this script?
 
No, it starts at the first command outside of a function call and completes all of them till it finds void main, then it starts handling void main.
 

hippymon

Member
Well, I really just want a script that will seel stuff to the trader, get clovers, make drinks (Superhuman), Make scrumpdidalyumptious potions.. or whatever, and put toast in DC, and some other items in mall. :| This one doesn't do all of it, but I am going to try and put some of the other junk in there. although the making of the potions I do not know how to do, can you help? Please!
 
sell stuff to trader: easy, can be done with a cli script

Get clovers: easy can be done with an already written script

Make drinks? what specific drinks? how many? Do you want to buy the stuff from the mall to make them if you don't have it? or only make what you can with current inventory?

How many potions do you want to make? what kind of potions do you want to make? do you want to only use what you have, or do you want to buy stuff from the mall to create the potions?

Toast in DC: easy

other stuff in mall: what other stuff? should the script price it? or leave the price as-is? do you want to limit sales?

mostly once I get an idea what you want to do, I will fix what you already put together, and tell you what I have done to fix it.
 

macman104

Member
[quote author=efilnikufecin link=topic=869.msg4239#msg4239 date=1177036241]mostly once I get an idea what you want to do, I will fix what you already put together, and tell you what I have done to fix it.[/quote]Only because elf is the man.
 

hippymon

Member
Well I would like it to do this if I have any of this in my inverntory:
Code:
boolean utilize_still(){
	if(my_primestat() != $stat[moxie]) {
		print("youre not a moxie class, and hence cannot use the still");
		return false;
	}
	if(stills_available() == 0) {
		print("you have no uses left at the still");
		return false;
	}
	item [item] spirits_n_mixers;
	spirits_n_mixers[ $item[grapefruit] ] = $item[tangerine];
	spirits_n_mixers[ $item[lemon] ] = $item[kiwi];
	spirits_n_mixers[ $item[olive] ] = $item[cocktail onion];
	spirits_n_mixers[ $item[orange] ] = $item[kumquat];
	spirits_n_mixers[ $item[soda water] ] = $item[tonic water];
	spirits_n_mixers[ $item[strawberry] ] = $item[raspberry];
	spirits_n_mixers[ $item[bottle of gin] ] = $item[bottle of Calcutta Emerald];
	spirits_n_mixers[ $item[bottle of rum] ] = $item[bottle of Lieutenant Freeman];
	spirits_n_mixers[ $item[bottle of tequila] ] = $item[bottle of Jorge Sinsonte];
	spirits_n_mixers[ $item[bottle of vodka] ] = $item[bottle of Definit];
	spirits_n_mixers[ $item[bottle of whiskey] ] = $item[bottle of Domesticated Turkey];
	spirits_n_mixers[ $item[boxed wine] ] = $item[boxed champagne];

	print("checking spirits, mixers, and crosby nash's still...");
	foreach key in spirits_n_mixers {
		if( item_amount( key ) > 0 && stills_available() > 0 && item_amount(key) >= stills_available() ) {
			print( "hey, you have " + item_amount(key) + " " + key );
			print( "you have " + stills_available() + " uses left at the still");
			print( "making " + stills_available() + " " + spirits_n_mixers[key]);
			return create(stills_available(), spirits_n_mixers[key]);
		}
	}
	print("hmm, you didnt have much, so I made " + stills_available() + " tonic waters");
	buy (stills_available(), $item[soda water]);
	return create(stills_available(), $item[tonic water]);
}

Also purchase and use as many delectable catalyst as I have scrumptious reagent to make scrumdiddlyumptious solution.

I would also like to add this if I could somewhere in there, it is soo long I just attached the document:
 

Attachments

  • Add.ash
    49.7 KB · Views: 41

holatuwol

Developer
Now it sounds like you're trying to get help modifying someone else's script, not help modifying your own script, and it sounds like you're trying to get someone else to do all the leg work for you without sufficient compensation, which is explicitly against the rules of this forum.

I will, however, give you the benefit of the doubt.  Where are you stuck, and what have you tried? If your answers are "I don't know" and "nothing" then I strongly recommend you start doing something to change those answers.
 

hippymon

Member
I guess I kind of am.. But shouldn't thanks for bringing it to my attention, how would I go about putting this scripts together in that case?
 

holatuwol

Developer
First, efilnikufecin proposed a solution to your original issue (the script couldn't compile) -- basically moving a curly brace in the script.  Did you try that solution, and if so, did it work?  If not, make sure to try it before asking any further questions.

Now if that worked, invoking two scripts is as easy as making sure that both are in the "scripts" folder and then selecting one from the "Scripts" menu in KoLmafia followed by selecting the other from the "Scripts" menu in KoLmafia. And that's all you have to do if you have multiple scripts, each of which do a piece of what you want.

Now, if you want a script to automatically call every single one of those individual scripts, try learning how to write simple CLI scripts that "call" other scripts by reading through this manual. Again, let us know what you tried, just so we know that you put forth some effort instead of treating the community with near-zero respect for their free time.

Finally, if you have zero programming experience, and you're not at all prepared to do modifications on your own, and you have no interest in actually learning the language (you're just trying to get a script to work the way you want it to), be sure to read these guidelines.
 

hippymon

Member
Yea, did that awhile ago.. it worked, now I am making some changes I know how to do, I have to take off soon, and will work on it more.. I have figured it out a little, will come back if I need help though, thank you all!
 

holatuwol

Developer
All right. In the event that you do have questions and repost the script for assistance, be sure to do the following:

1. Let us know what you expected your script to do.
2. Let us know what the script currently does.
3. Let us know what you have tried in order to resolve the issue.

While I come across as overly harsh at times (perhaps even this time), I hope you understand that while many members of the community may offer our time unconditionally, I strongly dislike it when those offers are not treated with any respect (namely, I'd like to see that you've invested a lot of your own time before you begin to ask others for theirs).
 

hippymon

Member
Code:
void Item_ValhallaPrep(boolean UnequipFams) 
	{
	int FamiliarID;
	cli_execute("outfit Birthday Suit");
	FamiliarID = 1;
	while (FamiliarID < 51 && UnequipFams)
		{
		print("unequipping familiar " + int_to_string(FamiliarID));	
		cli_execute("familiar.php?pwd=&action=unequip&famid=" + int_to_string(FamiliarID));	
		FamiliarID = FamiliarID + 1;
		}
	cli_execute("inv refresh");
		}
	if ( item_amount( $item[bitchin' meatcar] ) > 0 )	{	cli_execute("untinker bitchin' meatcar"); }
	cli_execute("use * penultimate fantasy chest");
	cli_execute("use * warm subject gift certificate");
	cli_execute("use * briefcase");
	put_stash(item_amount($item[yeti fur]), $item[yeti fur]);
	put_stash(item_amount($item[penguin skin]), $item[penguin skin]);
	cli_execute("autosell * 1337 7r0uZ0RZ");
	cli_execute("autosell * 33398 scroll");
	cli_execute("autosell * amulet of extreme plot significance");
	cli_execute("autosell * Angry Farmer candy");
	cli_execute("autosell * arrrgyle socks");
	cli_execute("autosell * asparagus knife");
	cli_execute("autosell * awful poetry journal");
	cli_execute("autosell * balaclava baklava");
	cli_execute("autosell * bar skin");
	cli_execute("autosell * barrrnacle");
	cli_execute("autosell * barskin hat");
	cli_execute("autosell * basic meat crossbow");
	cli_execute("autosell * basic meat helmet");
	cli_execute("autosell * basic meat pants");
	cli_execute("autosell * bat guano");
	cli_execute("autosell * batgut");
	cli_execute("autosell * big red clown nose");
	cli_execute("autosell * Brimstone Chicken Sandwich");
	cli_execute("autosell * bugbear beanie");
	cli_execute("autosell * bugbear bungguard");
	cli_execute("autosell * cast");
	cli_execute("autosell * chaos butterfly");
	cli_execute("autosell * charrrm");
	cli_execute("autosell * clown shoes");
	cli_execute("autosell * cocoa eggshell fragment");
	cli_execute("autosell * cog");
	cli_execute("autosell * cool whip");
	cli_execute("autosell * cranberries");
	cli_execute("autosell * crowbarrr");
	cli_execute("autosell * dense meat stack");
	cli_execute("autosell * diamond-studded cane");
	cli_execute("autosell * facsimile dictionary");
	cli_execute("autosell * disbelief suspenders");
	cli_execute("autosell * disco ball");
	cli_execute("autosell * disturbing fanfic");
	cli_execute("autosell * draggin' ball hat");
	cli_execute("autosell * Dyspepsi-Cola");
	cli_execute("autosell * empty meat tank");
	cli_execute("autosell * evil golden arch");
	cli_execute("autosell * eyepatch");
	cli_execute("autosell * f3d0r4");
	cli_execute("autosell * fat stacks of cash");
	cli_execute("autosell * foolscap fool's cap");
	cli_execute("autosell * frilly skirt");
	cli_execute("autosell * frozen nunchaku");
	cli_execute("autosell * furry fur");
	cli_execute("autosell * ghuol ears");
	cli_execute("autosell * ghuol egg");
	cli_execute("autosell * giant discarded plastic fork");
	cli_execute("autosell * giant needle");
	cli_execute("autosell * glowing red eye");
	cli_execute("autosell * gnoll lips");
	cli_execute("autosell * gnoll teeth");
	cli_execute("autosell * Gnollish flyswatter");
	cli_execute("autosell * Gnollish pie tin");
	cli_execute("autosell * Gnollish plunger");
	cli_execute("autosell * goat beard");
	cli_execute("autosell * grave robbing shovel");
	cli_execute("autosell * heavy D");
	cli_execute("autosell * helmet turtle");
	cli_execute("autosell * herbs");
	cli_execute("autosell * hippo skin buckler");
	cli_execute("autosell * hot katana blade");
	cli_execute("autosell * ice-cold Willer");
	cli_execute("autosell * ice-cold fotie");
	cli_execute("autosell * icy katana hilt");
	cli_execute("autosell * Imp Ale");
	cli_execute("autosell * infernal insoles");
	cli_execute("autosell * Knob Goblin elite helm");
	cli_execute("autosell * Knob Goblin elite pants");
	cli_execute("autosell * Knob Goblin elite polearm");
	cli_execute("autosell * Knob Goblin harem pants");
	cli_execute("autosell * Knob Goblin harem veil");
	cli_execute("autosell * Knob Goblin seltzer");
	cli_execute("autosell * Knob Goblin visor");
	cli_execute("autosell * Knoll shroomkabob");
	cli_execute("autosell * leather mask");
	cli_execute("autosell * lemon");
	cli_execute("autosell * leotarrrd");
	cli_execute("autosell * lihc eye");
	cli_execute("autosell * lihc face");
	cli_execute("autosell * line");
	cli_execute("autosell * linoleum crossbow");
	cli_execute("autosell * linoleum staff");
	cli_execute("autosell * Lord of the Flies-sized fries");
	cli_execute("autosell * los chinos");
	cli_execute("autosell * lowercase N");
	cli_execute("autosell * maiden wig");
	cli_execute("autosell * maple syrup");
	cli_execute("autosell * mariachi pants");
	cli_execute("autosell * meat engine");
	cli_execute("autosell * Meat maid body");
	cli_execute("autosell * meat paste");
	cli_execute("autosell * meat stack");
	cli_execute("autosell * meat vortex");
	cli_execute("autosell * metallic A");
	cli_execute("autosell * Mick's IcyVapoHotness Rub");
	cli_execute("autosell * miner's pants");
	cli_execute("autosell * Mohawk wig");
	cli_execute("autosell * ninja hot pants");
	cli_execute("autosell * orange");
	cli_execute("autosell * original G");
	cli_execute("autosell * pasta spoon");
	cli_execute("autosell * phonics down");
	cli_execute("autosell * Pine-Fresh air freshener");
	cli_execute("autosell * pirate pelvis");
	cli_execute("autosell * probability potion");
	cli_execute("autosell * procrastination potion");
	cli_execute("autosell * rat appendix-kabob");
	cli_execute("autosell * ravioli hat");
	cli_execute("autosell * reodorant");
	cli_execute("autosell * ridiculously huge sword");
	cli_execute("autosell * ruby W");
	cli_execute("autosell * sabre teeth");
	cli_execute("autosell * safarrri hat");
	cli_execute("autosell * saucepan");
	cli_execute("autosell * scroll of drastic healing");
	cli_execute("autosell * scroll of turtle summoning");
	cli_execute("autosell * seal tooth");
	cli_execute("autosell * seal-clubbing club");
	cli_execute("autosell * shot of tomato schnapps");
	cli_execute("autosell * skeleton bone");
	cli_execute("autosell * skeleton key");
	cli_execute("autosell * skewer");
	cli_execute("autosell * snakehead charrrm");
	cli_execute("autosell * soft green echo eyedrop antidote");
	cli_execute("autosell * Spam Witch sammich");
	cli_execute("autosell * spooky shrunken head");
	cli_execute("autosell * spooky stick");
	cli_execute("autosell * spring");
	cli_execute("autosell * sprocket");
	cli_execute("autosell * sprocket assembly");
	cli_execute("autosell * stolen accordion");
	cli_execute("autosell * stuffed shoulder parrot");
	cli_execute("autosell * sunken chest");
	cli_execute("autosell * super-spikey hair gel");
	cli_execute("autosell * swashbuckling pants");
	cli_execute("autosell * Tasty Fun Good rice candy");
	cli_execute("autosell * thin black candle");
	cli_execute("autosell * tiny house");
	cli_execute("autosell * tires");
	cli_execute("autosell * titanium assault umbrella");
	cli_execute("autosell * tomato");
	cli_execute("autosell * Trollhouse cookies");
	cli_execute("autosell * valuable trinket");
	cli_execute("autosell * wad of dough");
	cli_execute("autosell * white chocolate chips");
	cli_execute("autosell * white satin pants");
	cli_execute("autosell * whitesnake skin");
	cli_execute("autosell -1 wolf mask");
	cli_execute("autosell * wussiness potion");
	Item_Buy( 3, $item[asbestos ore] );
	Item_Buy( 1, $item[barbed-wire fence] );
	Item_Buy( 3, $item[chrome ore] );
	Item_Buy( 1, $item[batblade] );
	Item_Buy( 1, $item[disassembled clover] );
	Item_Buy( 3, $item[linoleum ore] );
	Item_Buy( 1, $item[NG] );

Ok, in this little section, I am having problems with the "Itembuy" all I want it to to is simply purchase the items from the mall, as of now it says "undefined reference" and I have tried nothing for I have no clue what to do.
specifically:
Code:
Item_Buy( 3, $item[asbestos ore] );
	Item_Buy( 1, $item[barbed-wire fence] );
	Item_Buy( 3, $item[chrome ore] );
	Item_Buy( 1, $item[batblade] );
	Item_Buy( 1, $item[disassembled clover] );
	Item_Buy( 3, $item[linoleum ore] );
	Item_Buy( 1, $item[NG] );

Also:
Code:
boolean Item_PullLairItems(boolean BuyItems)
	{
	if (BuyItems == true)
		{
		Item_Buy( 1, $item[boris's key] );
		Item_Buy( 1, $item[jarlsberg's key] );
		Item_Buy( 1, $item[sneaky pete's key] );
		Item_Buy( 1, $item[richard's star key] );
		Item_Buy( 1, $item[digital key] );
		Item_Buy( 1, $item[star crossbow] );
		Item_Buy( 1, $item[star hat] );
		Item_Buy( 1, $item[barbed-wire fence] );
		Item_Buy( 1, $item[disease] );
		Item_Buy( 1, $item[sonar-in-a-biscuit] );
		Item_Buy( 1, $item[NG] );
		Item_Buy( 1, $item[wolf mask] );
		Item_Buy( 1, $item[wand of nagamar] );
		Item_Buy( 1, $item[flaming talons] );
		Item_Buy( 1, $item[furry pants] );
		Item_Buy( 1, $item[disassembled clover] );
		Item_Buy( 3, $item[ring of increase damage] );
		Item_Buy( 1, $item[hypodermic needle] );
		Item_Buy( 1, $item[prosthetic forehead] );
		Item_Buy( 1, $item[tiny shaker of salt] );
		Item_Buy( 1, $item[sucky decal] );
		Item_Buy( 1, $item[many-eyed glasses] );			
		if (Option_FarmLairItems() == false)
			{
			Item_Buy( 1, $item[loose teeth]);
			Item_Buy( 1, $item[baseball]);
			Item_Buy( 1, $item[broken skull]);
			Item_Buy( 1, $item[razor-sharp can lid]);
			Item_Buy( 1, $item[spider web]);
			Item_Buy( 1, $item[disease]);
			Item_Buy( 1, $item[wussiness potion]);
			Item_Buy( 2, $item[orange]);
			Item_Buy( 2, $item[skeleton bone]);
			Item_Buy( 1, $item[frigid ninja stars]);
			Item_Buy( 1, $item[meat vortex]);
			Item_Buy( 1, $item[photoprotoneutron torpedo]);
			Item_Buy( 1, $item[chaos butterfly]);
			}	
		}
 
[quote author=hippymon link=topic=869.msg4249#msg4249 date=1177087719]

Ok, in this little section, I am having problems with the "Itembuy" all I want it to to is simply purchase the items from the mall, as of now it says "undefined reference" and I have tried nothing for I have no clue what to do.
specifically:
Code:
Item_Buy( 3, $item[asbestos ore] );
	Item_Buy( 1, $item[barbed-wire fence] );
	Item_Buy( 3, $item[chrome ore] );
	Item_Buy( 1, $item[batblade] );
	Item_Buy( 1, $item[disassembled clover] );
	Item_Buy( 3, $item[linoleum ore] );
	Item_Buy( 1, $item[NG] );
[/quote]

OK when you get "undefined reference" what that can mean is:
1: You have misspelled something.
2: You have forgotten to import a script.
3: When using code from other scripts it can mean that you need to return to the script that you got the code from and find another function in that script which you forgot (or didn't know) to copy to yours also.

Item_Buy was a form of an over-ride for a kolmafia built in function. I don't remember the exact purpose of the function, but in your case it probably isn't necessary. I'm sure that you can visit the Scripting Wiki and find a function that does what you expect that to do, then using your editor's find/replace replace all of the offending function calls with the one that does what you want.

Edit: I just looked at add.ash and well: :eek: how many scripts did you put together, and grab stuff out of for that? I think I see a little bit of everyone here on the forums work in there. (yes after looking at so many scripts I have an idea who wrote what just by looking at the source) You at least have some stuff from each of the most well known script writers here on the forums! Just WOW!
 

holatuwol

Developer
Or you pasted a function definition after where it's used for the first time. The fact that I see at least two void main methods further highlights just how that script was put together. :p
 
Top