Display Case Command

macman104

Member
Thanks to elf..(sorry your names to long ;)), I made a custom ASH command.
It's:
Code:
display_add(int amount, $item[item], string shelf
There is also
Code:
display_take(int amont, $item[item])
So if you know how to edit the files, here's what you do. All changes are in KoLmafiaASH.java The idea behind the "q" check is that let's say you have an item already in your display case, or let's say you don't know where you want to add it right now, you can put "q" in there and the command will skip the part where it puts it in a case. However, right now, it still tries to add it, because in the command, if I don't put the q in quotes (I now realize this may be because I'm declaring it as a string) it tells me that q has not been defined. So it goes ahead and runs the command to put it in a shelf, and it just doesn't add it to a shelf because "q" isn't a valid shelf. So here's the code. Oh, for the shelf, its actually gets passed as the shelf number, where your first shelf is 0 and then go from there.

display_add and display_take under "public ScriptScope getExistingFunctionScope()"
Code:
params = new ScriptType[] { new ScriptType( TYPE_INT ), new ScriptType( TYPE_ITEM ), new ScriptType( TYPE_STRING) };
result.addFunction( new ScriptExistingFunction( "display_add", new ScriptType( TYPE_BOOLEAN ), params ) );

params = new ScriptType[] { new ScriptType( TYPE_INT ), new ScriptType( TYPE_ITEM ) };
result.addFunction( new ScriptExistingFunction( "display_take", new ScriptType( TYPE_BOOLEAN ), params ) );

Code to run display_add and display_take under "private ScriptValue executeLibraryFunction() throws AdvancedScriptException"
Code:
if ( name.equalsIgnoreCase( "display_add" ) )
{
DEFAULT_SHELL.executeLine("managecollection.php?pwd&action=put&howmany1=" + 		variables[0].toStringValue() + "&whichitem1=" + variables[1].intValue() + 		"&addgoodies=Put+%3E%3E");
		
if(variables[2].toStringValue().toString() == "q")
{
	return new ScriptValue( TYPE_BOOLEAN, client.permitsContinue() ? 1 : 0 );			}	

else
{
DEFAULT_SHELL.executeLine("managecollectionshelves.php?pwd&action=arrange&whichshelf" + variables[1].intValue() + "=" + variables[2].toStringValue());
return new ScriptValue( TYPE_BOOLEAN, client.permitsContinue() ? 1 : 0 );
}
				
}
			
if (name.equalIgnoreCase( "display_take" ) )
{
DEFAULT_SHELL.executeLine("managecollection.php?pwd&action=take&owmany1=" + variable[0].toStringValue() + "&whichitem1=" + variables[1].intValue() + "&takegoodies=Take+%3E%3E");
return new ScriptValue(TYPE_BOOLEAN, client.permitsContine() ? 1 : 0 );
}

Any suggesstions on how to deal with the "q" thing or other suggesstions would be appreciated.

EDIT: Aplogies to holatuwol if you would prefer I keep this functionality privite, just delete it, but it seemed pretty harmless

EDIT2: Looks like holatuwol just added a MUCH cleaner version of the display case commands to current SVN version, although lacking the shelving ability, but I can deal, thanks hola!
 
Off topic, but fits here: I can be referred to as my full name (of course), efil, NFL (read name backwards) and yep! the ever so common "elf" works to :p I do not take offense to any variations of my name.

On topic: Wether or not the functions were implemented in the newer version of KOLMafia, this very post may be enough to cause me to actually look further into the code inside KOLMafia, and better come to understand it. As you know, before you can write a letter in french, you must first be able to read french.
 
Top