Code: Select all
void sellItems (var options, var shapes, var frames, var price, var quantity, var articles, var quantity_text, var quantity_tokens, var dialog)
{
var choice_index;
var msg;
var sell_result;
var total_price;
var isplural;
//Present the options to the player:
choice_index = chooseFromMenu2(options);
//Keep doing this until the player choses not to buy anything else:
while (!(choice_index==1))
{
total_price = price[choice_index] * quantity[choice_index];
if (quantity[choice_index] > 1)
isplural = true;
else
isplural = false;
//Inform price to player:
say("@^",
makeSellPriceString(articles[choice_index], options[choice_index],
isplural, price[choice_index],
quantity_text[choice_index]),
dialog[1]);
//See if player agrees with price:
if (askYesNo())
{
//Ask for quantity:
say(dialog[2], quantity_tokens[choice_index], dialog[3]);
//Sell everything to the party:
sell_result = sellAmountToParty(shapes[choice_index], frames[choice_index], quantity[choice_index], price[choice_index], 32, 1, true);
if (sell_result == 1)
msg = dialog[4]; //can't carry?
else if (sell_result == 2)
msg = dialog[5];
else if (sell_result == 3)
msg = dialog[6];
else
msg = dialog[7]; //not agreeable - answered no?
//Inform the player if the buy was successful:
say(msg);
}
else
say(dialog[8]);
//Present the menu again:
choice_index = chooseFromMenu2(options);
}
say(dialog[9]);
}
Also, the return dialog[0] thru dialog[9] in this function, could someone explain when each of those dialog lines are triggered? I found some of them I believe, like "not enough gold" or "not enough room" lines, but some of them I couldn't figure out where they show up. Let me know and if there are good examples of this function being used, I think it would clean up a lot of code , thanks!