Request with a reward!

Can I ask you a question? I've noticed that you sometimes seem to add functions onto the ends of variables separated by a "." and that puzzles me. Does tosell.append(", ") differ from append(tosell, ", ")? Is there some benefit to one over the other? What rules govern this transposition and when is it not legal to do so?

In Java, you can execute methods of an object's datatype (and everything including strings are objects) by simply adding a "." and the method name to the end of the object. For example, if I had a class called Dog which had a bark() method, I could create a dog object called Fido and say:
Code:
Fido.bark();
which would do whatever the bark method did specifically to Fido. Does that make sense?
 

Bale

Minion
That makes perfect sense. Thanks for the information about Java, but apparently that does not apply to ASH despite cosmetic similarity.
 

Theman123

New member
Nah Bale im gonna use your script when i wanna acsend so was ur name?

Anyway i tried to use the script but it didn't work.... can someone make it a .ash for me? i tried but im using mac and i don't know how to use it... hehe... Thanks for all the help!
 

Bale

Minion
You want to use my script when you ascend? Sure, but realize that it will get rid of absolutely everything in your inventory that isn't marked as a memento. Here you go and BEWARE because it will get rid of Mr Items along with everything else if you really want to do that. The only way to save something is to make it a memento!

I'm a little concerned that I might have misunderstood you, so please be sure your inventory is disposable before running this. I've attached the ash script to this reply.
 

Attachments

  • after run sell all.ash
    3.2 KB · Views: 25

zarqon

Well-known member
ASH files are just basic text files. You can make/edit them in Text Edit.

Anyway, here you go.
 

Attachments

  • sellstash.ash
    462 bytes · Views: 23

giraffe man

New member
Code:
int amt;
buffer tosell;
for i from 1 to 4000 {
   item it = to_item(i);
   if (is_tradeable(it) && stash_amount(it) > 50) {
      amt = stash_amount(it)-50;
      if (take_stash(amt,it)) {
         if (length(tosell) != 0) tosell.append(", ");
         tosell.append(amt+" "+to_string(it));
      } else print("There was a problem pulling "+amt+" "+it+" from the stash.  Stash contents may have changed.","red");
   }
}
cli_execute("mallsell "+tosell+"; undercut");

I need something like this for the clan I'm in. I've edited abit. Would this take all items more than 50 and put it in the bot's store?
 

Bale

Minion
Not quite. I think that would fail if you have more than 11 items in your stash. Also, I'm afraid there is now a bug in the original script which didn't exist at the time it was written.

Since then, item numbers in KoL have exceeded 4000. Also, a new feature was introduced to mafia that allows plural constants. Now you should use:

foreach i in $items[]

