More library funtions wanted

raorn

Member
It would be nice if those KoLmafia internal functions would be available directly from ASH:

FightRequest.getCurrentRound();
EquipmentDatabase.equipStat();
FightRequest.alreadyJiggled();
KoLConstants.inventory as array/iterator, direct or slot/type-based.
 

holatuwol

Developer
The current round is passed as a parameter to consult scripts.

EquipmentDatabase.equipStat() just tells which stat is required to equip a weapon or item, not how much of that stat is needed.  You can use can_equip() to tell whether or not you can equip a given item.  Not sure what you want this function for?

I don't see why anyone would need FightRequest.alreadyJiggled().  (Inside of a custom combat script, the script would be the one doing it, not KoLmafia.) You'd have to give a case example of where you want it and what you're having to do in order to get it, because I believe it's trivially possible using the existing code, and if it's not actually needed, I'd rather not expose more functions and make ASH more bloated.

In the next release of KoLmafia, you can get your inventory as an int [item] map using get_inventory().
 

raorn

Member
[quote author=holatuwol link=topic=1552.msg7266#msg7266 date=1203548285]
The current round is passed as a parameter to consult scripts.[/quote]
But not to relay overrides.

Not sure what you want this function for?
To check if I can use Spectral Snapper and other weapon-dependent skills (fight_buttons.ash). Also it could be useful to check if two items can be equipped together (Maximize.ash).

I don't see why anyone would need FightRequest.alreadyJiggled().
fight_buttons.ash again ;-) This could be done by checking page buffer, but library function is faster/easier.

In the next release of KoLmafia, you can get your inventory as an int [item] map using get_inventory().
Great! This would greatly speedup Maximize.ash I guess ;-)

Next, AFAICS, everyone is reimplementing his own min() and max() functions. This could belong to runtime library as well.
 

holatuwol

Developer
I don't see why a relay override script needs the round number, but like FightRequest.alreadyJiggled(), it can be determined from the page that KoLmafia returns to the script.

Based on your example use, you can use ranged_weapon(item) for the same information. Adding another function doesn't seem necessary to me. You need to come up with a better reason why I should make RuntimeLibrary harder to manage, after we've taken so much effort to split it apart and make it small. =)

I'm rejecting your request for FightRequest.alreadyJiggled() for the reason noted previously. Again, you need to come up with a better reason why I should make RuntimeLibrary harder to manage, after we've taken so much effort to split it apart and make it small. =)

Ideally, min/max would take a variable parameters, and we've been holding off on implementing it until we come up with an interesting way to implement it, and given the outrage that happens each time I change method signatures, I'd prefer to have an interesting implementation the first time, rather than have a function which could just as easily be included in some kind of forum-standardized "stdlib.ash" or something.
 
[quote author=holatuwol link=topic=1552.msg7269#msg7269 date=1203552319]
Based on your example use, you can use ranged_weapon(item) for the same information. Adding another function doesn't seem necessary to me. You need to come up with a better reason why I should make RuntimeLibrary harder to manage, after we've taken so much effort to split it apart and make it small. =)
[/quote]

The ranged_weapon(item) function can't distinguish between muscle and mysticality weapons. This came up when my own maximize.ash script tried to equip a chefstaff and a sword of static at the same time. A myst_weapon(item) function would probably be an easier way to solve the problem, though.
 

holatuwol

Developer
Based on what I'm hearing, ranged_weapon no longer serves any useful purpose, and people would prefer something that returned the stat used to equip a weapon instead.  Is that correct?

Update: Okay, I've removed ranged_weapon, and provided a changed weapon_type(item) to return a $stat[] object which tells you which stat is used to equip the weapon.  In the event that it's not a weapon, this method should return $stat[none].
 

raorn

Member
[quote author=holatuwol link=topic=1552.msg7269#msg7269 date=1203552319]
Again, you need to come up with a better reason why I should make RuntimeLibrary harder to manage, after we've taken so much effort to split it apart and make it small. =)[/quote]
Two reasons, make scripts simplier and make scripts faster. But of course RuntimeLibrary stability takes precedence

some kind of forum-standardized "stdlib.ash" or something.
In this case I will be happy too ;-)
[quote author=holatuwol link=topic=1552.msg7271#msg7271 date=1203559218]
Update: Okay, I've removed ranged_weapon, and provided a changed weapon_type(item) to return a $stat[] object which tells you which stat is used to equip the weapon. In the event that it's not a weapon, this method should return $stat[none].[/quote]
What about old weapon_type()? How do I know if this Mox weapon crossbow or not?
 

Paragon

Member
Um... I am not sure if I agree with range_weapon(item) being useless... unless all moxie weapons are now, and will (likely) forever be ranged weapons. If that is true then range_weapon(item) probably is useless. However weapon_type is still useful as returning the type of weapon it is (crossbow,sword, etc.) If I were to make any changes I would proably replace string weapon_type(item) : Which returns sword, crossbow etc.. with string item_type(item) which would accept any type of weapon and return things like Sword, crossbow, shield, off-hand, booze, food, combat item etc. And create a new function weapon_stat(item) which returns the muscle, myst or moxie (of course this one would complety replace ranged_weapon if all moxie weapons are ranged.)

But that's just my two cents, and I am sure you know better than me what is possible and what you are willing to do.
 

holatuwol

Developer
[quote author=Paragon link=topic=1552.msg7281#msg7281 date=1203608036]... with string item_type(item) which would accept any type of weapon and return things like Sword, crossbow, shield, off-hand, booze, food, combat item  etc.[/quote]
Other than marking combat-usable items in some special way, this is done.
 
Top