Using an Instead Command to Do Multiple Things

I am working on using an instead command to do a few things at once, but I’m not sure where I’ve gone wrong, exactly (everything I’ve tried on my own since my last post has worked…but I am getting too comfortable with Inform 7, I guess). Here’s what I want to do: I have the player in a room (technically a pirate ship), and I don’t want them to be able to leave the pirate ship unless they give the captain two items (a broken compass and a mysterious tome). If they give the captain a combination of other items (either a jade koi fish & the broken compass, or the jade koi fish & the mysterious tome) I want play to end…so really, they can only continue if they give the right combination.

here’s what I came up with:

Instead of going from the wicked wench: if the player gives captain avery the broken compass and the player gives captain avery the jade koi fish: say "'We thank ye for yer contribution boy, but I can see that yer carrying a cursed item, boy,' Captain Avery says grimly. 'Cursed items on my ship will not be tolerated.' [paragraph break]'What do you mean, Captain?' you say in what can only be discerned as a frightened squeak.[paragraph break] 'Where did ye get that book, lad?' the captain narrows his eyes.[paragraph break] 'From my grandmother's library! When I picked it up, I ended up here on your ship, Captain, I swear my life on it,' you squeal. [paragraph break] 'Now, now, there's no need to be swearing what I can simply take,' the captain says as he shoots you with his pistol. 'Just as I thought. This book,' Captain Avery says to the sailors, 'be our ticket back to the real world boys. It's a portal between the world of the living and the world of the dead. We're going home, lads!'[paragraph break]As you lay on the deck, you realize that you must already be dead as there is no blood emerging from your wound; however, you still feel as though you are dying. As the world around you gets darker and darker, you realize that this must have been some kind of purgatory, and now you are slipping in to the true death.[paragraph break]You are dead."; end the game in failure; if the player gives captain avery the broken compass and the player gives captain avery the mysterious tome: say "'Now, my boy,' Captain Avery says, that be a fair trade, indeed.' The sailors nod in agreement as Captain Avery holds up the treasure he has just acquired. 'Ye could not be knowing this, lad, but we have been looking for this compass for quite some time. I'll not be asking where you got it from, but we are happy as mermaids to have it back. If ye travel north, ye will be on the shores of Astoria, and I know someone who will be paying a pretty penny for that trinket of a fish ye be carrying.'[paragraph break]'Like I said,' the captain continues, 'I'll not be asking where ye captured this loot. But good luck to you, lad. We'll be wishing you the best of luck on your adventure. If you're ever on the silver seas of Astoria again, be sure to look up old Avery and his crew, won't you?'"; continue action; if the player gives captain avery the jade koi fish and the player gives captain avery the mysterious tome: say "'That compass, boy,' The captain narrows his eyes. 'Where did ye be getting such a thing as that?'[paragraph break]'This? This compass belonged to my grandfather, and I found it in the curio cabinet in the parlor. Grandmother said I could take it. Besides, it's broken,' you say very matter-of-factly.[paragraph break]'May I see that?' the captain asks. As you hand it over, he examines it carefully. 'Just as I thought, this compass is no more broken than ye are, and it is my rightful property.'[paragraph break]'I told you that belonged to my grandfather,' you say with a bit of force. 'How can it be yours?'[paragraph break]'Did yer grandfather ever tell you where this came from, boy?' you shake your head and the captain smiles. 'I thought not,' he says. 'Ye see, lad, this compass was mine when i was alive,' the captain begins, 'and Astoria is a kind of place ye go when ye die. A kind of purgatory for heroes, if ye will. I don't claim to be a hero, and yet here i be. This may be hard for ye to here, but ye must be dead, too. It were no coincedence, son, that your father be named Henry and yer mother be named Amelia…I am yer father. Ye see the true nature of things, and I know I'm not the paragon of fathers, what with the piracy and the consumption of rum, but if ye will have me, then we can sail the seas of Astoria together.'[paragraph break]'Then I am dead, too?' you frown as a tear comes to your eye.[paragraph break]'Yes, my boy,' your father says grimly, 'But if it makes ye feel better, I have been waiting for ye for seven years, and I would rather have no one for my first mate than you, lad.'[paragraph break] Though being dead was not your first choice, you can think of worse things than having adventures on the high seas, especially with real pirates: you've always dreamed of this moment. As for your father, you were only three when he first set sail with the king's navy, and he had been at sea for five more until the day he died. You don't remember exactly what he looked like but something inside of you confirms that Captain Avery is, indeed, your father. [paragraph break]After a few moments, you pull yourself together and brace yourself for a lifetime of adventures."; end the game in victory; otherwise: say "Before you leave the Wicked Wench, you feel as though you should give Captain Avery something for his hospitality. [italic type]I can give him two of the things that I carry,[roman type] you think. [italic type]If I do that, I will still have one item to barter with later, and that should be sufficient.'[roman type]":