And do something to fix the problem with mallsell only being able to handle 11 items. (You'll see code for that in my post, earlier in the thread.)
 

giraffe man

New member
Code:
string tosell ="";
int queue = 0;
int total = 0;
int price;
for i from $items[] {
	item it = to_item(i);
	if (is_tradeable(it) && stash_amount(it) > 100) {
		amt = stash_amount(it)-50;
        if (take_stash(amt,it)) {
                          if (length(tosell) != 0) tosell.append(", ");
                          tosell.append(amt+" "+to_string(it));
                          } else print("There was a problem pulling "+amt+" "+it+" from the stash.  Stash contents may have changed.","red");
                          if (tosell.length() != 0) tosell= tosell + ", ";
		price = mall_price(it);
		tosell= tosell + "* "+to_string(it)+ " @ "+to_string(price);
		queue = queue + 1;
		if(queue == 11) {
			print("mallsell "+tosell, "blue");
			cli_execute("mallsell "+tosell);
			tosell ="";
			queue = 0;
		}
	}
}
if (tosell.length() != 0) {
	print("mallsell "+tosell, "blue");
	cli_execute("mallsell "+tosell);
}

I don't think that's right. I think I put the code in the wrong place. Is there a better way to do it?
 
Last edited:

Bale

Minion
I fixed up what you were trying to do. I also made one little addition to support the new historical_price() feature. It will speed up execution time a lot and contribute to the community by helping everyone have access to recent prices.

Code:
cli_execute("update prices http://zachbardon.com/mafiatools/updateprices.php?action=getmap"); 
string tosell ="";
int queue = 0;
int price;
int amt;
foreach it in $items[] {
	if (is_tradeable(it) && stash_amount(it) > 50) {
		amt = stash_amount(it)-50;
		if (tosell.length() != 0)
			tosell= tosell + ", ";
		take_stash(amt, it);
		if(historical_age(it) < 3) price = historical_price(it);
			else price = mall_price(it);
		price = mall_price(it);
		tosell= tosell + amt+ " "+to_string(it)+ " @ "+to_string(price);
		queue = queue + 1;
		if(queue == 11) {
			print("mallsell "+tosell, "blue");
			cli_execute("mallsell "+tosell);
			tosell ="";
			queue = 0;
		}
	}
}
if (tosell.length() != 0) {
	print("mallsell "+tosell, "blue");
	cli_execute("mallsell "+tosell);
}
cli_execute("spade prices http://zachbardon.com/mafiatools/updateprices.php");

Disclaimer: This is not tested so there might be some niggling thingie I missed, but the framework is quite sound.
 

Bale

Minion
Just for the record, in ash I never trust the output of boolean returning functions like take_stash() or use(). It seems obvious that they'd return true if they successfully do what you tell them, but that just isn't so. Too often I have been burned by them so now I won't use their output unless I verify extensively that it means what you think it does.

That's why I removed your check to see if take_stash() returned true. I suspect it will always return true, even if it fails, based on my experience with the return value of use(), eat() and others.
 

giraffe man

New member
I've tested the script and it works fine. What about this:

Code:
if (item_num != 25 && item_num != 88 && item_num != 258)
{
     #code
}

I think this make it not remove meat items. Is there a shorter way to not remove a range of items, 14-27 for example, without having to type each out individually?

Code:
if (item_num < 14 && item_num > 27 )
{
     #code
}
 
Last edited:

Bale

Minion
Sure, if you want. However you're going to have to either use $item[meat paste] or to_item(it) since it is of type item.
 

Jar of Jam

Member
Seeing as this is relative to my interests, could somebody help me out with a similar script \ relay ? What I'm interested in is having an items price ( fetched from today.txt or a similar source of mallprices ) listed next to the items autosell price and amount in the clan stash. Would appreciate any help and/or advice. Thanks!
 

mredge73

Member
Slyz's PriceAnalyser.ash could easily be modified to give advice for Clan stash items instead of current inventory.
My search skills are poor, I wish I could link it but I cannot seem to find the right keywords.
 

Jar of Jam

Member
Actually, Edge, I'd more gladly use your script for this, since compared to the original, it works way faster. I even found that one of the script functions ( string ListItems(int [item] Closet, int mode) ) gets the stash contents with the right argument, but since I'm quite bad at any kind of coding, I'm having hard time figuring it out. If you could just give me a little nudge in the right direction, I'd be grateful.
 

mredge73

Member
Mine took advantage of ItemsofLoathing pricing information. That is no longer available due to it shutting down.
But since it is super easy to edit this simple function, here it goes:
Download MrEdge73's Support Script -- Item Lists (Beta).ash
Replace the PriceAnalyzer function on the bottom with this:
Code:
void PriceAnalyzer()
{
    //LoadOfLoathingMap("http://items.ofloathing.org/today.txt","ItemsOfLoathing.txt");
    LoadPriceMap("MMM Prices.txt");
    int AutoSellAllBelow=getvalue($item[twinkly wad]);
    buffer table;
    int total=0;
    table.append( "<TABLE BORDER='1' CELLPADDING='2'>" );
    table.append( "<TR bgcolor='#33CCCC'>" );
    table.append( "<TD align='center'><B>Items</B></TD>" );
    table.append( "<TD align='center'><B>Mafia Mall Price</B></TD>" );
    //table.append( "<TD align='center'><B>Items Of Loathing Price</B></TD>" );
    //table.append( "<TD align='center'><B>Average Mall Price</B></TD>" );
    table.append( "<TD align='center'><B>AutoSell Price</B></TD>" );
    table.append( "<TD align='center'><B>Recomendation</B></TD>" );
    table.append( "</TR>" );
    
    foreach i in $items[]
    {
        //if(is_tradeable(i) && haveItem(i))
        if(is_tradeable(i) && stash_amount(i)>0)
        {
            table.append( "<TR bgcolor='#ddb1ec'>" );
            table.append( "<TD align='left'>"+i+"</TD>" );
            table.append( "<TD align='center'>"+MyPrice(i)+"</TD>" );
            //table.append( "<TD align='center'>"+getvalue(i)+"</TD>" );
            //table.append( "<TD align='center'>"+getvalue(i)+"</TD>" );
            table.append( "<TD align='center'>"+autosell_price(i)+"</TD>" );
            
            if (getvalue(i)<AutoSellAllBelow)
            {
                //total=total+item_amount(i)*autosell_price(i);
                //table.append( "<TD align='center'><font color='red'>AutoSell "+item_amount(i)+" for "+item_amount(i)*autosell_price(i)+"</font></TD>" );
                total=total+stash_amount(i)*autosell_price(i);
                table.append( "<TD align='center'><font color='red'>AutoSell "+stash_amount(i)+" for "+stash_amount(i)*autosell_price(i)+"</font></TD>" );
            }
            else
            {
                //total=total+item_amount(i)*getvalue(i);
                //table.append( "<TD align='center'><font color='green'>MallSell "+item_amount(i)+" for "+item_amount(i)*AvgPrice(i)+"</font></TD>" );
                total=total+stash_amount(i)*getvalue(i);
                table.append( "<TD align='center'><font color='green'>MallSell "+stash_amount(i)+" for "+stash_amount(i)*AvgPrice(i)+"</font></TD>" );
            }
            table.append( "</TR>" );
        }    
    }
    
    table.append( "</TABLE>" );
    table.append("<font color='green'>Following Recomendations you can make "+total+" meat.</font>");
    string[int] logfile;
    logfile[1]=table.to_string();
    Map_to_file(logfile,"InventoryAnalysis.html");
    print("Check your Data Folder for InventoryAnalysis.html","blue");
}

Run MrEdge73's Support Script -- Item Lists (Beta).ash
Check your Data folder
Enjoy
 
Top