Listing a set of things that are affecting the player

Dear all,

I remember playing Hitchhikers (the Infocom game) and the fact that sometimes it would list a set of things that you could hear, smell etc.

I would like to expand this so that when a player ‘examines me’ they get a breakdown of what is wrong (or not) with them.

For example at the start of the game they are not well at all… “You are barely concious, various parts of your body are queuing up to complain about their recent harsh treatment.”

At the start the player is also tied up and blindfolded, so I want the description to continue…" there is a tighness around your waste and a pressure over your eyes.

Coming from a traditonal coding background I know how to do this using if statements, variables and flags (tiedup would be a flag that is true if, erm, the player is tied up). However I am really struggling to figure out how to connect various conditions in Inform7. The ones I have at present are:

Awareness - full, partial, slight, none;
Location -lost, confused, unsure, confident;
Health - has a value 100 being fine 0 being dead.
tiedup yes or no
blindfolded yes or no

Could someone point me at an example, or suggest how to combine a set of descriptions so that they all display on one action, depending on a number of factors?

Many thanks

Inform has if statements, variables, and flags, so you don’t have to go too far.

This is a very rough first draft:

A person has a number called the health.
A person can be lost, confused, unsure, or confident.

The player is wearing a blindfold.

Note that health is a numeric property; the “lost/etc” condition is another property; but blindfoldedness depends on an object in the model world. (I could have written “A person can be blindfolded” but then that would have to be kept in sync with a blindfold object.)

Then we write:

Check examining the player:
	If the health of the player is 100:
		say "You feel fine";
	else if the health of the player is greater than 75:
		say "You are doing okay";
	else if the health of the player is greater than 25:
		say "You hurt";
	else:
		say "You are barely conscious";
	if the player is lost:
		say ", you are lost";
	else if the player is confused:
		say ", you are confused";
	else if the player is unsure:
		say ", you are unsure";
	if the player is wearing the blindfold:
		say ", and you are wearing a blindfold as well";
	say ".";
	stop the action.

This is not great – note the missing “and” in the last line – but you could hammer it around to produce the results that you want.

Hi,

Many thanks for this. Sadly I am getting the following errors;

Problem. The rule or phrase definition ‘Check examining the player’ seems to use both ways of grouping phrases together into ‘if’, ‘repeat’ and ‘while’ blocks at once. Inform allows two alternative forms, but they cannot be mixed in the same definition.

Problem. The phrase or rule definition ‘say “it is dark.” if the player is lost’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘say " You do not know were you are."’ , in case that helps.

… which I guess means that copying from your example has somehow stuffed some formatting (tabs?). Problem is I am used to clear block programming, curly brackets, if…then…else… endif etc and am having real difficulties untangling the block structure in your second example, or understanding the errors. Is there an explanation anywhere? I would like to stick to a simple block like structure if possible until I get my head around Inform a bit better if this is possible. Seraching in google has so far drawn a blank, but shown how much I don’t know…

If you want to preserve the tab stops you can hit “quote” under the post you’re replying to and copy the code from the box in which you’d type your reply. (Then hit “cancel,” assuming you don’t want to actually reply.) This should preserve the tab stops in most places.

But you might be happier with the “begin … end if” syntax instead of the Pythonesque indentation syntax. This is discussed a bit in section 11.7 of the documentation.

Hi,

Many thanks for the reply. Sadly I now have a complete confused mess. I cannot find an example that uses an if…begin…else if… structure and so have errors all over. my code looks like this…

Check examining the player:
	If the health of the player is 100
	begin;
		say "Your are in perfect health.";
	else if the health of the player is greater than 75
	begin;
		say "You are doing okay";
	else if the health of the player is greater than 25
	begin;
		say "You are badly hurt";
	else
	begin;
		say "You are barely conscious, bits of your body are queuing up to complain about their recent rough treatment.";
	end if.
	if the player is wearing the blindfold:
	begin;
		say "It is dark, there is a presure on your eyes.";
	else if the players eyes are closed
	begin;
		say "it is dark."
	end if.
	if the player is lost
		begin;
		say " You do not know were you are.";
	else if the player is confused
	begin;
		say "You are cannot think clearly.";
	else if the player is unsure
	begin;
		say ", you are unsure where you are";
	end if.
stop the action.

my errors (and there are pages of them) start

In a block language behaviour like this is due to a stuff-up in structure, ususally because you have not terminated a bock somewhere and so everything is out of sync. Trouble is I don’t know enough about inform to know where I have done ( or not done) this.

