Hmm...
I think that Kurt might want that to carry between different pay for info stores, selling different information, so you would want to store the value donated in a global variable, and make a global function to give the item when that amount reaches a specific amount.
If you rely on Screen->D to hold the value of payments, and Kurt wants this to carry between info shoppes, that won't work; but he also didn't specify that point.
import "std.zh"
import "stdExtra.zh"
import "string.zh"
import "ffcscript.zh"
const int DONATION_VALUE = 500; //Set to value in rupees that is needed to activate free item.
const int DONATION_ITEM = 51; //Set to item to give for global donations as a reward.
int donationTotal;
// D0: Index of the Screen->D variable to store donation amount
// Can be shared between multiple tiles of different amounts
// D1: The amount to donate
// D2: The total amount of money before getting the reward
// D3: Reward item
// D4: Message to play when donating
// D5: Message to play when you get the item
// D6: Set to 1 or higher, if donation count, and reward aren't global.
// i.e. A special reward for each individual info shoppe.
// Set to 0 for global only.
// Set to 1 for this shoppe only.
// Set to 2, to be for this shoppe, and global.
ffc script donationTile{
void run(int d, int amount, int total, int reward, int successMessage, int itemGetMessage, int onlyHere){
// Find out how much has been donated so far
int startingAmount = Screen->D[d];
// Until all the money has been donated,
// or money has been donated since entering the screen
while(Screen->D[d] < total && Screen->D[d] == startingAmount){
// If Link touches FFC and has enough money
if(DistanceLink(this) < 8 && Game->Counter[CR_RUPEES] >= amount){
Screen->Message(successMessage);
Game->Counter[CR_RUPEES] -= amount;
Screen->D[d] += amount;
donationTotal += amount;
// If the money exceeds the total
if ( onlyHere == 0 ) {
if( donationTotal >= DONATION_VALUE ) {
WaitNoAction(60);
holdUpItem(DONATION_ITEM, true, true, true);
Screen->Message(itemGetMessage);
}
}
else if ( onlyHere == 1 ) {
if(Screen->D[d] >= total){
WaitNoAction(60);
holdUpItem(reward, true, true, true);
Screen->Message(itemGetMessage);
}
}
else if ( onlyHere == 2 ) {
if(Screen->D[d] >= total){
WaitNoAction(60);
holdUpItem(reward, true, true, true);
Screen->Message(itemGetMessage);
}
if( donationTotal >= DONATION_VALUE ) {
WaitNoAction(60);
holdUpItem(DONATION_ITEM, true, true, true);
Screen->Message(itemGetMessage);
}
}
// Draw amount below FFC
Screen->DrawInteger(0, this->X, this->Y + 24, FONT_Z1, COLOR_WHITE, -1, 16, 16, amount, 0, OP_OPAQUE);
Waitframe();
}
this->Data = 0;
}
}
(The 'just in case' edit. )