[quote author=quantumnightmare link=topic=666.msg3129#msg3129 date=1167367303]
Thanks for the quick replies. When I use the code
Code:
int main(){
throw_item( $item[spices] );
return 0;
}
i get an error " ')' Expected at line 2 in file scripts\item.ash " in the graphic CLI.[/quote]Which you should
I tested out the bits of code that efilnikufecin showed. I first overrided the throw_item function as shown, on a multi of mine. When I use the int main() version of the code, I get "Too many arguments supplied Script aborted!"
Again, this should happen, stop using int main()
When I use the void main(int iround....) the CLI gets filled with combat information. By that I mean, it prints out the text that would be displayed in the browser, as well as every combat item and skill I can use that round.
Ok...even though it's reporting stuff, is it doing anything?
Then I tried testing out macman's code. While the round does display properly, and the script is accepted by mafia, the items aren't used. I'm fighting bunnies with no +ML, to get consistency. And they survived 8 rounds of seal toothing. So no dice there. And this multi is stocked with plenty of seal teeth, spices, and turtle summoning scrolls.
Yup, that's exactly what I reported happens. That code wasn't meant for you to try out, I know what happens, but to help in debugging the issue.
Anyway....
Efilnikufecin, I tried out overriding the code for throw_item, and it succeeded.
Code:
string throw_item(item tothrow)
{
print("Overridden");
return visit_url("fight.php?action=useitem&whichitem=" + item_to_int(tothrow));
}
void main(int iRound, monster eek, string sText)
{
String grab;
print("Round " + iRound);
item razor = $item[seal tooth];
grab = throw_item(razor);
return;
When in the dire warren, prints:
Visit to Mountain: The Dire Warren in progress...
Encounter: fluffy bunny
Round 1
Overridden
You gain 8 Meat
You gain 6 Strongness
Script succeeded!
So..I guess that means it's an issue with the throw_item function in mafia, right?
*Goes digging in mafia*, yup, in KoLmafiaASH.java, we have
Code:
public ScriptValue throw_item( ScriptVariable item )
{
KoLRequest request = new KoLRequest( "fight.php?action=item&whichitem=" + item.intValue() );
request.run();
return new ScriptValue( request.responseText == null ? "" : request.responseText );
}
Which according to nightmist, and my test makes sense that it doesn't do anything, because the action value is incorrect. *Goes off to report on dev forum*. Thanks for helping debug everyone.
Quantum, so until a new version of mafia is released, or until it's fixed and you download a daily build, add the throw_item function that I posted at the top of your script (you can take out the print("overridden") part. You should be able to normally use the throw_item function then. Note, that if you want to throw two items, you'll need to also have the throw_items function which is
Code:
string throw_items(item tothrow1, item tothrow2)
{
return visit_url("fight.php?action=useitem&whichitem=" + item_to_int(tothrow) +
"&whichitem2=" + item_to_int(tothrow2));
}
*I broke that up into two lines, just to not break the frames, it should be all together without all those spaces (if you copy-pasted it).