efilnikufecin
Member
from time to time I have found myself over-riding some of kolmafia's built-in functions with my own. Several times though I have wanted to call the over-ridden function within the function I wrote. This makes me wish there was command "overridden" which when kolmafia encounters it kolmafia would look for another function with the same name, and call it passing the same parameters or if parameters are given pass them.
examples:
refuse to buy a tiny plastic sword, but buy anything else.
if I want a spring buy a meat engine and untinker it
There may be a better name for the command, and there definitely is far better uses for it than the ridiculous spring example I have shown.
effectively the TPS blocking buy function would over-ride kolmafia's built in buy function, and the spring one would over-ride the TPS blocking one. when the command "buy(1, $item[asshat])" is encountered kolmafia would use the spring version first, then that command would call the TPS blocking version, then the TPS blocking version would resort to the built in kolmafia function which has a way to handle all items which can be bought, but we may not like how it's done.
Keep in mind that though the example appears to be an effort to squeeze a couple of extra meat out of the game, it actually is just a quickly written example.
examples:
refuse to buy a tiny plastic sword, but buy anything else.
if I want a spring buy a meat engine and untinker it
Code:
boolean buy( int quant, item tobuy )
{
if(tobuy == $item[tiny plastic sword])
{
//print an error message
return false
}
return overridden;
}
boolean buy(int quant, item tobuy )
{
if(tobuy == $item[spring] && !in_muscle_sign())
{
int onhand = item_amount(tobuy);
overridden(quant, $item[meat engine]);
cli_execute("untinker " + quant + " " + $item[meat engine]);
cli_execute("untinker " + quant + " " + $item[cog and sprocket assembly]);
cli_execute("untinker " + quant + " " + $item[sprocket assembly]);
cli_execute("untinker " + quant + " " + $item[full meat tank]);
sell_item(quant, $item[meat stack]);
return ((onhand + quant) = item_amount(tobuy));
}
return overridden;
}
There may be a better name for the command, and there definitely is far better uses for it than the ridiculous spring example I have shown.
effectively the TPS blocking buy function would over-ride kolmafia's built in buy function, and the spring one would over-ride the TPS blocking one. when the command "buy(1, $item[asshat])" is encountered kolmafia would use the spring version first, then that command would call the TPS blocking version, then the TPS blocking version would resort to the built in kolmafia function which has a way to handle all items which can be bought, but we may not like how it's done.
Keep in mind that though the example appears to be an effort to squeeze a couple of extra meat out of the game, it actually is just a quickly written example.