Creating a lasting or permanent change to how a game operates

Please forgive my ignorance of the fine details of Inform, it’s been many years and several versions of the program since I first tried writing a game in it.

I was considering making an introduction to the game that would appear before a menu of options. One that could be viewed again if desired, but by default would appear only the first time the game was ever run, and that would have to be specifically selected on the menu to be seen again. On subsequent activations of the game, the menu would appear instead.

Is there any way to accomplish this in Inform? My reading of the documentation provides ways to alter variables within a game, but I haven’t noticed any way to alter something outside of the game’s world in a lasting fashion. Or if I came across it, I didn’t understand.

1 Like

I don’t think this is possible in Inform 7 (edit: I stand corrected!). What you can do is bundle the game with a feelie that has the introduction with it. This tradition is a callback to physical feelies and many games do include something like this.

You can write an external file after showing the introduction the first time, then check if that file exists on future runthroughs to see if you should show the introduction again. It’s a little finnicky, but it should work for this.

External files like this are usually used for things like achievements or high scores that should persist across playthroughs.

4 Likes

You could write information to an external file, but the vagaries of different systems, interpreters, make things harder to guarantee than it might be for a game that stays inside the VM. If I sound wishy-washy, it’s only because the tactic doesn’t enjoy a lot of conversation (use?) around here.

With that said, I do a file write with my story mode extension (as a pre-check for Daniel Stelzer’s autosave) and I haven’t had any trouble with that.

https://zedlopez.github.io/i7doc/WI_23.html#section_11

1 Like

So the solution is to make something roughly analogous to a save file. Data outside the bounds of the game, but generated in response to it, and stored (presumably) in the same location the game’s data is being kept.

Thanks to all who replied.

1 Like

Yup, exactly – the relevant bits of the docs start here.

2 Likes

I know many people have already answered, but I wanted to show an example of how it worked for a game I worked on with collaborators called If You Had One Shot:

It’s a tiny game with a single move, but once you play it you can never change your choice, so every time you restart the game it automatically ends with text based on your previous choice.

It’s small enough that I can post the whole source code here:

Source code
"If You Had One Shot" by Wade Clarke, Victor Gijsbers, Hanon Ondricek and Brian Rushton

Release along with an interpreter.
Release along with cover art.

Include Basic Screen Effects by Emily Short

Important-flag is a kind of value. The important-flags are music-flag, hole-flag, bomb-flag, and fire-flag.

When play begins:
	if the File of Ghosts exists, read File of Ghosts into the Table of Irreversible Things;
	if there is a fated value of music-flag in the table of irreversible things:
		say "[banner text]";
		say "[bold type]After the Moment[roman type]";
		try looking;
	otherwise if there is a fated value of hole-flag in the table of irreversible things:
		say "[banner text]";
		say "[bold type]After the Moment[roman type]";
		try looking;
	otherwise if there is a fated value of bomb-flag in the table of irreversible things:
		say "[banner text]";
		say "[bold type]After the Moment[roman type]";
		try looking;
	otherwise if there is a fated value of fire-flag in the table of irreversible things:
		say "[banner text]";
		say "[bold type]After the Moment[roman type]";
		try looking;
	otherwise:
		say "Your whole body trembles and the microphone is almost ready to drop from your sweat-slickened hands.

This is the moment. Your brother is about to make the biggest mistake of his life. There he is, sitting next to his fiancee--someone you know is a liar, a fraud, and heavily involved in criminal activity.

You're standing before the wedding party, ready to give a toast. Your jacket is stained on the cuffs; some of grandma's spaghetti, which you vomited up in the bathroom before the brunch because of nervousness.

No one has any idea how nervous you are. They're all cheering for you."

The Moment is a room. The description of the moment is "Standing on the stage, you begin to lose focus, your sight blurring. It feels like your head is about to burst.

Then your mind opens.

Everything stops, and the future becomes clear to you. You can see four different paths open in front of you:

