Me trying to make the player only do certain things. i love being bad at this. ;-;

My code is below.

It is very messy and whatever and really not neat. i used “Triggering” as opening the fridge. any help?

Before doing something:
	If player is in Kitchen:
		if player is triggering:
			say "";
		Otherwise:
			if hunger is 1:
				say "You're still very hungry. Get to the fridge to look for food.";
				stop;
			otherwise:
				If hunger is 2:
					say "You are less hungry than before but you can still bearly walk from hungry. Get to the fridge to look for food.";
					stop;
				Otherwise:
					If hunger is 3:
						say "You can bearly walk you're that hungry. Get to the fridge to look for food.";
						stop;			
	Otherwise:
		if hunger is 1:
			say "You're still very hungry. Get to the fridge to look for food.";
			stop;
		otherwise:
			If hunger is 2:
				say "You are less hungry than before but you can still bearly walk from hungry. Get to the fridge to look for food.";
				stop;
			Otherwise:
				If hunger is 3:
					say "You can bearly walk you're that hungry. Get to the fridge to look for food.";
					stop;

I wasn’t very clear on what i needed help with. i wanted to make it so when the player is hungry, the player can only open the fridge. It’s quite messy but you might see where i’m going with it. thanks.

Since you’ve only put up part of your scenario, it’s hard to know exactly what you need. It sounds like what you want is: When a hunger variable is non-zero, the player can only go to a refrigerator object (and presumably also open it and eat things inside it).

That probably involves a lot of things that you haven’t reached yet in Writing with Inform (the documentation).

The Living Room is a room.
An enterable supporter called a couch is in the Living Room. The player is on the couch.

The Bedroom is a room. It is north of the Living Room.
An enterable supporter called a bed is in the Bedroom.

The Kitchen is a room. It is east of the Living Room.

A refrigerator is a closed openable fixed in place container in the Kitchen. Understand "fridge" as the refrigerator.

Some cheese is in the refrigerator. It is edible.
A bologna sandwich is in the refrigerator. It is edible.
Some leftover pizza is in the refrigerator. It is edible.

Hunger is initially zero.

Carry out eating:
	decrement hunger. 

When play begins:
	hunger calls in one turn from now.

At the time when hunger calls:
	say "You are suddenly [bold type]really[roman type] hungry.";
	now hunger is three.

To decide whether hungry:
	if hunger is at least one, decide yes;
	decide no.

[This could be set up as a rulebook for more flexibility.]
To decide whether (SA - stored action) is hunger-compliant:
	if SA is looking, decide yes;
	if SA is exiting, decide yes;
	if SA is getting off something, decide yes;
	let way be the best route from location of the player to the location of the refrigerator;
	if SA is going way, decide yes;
	if SA is opening the refrigerator, decide yes;
	if SA is taking something edible, decide yes;
	if SA is eating something edible, decide yes;
	decide no.

To decide whether (SA - stored action) is not hunger-compliant:
	if SA is hunger-compliant, decide no;
	decide yes.

Instead of doing something when hungry and the current action is not hunger-compliant (this is the hunger limits options rule):
	if the current action is hunger-compliant, continue the action;
	if hunger is:
		-- 1: say "You're still very hungry. ";
		-- 2: say "You are less hungry than before but you can still barely walk from hunger. ";
		-- 3: say "You can barely walk -- you're that hungry. ";
	unless the location is the Kitchen:
		say "Get to the fridge to look for food.";
	say paragraph break.
1 Like

First of all, thanks for trying to help.

Secondly, you’re right. i don’t really understand what your talking about. What i do understand though is that you pretty much have to make it so the game decides if something is capable or not and use the capability to figure out the outcome. Right?

I would appreciate to see what i need in an inform “code” format (if it isn’t already in “code format”. It just looks unusual) if possible.

Thankyou :upside_down_face:

Edit: I just put your code into inform and it worked… My brain exploded multiple times.

Edit 2: i used the concept and structure of your code to get my code to work. tysm for helping me. I also just realised i spelt barely bearly on two different occasions. again, tysm :upside_down_face:

This was the part i was working on

East of the tunnel is the air vent exit

the kitchen is east of the air vent exit

Hunger is a number variable. Hunger is 0.

The kitchen is a room. The description is "[first time]The kitchen is covered in a layer of dust. You see a conveyer belt going into a hole in the wall. It must have been giving you the food trays. You glance around the kitchen to see an oven, a stove, a fridge, and a sink. You hold on to your stomach as you fall to the floor from hunger.[only]"

Before entering tunnel:
	now Hunger is 3;

There is a oven in the kitchen.

There is a stove in the kitchen.

There is a fridge in the kitchen

There is a sink in the kitchen.

the air vent exit is a door

before going east:
	if player is in tunnel:
		say "[first time] You hit the air vent grate hard. It seems to have been old and pops off. You look out of the tunnel and see a very large kitchen.[only]";
		now hunger is 3;
		now the player is in the kitchen;
		stop;
		
Triggering is an action applying to one thing.

Understand "Open [fridge]" as Triggering.

Instead of Triggering:
	say "You open the fridge to find a few bottles of water and 3 slices of mouldy pizza. Yum...";
	Now the player is in Fridgee;
	now hunger is 0

Troggering is an action applying to one thing.

Understand "Close [fridge]" as Troggering.

Instead of Troggering:
	say "You close the door and try to forget how mouldy that pizza was.";
	increment hunger;
	increment hunger;
	increment hunger;
	Now the player is in Kitchen;

There is 3 pieces of mouldy pizza in fridgee

mouldy pizza is edible.

Understand "fridge/fridge door/fridgedoor" as the fridge

There is 2 bottles of water in the fridgee

Fridgee is a room

Carry out eating:
	decrement hunger. 
	
To decide whether hungry:
	if hunger is at least one, decide yes;
	decide no.
	
To decide whether (SA - stored action) is hunger-compliant:
	if SA is looking, decide yes;
	if SA is opening the fridge, decide yes;
	if SA is eating something edible, decide yes;	
	decide no.
	
To decide whether (SA - stored action) is not hunger-compliant:
	if SA is hunger-compliant, decide no;
	decide yes.
	
Instead of doing something when hungry and the current action is not hunger-compliant (this is the hunger limits options rule):
	if the current action is hunger-compliant, continue the action;
	if hunger is:
		-- 1: say "You're still very hungry. ";
		-- 2: say "You are less hungry than before but you can still barely walk from hunger. ";
		-- 3: say "You can barely walk -- you're that hungry. ";
	unless the location is the Kitchen:
		say "Get to the fridge to look for food.";
	say paragraph break.