this instead code has worked for nearly everything else, but I don’t know if this many things complicates it too much or if I’m way off base with how I’m trying this. Any advice or suggestions are greatly appreciated. After I figure this out, I am 99% done with authoring my IF.

The condition “if the player gives Captain Avery the broken compass” isn’t grammatical (unless you define it somehow). My guess is that you want to process the command “give compass to captain avery” so that captain avery winds up with the compass. This could be as simple as

The block giving rule is not listed in the check giving it to rules.

although that would let you give anything away to anybody, and you might want to write a rule that restricts this to giving things to Captain Avery (and no more than two).

Then you can say something like

if Captain Avery carries the broken compass and captain avery carries the jade koi fish:

since Captain Avery will only have these things if you’ve given them to him. You might also want to check to make sure that the player carries the book in the first case, since it’ll seem weird to refer to the book in that way if the player has dropped it.

ETA: I haven’t checked that the rest of your code works, but that jumped out to me. Also, I think “end the game in failure” might not be valid code, though I’m not sure about that.

i have this already coded in:

The block giving rule is not listed in the check giving it to rules.

See, I knew I was trying to make things harder than they had to be. When I had “end game in failure” programmed in, it did not give me an error message for that, just that the way i had the whole instead command put in was not tabbed correctly: inform tells me “This sometimes happens even when the code looks about right, to the eye, if rows of spaces have been used to indent phrases instead of tabs.”

I will try your advice & try to figure out how to end the game that way.

Alright, I’ve worked it out in so far that I can give him two things (I made his carrying capacity 2), but I think I might still have the end play part wrong. What I have coded is:

Instead of going from the wicked wench: if captain avery carries the broken compass and captain avery carries the jade koi fish: end the game saying "'We thank ye for yer contribution boy, but I can see that yer carrying a cursed item, boy,' Captain Avery says grimly. 'Cursed items on my ship will not be tolerated.' [paragraph break]'What do you mean, Captain?' you say in what can only be discerned as a frightened squeak.[paragraph break] 'Where did ye get that book, lad?' the captain narrows his eyes.[paragraph break] 'From my grandmother's library! When I picked it up, I ended up here on your ship, Captain, I swear my life on it,' you squeal. [paragraph break] 'Now, now, there's no need to be swearing what I can simply take,' the captain says as he shoots you with his pistol. 'Just as I thought. This book,' Captain Avery says to the sailors, 'be our ticket back to the real world boys. It's a portal between the world of the living and the world of the dead. We're going home, lads!'[paragraph break]As you lay on the deck, you realize that you must already be dead as there is no blood emerging from your wound; however, you still feel as though you are dying. As the world around you gets darker and darker, you realize that this must have been some kind of purgatory, and now you are slipping in to the true death.[paragraph break]You are dead.";

but even if i give him these two items and i try to leave, it will give me an otherwise message from one of the similar combinations (the one that lets you off the ship). i just want the player to die, darn it!

“End the game in death/victory” (like “End the story --/finally (saying …)”) does not end the game until the current rule comes to an end – which means the rule tries the following conditions as well, and the last otherwise condition is met (since the Captain doesn’t carry the tome).

(The second combination of offerings to the Captain works, because the “continue the action” ends the current rule and skips directly to the next rule in line in the processing of the action.
Giving him the tome (or the koi and the tome) works, because the concluding otherwise-block will not be considered at all if the corresponding if-condition is met, so the rule ends before that last block if the Captain carries the tome.)

The solution is to put an otherwise before all the ifs but the first – or alternatively you could write “instead end the game in death” (“instead” ends the current rule without skipping to a new one).

you guys are geniuses. thank you!!!