Hey, I'm very new at scripting and I've gotten stuck with the Adventure Game I'm working on. There is a drawer, that when you first open it you recieve an Inventory Item and a message. But if you close and re open the drawer, the message is repeated.
How would I go about fixing it so that once the message has been displayed once, it won't show again? I've read through the tutorial but nothing seems to be working. Can anybody help?
Check the manual under 'if'.
Basically you need a condition, where if you currently have the inventory item, or if you have already interacted with the item it will not display the message or give you a duplicate item.
This is one way you could do it:
// to be declared at the top of the page
int count = 0;
// to be put inside your interact with area
if (count==0) {
Display("You take the item");
player.AddInventory(iItem);
count = 1;
}
else {
Display("You find nothing else in the drawer");
}
Quote from: magintz on Fri 29/02/2008 12:11:54
Check the manual under 'if'.
Basically you need a condition, where if you currently have the inventory item, or if you have already interacted with the item it will not display the message or give you a duplicate item.
This is one way you could do it:
// to be declared at the top of the page
int count = 0;
// to be put inside your interact with area
if (count==0) {
Display("You take the item");
player.AddInventory(iItem);
count = 1;
}
else {
Display("You find nothing else in the drawer");
}
Thanks man, I understand it now.