So, just today I decided to start experimenting with ash a little. I have my own little farming CLI routine, and today I wrote this up to supplement it:
My question is, how can I make this an array-driven loop, instead of repeating code? It would have to be something like (to use php code):
and then just reference the appropriate parts of the array ($buffs[n][0] = item name, $buffs[n][0] = effect name). Thanks!
Code:
# get correct number of pet-buff and wasabi sinus buffs
void getKnobGoblinMoneyBuffs()
{
# using floats since they will be divided by 10 later on
float heavy_petting;
float wasabi;
# determine how many of each buff I need
heavy_petting = my_adventures() - have_effect( $effect[ Heavy Petting ] );
wasabi = my_adventures() - have_effect( $effect[ Wasabi Sinuses ] );
# get the right number of heavy_petting buffs
if( heavy_petting > 0 )
{
heavy_petting = ceil( heavy_petting / 10 );
if( item_amount( $item[ Knob Goblin pet-buffing spray ] ) < heavy_petting )
{
buy( heavy_petting - item_amount( $item[ Knob Goblin pet-buffing spray ] ),
$item[ Knob Goblin pet-buffing spray ] );
}
use( heavy_petting, $item[ Knob Goblin pet-buffing spray ] );
}
# get the right number of heavy_petting buffs
if( wasabi > 0 )
{
wasabi = ceil( wasabi / 10 );
if( item_amount( $item[ Knob Goblin nasal spray ] ) < wasabi )
{
buy( wasabi - item_amount( $item[ Knob Goblin nasal spray ] ),
$item[ Knob Goblin nasal spray ] );
}
use( wasabi, $item[ Knob Goblin nasal spray ] );
}
}
Code:
$Buffs = array(
array( 'Knob Goblin pet-buffing spray', 'Heavy Petting'),
array( 'Knob Goblin nasal spray', 'Wasabi Sinuses'),
);