-To the [bold type]north[roman type]:  You let it go, drop the mic and surrender to the music.[line break]-To the [bold type]east[roman type]: You escape. Better to roam the world alone than choose either option.[line break]-To the [bold type]south[roman type]: You drop the bomb. You expose the fiancee for the criminal she is.[line break]-To the [bold type]west[roman type]: You burn it all down by proposing to the fiancee yourself.

[bracket]Make your choice carefully: There's no going back.[close bracket]"

Table of Irreversible Things
fated value
an important-flag
with 1 blank row.

The File of Ghosts is called "ghosts".

Instead of going nowhere:
	if the noun is north:
		say "You didn’t even have the balls to speak up during 'If any person here knows of any lawful impediment to this marriage…speak now or forever-' Which would have been the correct time to make this choice, before it was final, signed, legal…before they kissed under the veil…

A deep breath and a smile buffer back the tears that aren’t worth it. There’s literally nothing you can do and no other emotion you can embody fully. An attempt to explain all your problems and their problems and embarrassing yourself and ruining the reception and becoming an amusing anecdote that people will relay to their shocked friends for decades is an enormous burden. Everything is already so heavy…

There are people holding up phones so it’s even going on the internet. Do you want to go viral? Whether it works or not it’s–

You absently take a sip from your wine glass since your throat is so dry and you need to say something. Whoops, probably not correct to drink at the beginning of the toast…

'I did have a whole speech prepared, but I’ve decided I actually just want to say this-' you flinch as the mic feeds back for an instant before the DJ turns it down. You tear one of the dinner menus scattered about on the head table into a couple pieces halfheartedly - which is just stage-business: it does not have any speech notes on it since you originally planned not to be at this juncture after wussing out on the 'speak now or forever' moment - but this feels right: 'What I actually want to do is wish the happy couple all the best of luck on this…path they’ve chosen for themselves and hope it leads them to happiness. To the happy couple:'

There are some scattered shouts of 'woo!' as you drain the rest of your wine like a shot, blinking at the swirling motes projected by the disco ball on the ceiling for a moment. Is the world tilting? No. You’re stepping off the iceberg. There is a smattering of applause and everyone drinks. It’s over. Mic-drop. 'Anybody want to DANCE?'

The room erupts in cheers and applause.";
		choose a blank row in the Table of Irreversible Things;
		now the fated value entry is music-flag;
		write the File of Ghosts from the Table of Irreversible Things;
		end the story saying "You have made your choice.";
	otherwise if the noun is east:
		say "'What would Jesus do?' you say into the mic. 'That’s what our mother always asked, dear mom, when she was still alive. Remember that, Johnny?' Your brother smiles and nods. Many in the audience smile and nod. 'Dear mom. But you know. For me that’s not a happy memory. I always feared that question. No, not feared. I hated it. Hated it!'

You look around the room fiercely. People look at you quizically, some shift uncomfortably in their seats.";
		carefullpress;
		say "[line break]'It’s not that I didn’t want to walk the right path. And it’s not that I didn’t love Jesus, because, to be honest, I think I love him way more than at least half the people in this room.' You stare at your bother’s fiancée, but she just smiles back at you. Shameless woman. 'But I always thought – inside, I mean, I never worked up the nerve to talk to mom about this – I always thought, Jesus, I mean, he was the son of God, he was God himself. I mean, how could I do what he would do? It’s like asking me to do what Superman would do, only worse. Superman would just stop the runaway train with his bare hands. But I can’t do that! I just can’t, you know?'

You wipe the sweat from your face with a linen cloth.";
		carefullpress;
		say "[line break]'And neither can any of you! It’s impossible to help other people the way Jesus did! We can’t even solve our own problems, like like, well, for instance, like Uncle Joey over there, with his gambling, and Clarice and Henry, yes, that’s you I’m looking at, who fight over the same old stuff each night until the neighbours call the police, and you, Charlie, we all know that you can’t keep your hands off the young waitresses in your diner and that’s why there’s new ones every few weeks, and and …'

