Folding my Loathing Legion knife

Bale

Minion
While waiting for mafia to support folding the Loathing Legion knife, I decided to knock out a script to handle it. Sadly my script does not work and I'm hoping someone can tell me why. This will probably become meaningless in a few days when the fold command works on the knife, but I'm still curious what my problem is:

PHP:
boolean fold_knife(item doodad) {
	if(available_amount(doodad) < 1) {
		string fold_to = doodad.to_string().replace_string(" ", "+");
		for i from 4908 to 4928
			if(i.to_item().available_amount() > 0) {
				visit_url("inv_use.php?pwd="+my_hash()+"&which=4&whichitem="+i);
				visit_url("inv_use.php?whichitem="+i+"&pwd="+my_hash()+"&switch=1&eq=0&fold="+fold_to);
				return true;
			}
		return false;
	}
	return true;
}
 
Last edited:
1) The first visit_url() isn't needed
2) The folding is a GET request, so you need to use visit_url( url, false );

This works for me:
PHP:
boolean fold_knife( item doodad )
{
   if( available_amount( doodad ) < 1 ) 
   {
      for i from 4908 to 4928
      {
         if( i.to_item().available_amount() > 0 )
         {
            visit_url( "inv_use.php?whichitem="+i+"&pwd="+my_hash()+"&switch=1&eq=0&fold="+url_encode(doodad), false );
            return true; 
         }
      }
      return false;
   }
   return true;
}
 
Last edited:
You need a GET rather than a POST, using the 2-parameter version of visit_url. I just posted a patch for this on the dev forum, so I expect it will get added soon.
 
The fold command supports the Loathing Legion items as of revision 8883, which was inspired by lost's patch.
 
Well, I guess this isn't needed anymore! :)

1) The first visit_url() isn't needed
2) The folding is a GET request, so you need to use visit_url( url, false );

I suspected the first visit_url() isn't needed, but added it since the second wasn't working. Thank you for giving me that tip about it being a GET request, hopefully I'll remember to check for that next time I have a problem like this.
 
For info, I saved the text returned by visit_url("inv_use.php?pwd="+my_hash()+"&which=4&whichitem="+i); to look for the different fields to submit, and I noticed this:
Code:
<form method="get" action="inv_use.php">

Simply doing "view source code" in Firefox didn't show the source of the folding options.
 
Back
Top