Unexpected error when using a consult script

Hi people,

Can someone please tell me what I am doing wrong in the script below? I've been unable to get this ash script to work; Mafia keeps giving me unexpected error messages when I use it.

This is the .ash script:


#yetifight.ash
void main() {
string PAGEDATA = "";
repeat {
if(have_effect($effect[On the trail])==0) {
print("Casting Transcendent Olfaction...");
PAGEDATA = use_skill(1, $skill[Olfaction]);
} else {
print("On the Trail effect still active!");
#PAGEDATA = attack();
}
} until(
# general win/loss messages
contains_text(PAGEDATA, "You win the fight!") ||
contains_text(PAGEDATA, "You lose the fight!") ||
contains_text(PAGEDATA, "You run away, like a sissy little coward")
);
}


This is the CCS I call it from:


[Knott Yeti]
1: consult yetifight.ash


I've been doing a lot of reading in the forums to try to find the solution myself, but to no avail. :-\

[edit]
sorry i forgot to mention i am using build 5715 of kolmafia
[/edit]

[another edit]

excerpt from the debug log:


=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
KoLmafia r5715, Linux, Java 1.6.0_04
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Please note: do not post these logs in the KoLmafia thread. If
you would like us to look at the log, please instead email logs
to holatuwol@hotmail.com using the subject "KoLmafia Debug Log"
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Timestamp: Sun Feb 10 21:09:43 CET 2008
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.ArrayIndexOutOfBoundsException: -1
java.lang.ArrayIndexOutOfBoundsException: -1
at net.sourceforge.kolmafia.textui.Interpreter.requestUserParams(Interpreter.java:355)
at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:273)
at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:217)
at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:306)
at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:257)
at net.sourceforge.kolmafia.request.FightRequest.runOnce(FightRequest.java:638)
at net.sourceforge.kolmafia.request.FightRequest.run(FightRequest.java:672)
at net.sourceforge.kolmafia.LocalRelayAgent$CustomCombatThread.run(LocalRelayAgent.java:467)

[/another edit]
 

Veracity

Developer
Staff member
A consult script is called with three arguments. Therefore, you'd generally have the following:

Code:
void main( string round, string encounter, string responseText )

Now, when KoLmafia wants to pass more parameters to a function than it expects, it appends all the parameters (as strings) separated by spaces and passes that in as the last argument. Unfortunately, it takes the exception you are getting if the function has no last argument.

I'll fix KoLmafia so that it doesn't take the exception, but for now, you can get around it by declaring "void main( string ignored )"
 
Top