I was chewing away at my list of Clan Bot parsing/submission functions, and decided that it'd be good for me to make a function for adding multiple items to the clan stash simultaneously.
So, I ran the debug log, and put together a function that (besides mercilessly ripping off zargon's kmail() function) multi-adds and removes a list of items from the clan stash:
The problem is that it seems to not be seeing the "if( add_items == true )", the existence of the boolean add_items, and tries to evaluate "else" as a variable (when I put that in instead of a "if( add_items == false )").
It looks like it should be working to me as-is, and the problem doesn't seem to be stemming from its location in a function library - even when isolated in its own, the problem persists. Not sure what's up here...
So, I ran the debug log, and put together a function that (besides mercilessly ripping off zargon's kmail() function) multi-adds and removes a list of items from the clan stash:
HTML:
#Now in most recent, fixed state. Still evolving though :P
boolean clan_stash_modifier( boolean add_items , int[item] additions )
{
int num = 0;
string stash_submit = "clan_stash.php?action=addgoodies";
string[int] submit_strings;
boolean operation_success = true;
string stash_html = "";
string pwd_value = password_grab();
if( add_items == true )
{
if( count(additions) > 0 ) {
foreach key, int in additions {
num = num+1;
stash_submit = stash_submit + "&qty"+num+"="+int+"&item"+num+"="+to_int(key)+"";
if( num > 10 ) {
submit_strings[count(submit_strings)] = stash_submit;
stash_submit = "";
num = 0;
}
}
}
if( stash_submit != "" ) {
submit_strings[count(submit_strings)] = stash_submit;
for steve from 0 upto count(submit_strings)-1 {
stash_html = visit_url( submit_strings[steve]+"&pwd="+pwd_value+"" );
if( contains_text(stash_html,"You did not select any items to add to the Hoard.") ) {
operation_success = false;
print( "Select an item!" , "Red" );
}
}
}
}
else
{
if( count(additions) > 0 ) {
operation_success = true;
foreach key, int in additions {
boolean working = take_stash(int,key);
if( working == false ) operation_success = false;
}
}
else
{
print( "You have to provide a list of items to remove from the Stash." , "Red" );
}
}
return operation_success;
}
The problem is that it seems to not be seeing the "if( add_items == true )", the existence of the boolean add_items, and tries to evaluate "else" as a variable (when I put that in instead of a "if( add_items == false )").
It looks like it should be working to me as-is, and the problem doesn't seem to be stemming from its location in a function library - even when isolated in its own, the problem persists. Not sure what's up here...
Last edited: