Some questions from a new scripter

BleepBlorp

New member
I have an idea for a script I want to write. I'm not really a coder, but I'm not completely helpless either. I know what I want the script to do, and some idea of how to make it happen, and figure it wouldn't be a bad little project for me to spend some time on.

The problem is that I'm running into a pretty basic problem and I can't figure out what's wrong. I look at other scripts that as far as I can tell use the same function in the same way I'm trying to which run fine. But when I try to run mine I get an error.

Specifically:

Code:
Function 'mall_price( int )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (testing.ash, line 9

And this is where I'm trying to use it. Just a super basic thing to see if I can get it to work.

Code:
script "testing.ash";
import <zlib.ash>

void main() {

int price;
int itemToFind;

itemTofind = 1650;

price = mall_price(itemToFind);

print(price);

}

I try the same type of thing with some other functions, some work, and some don't. I hope someone can shed some light on my problem. I'm using build r14231, zlib is up to date etc, so I doubt that's the problem.

Thanks.
 

Darzil

Developer
You are passing in an item number, not an item. price = mall_price( $item[milk of magnesium] ); would work fine, as would mall_price( to_item( itemToFind ) );

I think that's the case anyway, I don't actually often do ash scripting.
 

BleepBlorp

New member
You are passing in an item number, not an item. price = mall_price( $item[milk of magnesium] ); would work fine, as would mall_price( to_item( itemToFind ) );

I think that's the case anyway, I don't actually often do ash scripting.

You are correct. Those both work fine.

What is the "to_item" in the 2nd example? Where does that come from?
 

BleepBlorp

New member
I have another basic question. I figure I'll just keep sticking them in this thread rather than cluttering up the board with a bunch. I tried to edit the post title to reflect this is now more general, but don't seem to have the option.


Anyway, this time I'd like to know if there is such a thing as tables or arrays in ASH? Can I set up a list of item numbers and then have a function iterate through that, rather than explicitly writing out an if statement or whatever for each item?
 

Bale

Minion
I have another basic question. I figure I'll just keep sticking them in this thread rather than cluttering up the board with a bunch. I tried to edit the post title to reflect this is now more general, but don't seem to have the option.

Putting all your questions in the same discussion/thread is a good idea. I changed your title. I had to guess what you wanted it to say. Titles are only user editable for a few hours after posting.


Anyway, this time I'd like to know if there is such a thing as tables or arrays in ASH? Can I set up a list of item numbers and then have a function iterate through that, rather than explicitly writing out an if statement or whatever for each item?

ASH has maps. Detailed information HERE.

Small example...
Code:
int[item] inventory = get_inventory();
foreach it in inventory
   if ( inventory[it] > 5 ) 
      put_closet( 1, it ) ;


Now for a much more interesting example I have handy. Let's say you want to check the mall prices for all items you can make with clip art (items 5224 to 5283), make the most expensive and put it into the mall at that price:
Code:
boolean clip_mall() {
	int tomeLeft = 3- get_property("_clipartSummons").to_int();
	if(!have_skill($skill[Summon Clip Art]) || tomeLeft < 1 || !can_interact()) return false;

	item [int] clip;
	for i from 5224 to 5283
		clip[count(clip)] = to_item(i);

	sort clip by -(historical_age(value) > .125? mall_price(value): historical_price(value));
	create(tomeLeft, clip[0]);
	print("Sell "+tomeLeft+" "+(tomeLeft > 1? to_plural(clip[0]):clip[0])+" @ "+historical_price(clip[0]), "blue");
	return put_shop(historical_price(clip[0]), 0, tomeLeft,  clip[0]);
}
 
Last edited:

zekaonar

Member
Since this is mall_price related, how do you get the buy price, or the min price in the mall? mall_price is not very accurate when it comes to low volume items.
 

lostcalpolydude

Developer
Staff member
Since this is mall_price related, how do you get the buy price, or the min price in the mall? mall_price is not very accurate when it comes to low volume items.

You don't, because that would allow someone to easily look for things like mispriced Mr. As.
 

fronobulax

Developer
Staff member
Since this is mall_price related, how do you get the buy price, or the min price in the mall? mall_price is not very accurate when it comes to low volume items.

The choice to return the fifth lowest is deliberate and by design. Work from the idea that a bot that does nothing but buy and sell in the mall is considered A Bad Idea and you will get some ideas as to why. So if you absolutely have to have the minimum price in the Mall no one here is really going to want to help you.
 

zekaonar

Member
Spidering the last sale price, avg last 7 days and volume sold last 7 days out of the wiki is probably more valuable than querying buy price, and this info couldn't be used to make a mall sniper bot. It's a shame legitimate uses of price data are discouraged to ensure there are no mall sniper bots.
 

Veracity

Developer
Staff member
It's a shame legitimate uses of price data are discouraged to ensure there are no mall sniper bots.
How, pray tell, do you suggest that KoLmafia can distinguish between "legitimate" and "illegitimate" uses of price data? Do speak up. I'm all ears!

Spidering the last sale price, avg last 7 days and volume sold last 7 days out of the wiki is probably more valuable than querying buy price
There is no way in hell that KoLmafia will query the Wiki for, well, anything. If your script wants to do that, go wild! I don't think we stop you from querying external sites. But, it's certainly not something that we have any interest in supporting natively.
 

zekaonar

Member
I'll check out CFStat, thanks!

How, pray tell, do you suggest that KoLmafia can distinguish between "legitimate" and "illegitimate" uses of price data? Do speak up. I'm all ears!

I just think there may be alternative ways to discourage mallbots without taking away useful info. Rather than provide less useful pricing information to everyone you could throttle/limit the frequency in which pricing information could be requested? If mafia makes you wait 5-10 minutes in-between requerying the buy price of the same item, then it would be hard to use built-in functionality to make a useful mallbot. I believe you already track age of the data.
 

fronobulax

Developer
Staff member
CFStat will get historical price and volume data from Coldfront. It will cache the information so Coldfront does not get hammered. I am certainly open to suggestions for improvements, especially since it is just a repacking of work done by others.

As for the reasons for reporting "accurate" prices, or not, you have not really added anything new to the debate which seems to flare up every few months. Suffice it to say there are people who disagree with the KoLmafia devs and have tweaked their own copies to bypass the current limit. At this point implementing a suggestion such as yours would probably encourage more of that because the SVN commit info would tell people exactly where to look. If you can't live with the decisions then there are several alternatives available to you but discussing them and exercising them would probably not make you any friends in this community.
 

Crowther

Active member
No one wants to play cat and mouse with mallbots. The current situation has been fairly stable for quite a while. I have my own disagreements with it, but I prefer the stability we have over the risk of ending up worse.
 
Top