Feature - Implemented Expose turns per craft in ASH

Cool12309

Member
I'm making a farming script and for accurate measures (mainly because papier-mache toothpicks have to be crafted) I'm making a function to grab the cheapest cost to produce an item. Since this can include crafting, and crafting can sometimes take turns, it would be important to note this instead of having mafia burn a couple dozen turns producing things and not having me noticing.

Ideally, there would be a mafia function that would let me find the cheapest way to make an item and then a separate function to grab the turns to make the item, but the first function is probably out of the scope of built-in functions. Anyways, with the turns_per_craft(item) (name patent pending) function, it would be ideal to have 2 functions (or a parameter) that would return the total turns to make the item, with and without the various turn-saving things (inigo's, rapid prototyping, thor's pliers, innaboxen, etc.). Since mafia seems to already have this functionality, it would be awesome if this could be exposed to ASH.
 

Darzil

Developer
We have (internally) public static int getAdventuresUsed( final GenericRequest request ).

Seems easy enough.
 
Last edited:

Darzil

Developer
Actually, it isn't. That getAdventuresUsed is calculating it after submitting the craft request. I should be able to make it work via Concoction, though.
 

Darzil

Developer
r15328 adds :
creatable_turns( item ) - returns number of turns to make 1 of those items, not considering free crafting.
creatable_turns( item, int ) - returns number of turns to make the number specified, not considering free crafting.
creatable_turns( item, int, Boolean) - returns number of turns to make the number specified, considering free crafting when the Boolean is true.
In this case free crafting considered is Inigo's turns, Rapid Prototyping skill, Loathing Legion Jackhammer, Thor's Pliers and Warbear AutoAnvil. Bartender, Chef and Knoll smithing are always taken into account.

As thanks you can update the Mafia Wiki with this function !
 

Cool12309

Member
As thanks you can update the Mafia Wiki with this function !

Updated with the X account. First time editing there, hope I did okay.

Also, thanks for adding this :D One minor tidbit: When I did ashref creatable, it listed "int creatable_turns( item )" twice. Don't know what's up with that.
 
Last edited:

Theraze

Active member
That was the first one he listed. A function which, when given a specific item, will return how many turns it will take to create one of those items. It should also list the other 2.
 

Veracity

Developer
Staff member
Because it was entered twice into the symbol table of library functions. Revision 15330 removes the duplicate definition.
 

Cool12309

Member
Perhaps this doesn't give quite what I intended -- it returns 0 for things like Jewelrycrafting and Wokking. Any chance that could be added?
 

Darzil

Developer
Can't replicate that: (Aftercore Sorceror with Thor's Pliers, Chef-in-the-Box)

Code:
> ash creatable_turns( $item[solid baconstone necklace] )

Returned: 3

> ash creatable_turns( $item[solid baconstone necklace], 1 )

Returned: 3

> ash creatable_turns( $item[solid baconstone necklace], 1, false )

Returned: 3

> ash creatable_turns( $item[solid baconstone necklace], 1, true )

Returned: 0

> ash creatable_turns( $item[cold hi mein] )

Returned: 1

> ash creatable_turns( $item[cold hi mein], 1 )

Returned: 1

> ash creatable_turns( $item[cold hi mein], 1, false )

Returned: 1

> ash creatable_turns( $item[cold hi mein], 1, true )

Returned: 1

Edit - Or are those things you can't do, and you're asking for an additional check whether you can make them? The internal functions return 0 for things you can't do, as you won't use up turns making them!
 

Cool12309

Member
Oh, okay -- I misinterpreted it. I assumed <element> and sour sauce took a turn to create -- it does not -- and I did not know it returned 0 for things you can't craft, which is probably for the better. Carry on.
 
Top