I guess you should find "abs(" in farm.ash and change the name of the function.
You shouldn't have to add anything. Once I code it, BatBrain will consult this function, and refuse to throw possibly needed tower items.
You shouldn't have to add anything. Once I code it, BatBrain will consult this function, and refuse to throw possibly needed tower items.
EDIT: Thanks Winterbay for fixing the tower_items formatting on the Wiki page! I didn't know how to do that.
int historical_price(item it, float age) {
if (historical_age(it) > age) return mall_price(it);
return historical_price(it);
}
float item_val(item i) {
if (is_tradeable(i) && historical_price(i) > max(100,2*autosell_price(i))) return historical_price(i);
if (autosell_price(i) > 0) return autosell_price(i);
return 50; // don't allow non-tradeable, non-sellable items to have 0 value
}
int get_value(item which){
if (!is_tradeable(which)) {
print("'"+which+"' is not tradeable.","red");
return 0;
}
if (ivals contains which) return ivals[which];
if (mall_price(which) > max(100,2*autosell_price(which))) return mall_price(which);
return (mall_price(which)*2 + autosell_price(which)*3)/5;
}
float item_expense(item it) {
switch (it) {
case $item["fortune cookie"]: if (get_counters("Fortune Cookie",0,250) == "") return -9999999; break;
case $item["steel margarita"]:
case $item["steel lasagna"]:
case $item["steel-scented air freshener"]: if (item_amount(it) > 0) return -9999999; break;
case $item["boris's key lime pie"]:
case $item["sneaky pete's key lime pie"]:
case $item["jarlsberg's key lime pie"]: if (!can_interact() && my_level() < 13 && item_amount(to_item(excise(to_string(it),""," lime"))) == 0) return -999999;
}
if (!is_tradeable(it) && is_displayable(it)) return 9999999;
if (historical_price(it) < 100 || historical_age(it) > priceage) return mall_price(it);
return historical_price(it);
}
float it_val(item which) {
if (historical_age(which) < 3 && historical_price(which) > 0) return historical_price(which);
if (mall_price(which) > max(100,2*autosell_price(which))) return mall_price(which);
return autosell_price(which);
}
# Returns minimum mall price (or 0 if untradeable)
int min_mall_price(item it) {
if (!is_tradeable(it)) return 0;
return max(100, autosell_price(it) * 2);
}
# Quick-and-dirty way of determining item value. If the item is untradeable, will simply return fallbackValue instead.
int value_quick(item it, int fallbackValue) {
if (!is_tradeable(it)) return fallbackValue;
if (autosell_price(it) > 0 && mall_price(it) == min_mall_price(it)) return autosell_price(it);
return mall_price(it);
}
boolean isMallPriceMinimum(item gameItem) {
return (historical_price(gameItem) == 100) || (historical_price(gameItem) == (2 * autosell_price(gameItem)));
}
int recommendedSellingPrice(item gameItem) {
return (isMallPriceMinimum(gameItem) ? autosell_price(gameItem) : historical_price(gameItem));
}
> ash import <zlib.ash>; rnum(13.0/7.0,2)
Returned: 1.8600000143051147
##Error compensation two posts down##
}
> ashtest rnum(13.0/7.0)
Returned: 1.86
> ashtest rnum(98024.0/7.0)
Returned: 14,003.43
This usually shows up (for me) when BatBrain (in DAM or WHAM) or the BatRelay try to do their calculating work...> ash to_float("1.5")
Returned: 1.5
> ash import <zlib.ash> rnum(1.5, 2)
End index 3 out of bounds (zlib.ash, line 122)
Returned: void
string rnum(float n, int place) {
if (to_float(round(n)) == n || place < 1) return rnum(round(n));
# buffer res;
# res.append(rnum(truncate(n))+".");
# if (n < 0 && n > -1) res.insert(0,"-");
# res.append(excise(to_string(round(n*10.0**place)/10.0**place),".",""));
# return to_string(res);
string res=rnum(to_int(excise(n,"",".")))+".";
int decimal;
if (length(substring(excise(n,".",""),0)) < place+1) {
int extraplace = length(substring(excise(n,".",""),0));
decimal = round(to_float(substring(excise(n,".",""),0,min(length(substring(excise(n,".",""), 0)), place+1))));
res+=decimal;
while (extraplace < place) {
res+="0";
extraplace+=1;
}
return res;
}
decimal=round(to_float(substring(excise(n,".",""),0,min(length(substring(excise(n,".",""), 0)), place+1)))/10);
res+=decimal;
return res;
}
> ash import <zlib.ash> rnum(1.5, 2)
Returned: 1.50
> ash import <zlib.ash> rnum(1.5, 1)
Returned: 1.5
> ash import <zlib.ash> rnum(1.5, 5)
Returned: 1.50000
string rnum(float n, int place) {
if (to_float(round(n)) == n || place < 1) return rnum(round(n));
# buffer res;
# res.append(rnum(truncate(n))+".");
# if (n < 0 && n > -1) res.insert(0,"-");
# res.append(excise(to_string(round(n*10.0**place)/10.0**place),".",""));
# return to_string(res);
string res=rnum(to_int(excise(n,"",".")))+".";
string dec=excise(n,".","");
while(length(dec)<place+1) dec+="0";
string decimal=round(to_float(substring(dec,0,place+1))/10);
while(length(decimal)<place) decimal="0"+decimal;
res+=decimal;
return res;
}
> ash import <zlib.ash>; rnum(1.5, 2);
Returned: 1.50