Several people are standing up, angry, shouting, and the master of ceremony comes forward with a wrathful face, clearly planning to take the mic away from you. You rush to say your last words.";
		carefullpress;
		say "[line break]'And so, if we can’t even solve our own problems, we sure can’t solve those of others! So brother, good luck, it’s gonna be hell for you, this marriage, but I know I can’t fix it. Goodbye!' And with those words you run away from the stage, into the wide wide world, which suddenly seems much more awfully godless than it was ever before.";
		choose a blank row in the Table of Irreversible Things;
		now the fated value entry is hole-flag;
		write the File of Ghosts from the Table of Irreversible Things;
		end the story saying "You have made your choice.";
	otherwise if the noun is south:
		say "You nervously tap the mic. 'Is this thing on?' you ask, the reverb screeching through the room.

A stranger you don't even know shouts, 'Tapping the mic can actually cause it serious damage!' Some of your brother's friends nod and murmur agreement, but he gives you a thumbs up of encouragement. It's nervewracking being the only one here to represent your family.

'Oh, heh,' you laugh. 'Thanks, I didn't know that.' You swallow. 'Anyway, I have something I want to say. About Jody.'

'Yeah Jody!' shouts one of her bridesmaids, and everyone claps.

You force a smile, showing your teeth. 'You see, I've learned something about Jody's career, and I really think everyone should know--'

Just then the mic cuts out.";
		carefullpress;
		say "[line break]You feel a tugging on your pants leg. It's the wedding planner, down below the stage. She holds a single finger to her lips and, facing you, pulls a badge out of her pocket. DEA. She pushes it back down and turns around.

'My apologies, we're having difficulties with the sound system,' she says, addressing the crowd. There are groans. 'Please accept a round of drinks on the house for the inconvenience.' There is rousing applause, and she pulls you out into the hallway.

'Mr. Darowski, I have one piece of advice for you. Get in your car, and leave.'

'What's the DEA doing here? Are you going to arrest Jody?' you ask. 'Is this is a sting?' you say, whispering, although no one is around you.

'Jody works for us,' she answers. 'I don't think you get what's going on here.'

That's when it all clicks in your brain. The way your brother's been taking so many trips recently. The new car. The group of friends that are always calling late at night. The same friends that are here tonight. The way that everyone else in your family stopped talking to him months ago.

'I think you should go,' she says again, and walks you out the door, past the swat team that's inching towards the door, past the line of cop cars. A uniformed officer has just begun to interview you when the shooting starts.";
		choose a blank row in the Table of Irreversible Things;
		now the fated value entry is bomb-flag;
		write the File of Ghosts from the Table of Irreversible Things;
		end the story saying "You have made your choice.";
	otherwise if the noun is west:
		say "You cough to steel yourself to speak. The sound blasts through the mic, causing most of the audience to wince. 'So, I've got your attention,' you say, drawing some laughs. 'I thought I'd be talking mostly about my brother today, and I will be. But in another truer way, I won't.' There's confused murmuring from the audience.

'Alright, Spencer!' your friend Dave shouts into the quiet with misguided enthusiasm.

You turn to the bride, Jody, rotating purposefully on the spot with the microphone clasped in front of you like a weapon. It might as well be one, what with the rampant criminality you know she's into. The rampant criminality you need to save your brother from. Jody holds your gaze, her eyebrows beginning to travel north.

'I'm going to talk about me and Jody,' you say. 

As discreetly as is possible but with her teeth gritted, Jody starts making throat-slashing motions, the universal sign language for STOP.";
		carefullpress;
		say "[line break]'Jody and I have secretly been in love for a year. Jody's very good at secrets, aren't you Jody? But now it's time to bring it all into the light. What do you say, Jody? Will you marry me instead?'

Dave breaks the silence with hysterical laughter and slow clapping, alone and mistaken in his belief that you've landed the ultimate wedding joke.

'What are you doing?' shrieks Jody, flying to her feet.