Any suggestions? Better still could someone provide a working example of an if…else if structure that does not use a python tab system?

You must use semicolons rather than periods in the middle of rules. In fact, you may want to always use semicolons and never use periods at all.

thanks for this. I found an Inform for programmers guide that looks like it lists a suitable if…then etc structure ( its here … http://www.ifwiki.org/index.php/Inform_7_for_Programmers/Part_1 ) and so changed my code as below.

Check examining the player:
	If the health of the player is 100 begin;
		say "You are in perfect health.";
	otherwise if the health of the player is greater than 75;
		say "You are doing okay";
	otherwise if the health of the player is greater than 25;
		say "You are badly hurt";
	otherwise; 
		say "You are barely conscious, bits of your body are queuing up to complain about their recent rough treatment.";
	end if;

	if the player is wearing the blindfold begin;
		say "It is dark, there is a presure on your eyes.";
	otherwise if the players eyes are closed;
		say "it is dark."
	end if;

	if the player is lost begin;
		say " You do not know were you are.";
	otherwise if the player is confused;
...............

This looks more like a standard block construct, though the otherwise if (elseif) clauses do not appear to nest, so it looks like I only need 1 end if, rather than one for the open if,begin and the one for each of the otherwise ifs (4 in total).

But it still doesn’t work…

I don’t know if this is a problem with the blocking of the if…begin…otherwise if… end if section or an error in the line 'if the player is wearing the blindfold - suspect the former.

Hope someone can suggest a fix

Inform 7 treats blank lines just as if they were full stops (periods). Either of them designates an end to the present rule, definition, assertion, etc.

So, inside one and the same rule you mustn’t use either periods or blank lines (except inside quoted text). Both periods and blank lines signal “new and independent logic to follow”.

Thank you for this, I had no idea that Inform was so strict! The code works, but I am once again stuck.

I’ve modified the inventory (dont like the standard) so that it does not list items if your eyes are closed or if you are blindfolded (this prevents the inventory from saying you are weaing a blindfold when you cannot see it as you are erm blindfolded. This works, but I also wanted to add a rule so that the player gets a descripton of the blindfold if they feel their eyes, and this does not.

Your eyes are part of the player. Your eyes are plural-named. Your eyes can be openable. Your eyes are openable. Your eyes can be open. Your eyes are closed. 

Instead of taking inventory: 
	if your eyes are closed begin;
		say "It is dark, something organic is obscuring your vision.";
	otherwise if the player is wearing a blindfold;
		say "It is dark,you cannot see, there is a pressure on your eyes.";
	otherwise; 
    		say "You're carrying [a list of things carried by the player][if the player wears something]. You are wearing [a list of things worn by the player][end if].";
	end if.

check feeling your eyes:
	if the player is wearing a blindfold begin;
		say "A strip of rough feeling cloth is over your eyes.";
	otherwise if your eyes are closed;
		say "You feel the delecate protective skin of your eyelids.;"
	otherwise;
		say "Ouch! Poking a finger into your eyes is not recommended.";
stop the action. 

I am getting;

Inform understands the instruction feel my eyes as a default, but am stumped as to what else I need to do to add the specific case.

Well… you could also change it so it says:

check examining the player: say "[if the health of the player is 100]You are in perfect health[otherwise if the health of the player is greater than 75]You are doing okay[otherwise if the health of the player is greater than 25]You are badly hurt[otherwise]You are barely conscious, bits of your body are queuing up to complain about their recent rough treatment[end if]."; ....

And how are your eyes defined?

I don’t have a copy of Inform here, but I think it’s possible that the command “feel” is linked to the action “touching” (with a line like “Understand the command “feel” as touching.” in the standard rules). You can test this by typing “actions on” (Um, if memory serves; it’s been way too long) from inside a working game and then doing the action, and it will tell you what actual action it is.

-Kevin

Hi,

The definition for your eyes is at the top of the code segment, I’ll duplicate it here.

Your eyes are part of the player. Your eyes are plural-named. Your eyes can be openable. Your eyes are openable. Your eyes can be open. Your eyes are closed.

Bit baffled why the new rule for dealing your eyes is erroring out.

As Kevin said, the action is called touching, not feeling. “Check touching your eyes” is a valid rule preface.

You missed a semicolon after “say “it is dark.””. It should be “say “it is dark.”;”.

Hope this helps.

Many thanks for that. All is good now - well ish.