Your brother gives you a non-comprehending look, then another to Jody. And yet, with Jody's flirtatious manner very well known to all present, you can already tell from your brother's face that he's given some credence to your lie.

The chaos you were aiming for is what comes after Jody's screams, with people rising and yelling and arguing, and the bridal party starting to fight, and others pushing to get at you but failing, and someone splattering your back with the contents of a vase of roses. One thing's for sure: Nobody's getting married today.

You duck out the exit behind the stage's left wing. It pains you that that was probably the most expensive way you could have derailed the marriage. If you ever have to do this again, you'll be sure to interfere in the relationship much earlier.";
		choose a blank row in the Table of Irreversible Things;
		now the fated value entry is fire-flag;
		write the File of Ghosts from the Table of Irreversible Things;
		end the story saying "You have made your choice.";

[Rule for printing the player's obituary: 
	say line break; 
	center "[bold type]You have made your choice[roman type]"; 
	say line break; 
	carefullpress; 
	stop game abruptly; 
	rule succeeds. ]

To carefullpress:
	say "[line break]     (press any key)[line break]";
	wait for any key;

Before doing something (this is the blocking rule):
	if the File of Ghosts exists, read File of Ghosts into the Table of Irreversible Things;
	if there is a fated value of music-flag in the table of irreversible things:
		say "You’re on the dance floor, grooving with abandon and rhythm you didn’t know you were capable of: …all eyes on me in the center of a ring just like a…

Maybe it’s the alcohol, but you’re dancing in a manner you’ve never felt qualified to own before. Who cares? All that burden fell off your shoulders with a carefully-chosen shrug of indifference. Not you. You’re not going back.

You’ve wanted to make that choice for so long that it’s almost overwhelming to step onto a new and different path which has in turn immediately opened up other possibilities you hadn’t thought about: You can date other people. You can accept that promotion that requires you to move because it’s no longer important for you to hang around and be your brother’s keeper or save yourself for her anymore. He’s a grown up making his own choices, and so are you.

Your karma is clear. Your brother’s problems are not your own; she is no longer your concern as a married woman. He’s an adult making his own mistakes which are not yours. You don’t need that, and you definitely don’t need her. You can no longer remain mired ankle deep in their mud, waiting for an opportunity when you are yourself a person who has the same agency. No time to look back.

You manage to dance with and meet three potential new friends (one an attractive guy!) securing two phone numbers in the process.";
		end the story saying "Your fate is your own." instead;
	otherwise if there is a fated value of hole-flag in the table of irreversible things:
		say "You don’t know what happened to your brother and his fiancée; your family has cut off all contact with you. And who can blame them? Not that you think about any of them much anymore. All you do is wander the Earth, doomed, forgotten, the loneliest man in the world – for there is no worse loneliness than this knowledge that you cannot help anyone, that there is no one who needs you.";
		carefullpress;
		say "[line break]But one day, perhaps, in the fullness of time, you will find by the side of the road a man who was left half dead by robbers, and whom all the priests and Levites pass by. Could it not happen, then, that you bind up his wounds, pour on oil and wine, bring him to an inn? And that, as you part, the man looks at you and says, smiling: 'Simon of Cyrene carried my cross. Saint Veronica wiped the sweat off my face.'";
		end the story saying "You have made your choice." instead;
	otherwise if there is a fated value of bomb-flag in the table of irreversible things:
		say "The trial has been in the news for weeks. The cops tried to implicate you at first, but an extensive search of your phone records and computer search history led them to believe you were just clueless.

Your family still can't get over the fact that you went to the wedding. 'You should have seen this coming,' says your dad. 'Did you really think Jody was the one dealing drugs?' texts your mom. Your cousin keeps sending you crying laughing emojis.

'At least Grandma still loves me,' you think, digging into a piece of pie she sent home. Your phone beeps; a reminder that you have to pick up Justine, the DEA agent that you met at the wedding. For your third date you're going to the movies. Something your grandma said echoes in your mind: 'Every time a door closes, another door opens.' ";
		end the story saying "You've made your choice." instead;
	otherwise if there is a fated value of fire-flag in the table of irreversible things:
		say "Your first conversation with your brother after the wedding didn't begin well. He threw you across the room.

With that out of the way, and before he could bean you with a gleaming chrome toaster of a wedding gift, you managed to start blabbing out the explanations.

You told him all about Jody's weird and obviously criminal behaviour that he'd missed. The weird deliveries you saw her make. The weird car journeys she'd take to remote motels that you followed her on. The way she'd hang out with bikers and drug dealers on street corners while weirdly dressed as a biker. And how she'd scarf down greasy fast food with all these weirdos even though she professed to be a health nut.

Your brother never noticed any of this because he spends all day making pizzas at that stupid restaurant. His response was, 'I thought she was out delivering medical supplies to needy hospitals.'

Given the nature of the accusations, he had to confront Jody. You don't know what that conversation was like (yeesh!) but they're no longer hitched and Jody cleared off.

Later, you hear a rumour that Jody was an undercover cop, and that you are single-handedly responsible for sinking a million-dollar drug sting.";
		end the story saying "Your brother hates you, and the number of parking tickets you’re getting seems to have gone up exponentially of late. This is your life now." instead;
		

The parser error internal rule response (E) is "[actiontext]"

[Rule for issuing the response text of a response (called R):
	if the story has not ended finally:
		say "[actiontext] "]

Taking inventory is frivolous behavior.
Taking is frivolous behavior.
Removing something from is frivolous behavior.
Dropping is frivolous behavior.
Putting something on is frivolous behavior.
Inserting something into is frivolous behavior.
Eating is frivolous behavior.
Entering is frivolous behavior.
Exiting is frivolous behavior.
Getting off is frivolous behavior.
[Looking is frivolous behavior.]
Examining is frivolous behavior.
Looking under is frivolous behavior.
Searching is frivolous behavior.
Consulting something about is frivolous behavior.
Locking something with is frivolous behavior.
Unlocking something with is frivolous behavior.
Switching on is frivolous behavior.
Switching off is frivolous behavior.
Opening is frivolous behavior.
Closing is frivolous behavior.
Wearing is frivolous behavior.
Taking off is frivolous behavior.
Giving something to is frivolous behavior.
Showing something to is frivolous behavior.
Waking is frivolous behavior.
Throwing something at is frivolous behavior.
Attacking is frivolous behavior.
Kissing is frivolous behavior.
Answering something that is frivolous behavior.
Telling something about is frivolous behavior.
Asking something about is frivolous behavior.
Asking something for is frivolous behavior.
Waiting is frivolous behavior.
Touching is frivolous behavior.
Waving is frivolous behavior.
Pulling is frivolous behavior.
Pushing is frivolous behavior.
Turning is frivolous behavior.
Pushing something to is frivolous behavior.
Squeezing is frivolous behavior.
Saying yes is frivolous behavior.
Saying no is frivolous behavior.
Burning is frivolous behavior.
Waking up is frivolous behavior.
Thinking is frivolous behavior.
Smelling is frivolous behavior.
Listening to is frivolous behavior.
Tasting is frivolous behavior.
Cutting is frivolous behavior.
Jumping is frivolous behavior.
Tying something to is frivolous behavior.
Drinking is frivolous behavior.
Saying sorry is frivolous behavior.
Swinging is frivolous behavior.
Rubbing is frivolous behavior.
Setting something to is frivolous behavior.
Waving hands is frivolous behavior.
Buying is frivolous behavior.
Climbing is frivolous behavior.
Sleeping is frivolous behavior.

Instead of frivolous behavior:
	say "[actiontext]"
	
To say actiontext:
	say "The only action allowed in the game is going in a direction. You can type North, East, South, or West, to move in a direction."
	
The immediately undo rule response (B) is "You made your choice[one of][or]. There's no going back[stopping]."
6 Likes