Capitalization and Location

Hey all-

Today’s frustration is:
I want to be able to change a location’s name from being capitalized to uncapitalized when the location is mentioned in the text of the game, and the documentation has not been helpful.

I want to do something like this:

Left-from-place is an object that varies.

Carry out doing a thing:
	say "A magical door appears in [the uncapitalised location]!";
	now the left-from-place is the location;
	move the magical door to left-from-place.

But that doesn’t work, of course. The idea is that the door can appear in any location and it leads to X room, and when you come out of X room, you’ll be back where you started. It looks weird to say “A magical door appears in the Kitchen.”

I don’t actually really need this; I can just get rid of saying [the location] and say “The magical door appears!”, but now it’s bugging me that I can’t figure this out. What’s the correct way to phrase this?

1 Like
to say the uncapitalized location:
	let the place be "[the player's surroundings]" in lower case;
	say "[the place]".

Checking and changing the case of text is documented in Writing With Inform 20.4 - Upper and Lower Case Letters.

The player’s surroundings is documented at example 410 - “Capital City”.


Thanks so much! This works like a charm.

1 Like

Keep in mind that this will not work properly if you have any cases where you do want (parts of) the location name to remain capitalized (e.g. “Amanda’s house”). If you have any locations like that, you could leave the location names as you want them to appear in running text, and use something like this:


@ArdiMaster , I’m impressed you were able to put this extension together so quickly!

I ran into the same problem Amanda initially expressed in my WIP, and came up with my own not entirely dissimilar solution. I thought I might describe it here, too.

I created a ‘smart case’ that can be used for printing room or container or vehicle names in different contexts. In creating rooms, I give them their names as I want them, except I always make the first letter uppercase. (e.g. edge of the cliff goes in as ‘Edge of the cliff’). Then in contexts where I want them converted (to some kind of not-title-case), I ‘say’ them in smart case.

And sometimes in code where the game won’t know the context, I have an activity that I toggle on and off around using the routine, if necessary, to let the game know whether to use smart case.

I also add a new kind of naming:

An object can be preposition-named.

This applies to a room with a name like ‘Above the waterfalll’, where the first word is a preposition.

The effects of smart casing on the printout, by the properties of the object whose name we’re printing’:

  • effect on improper-named (game will precede with ‘the’) = lowercase 1st letter of 1st word

  • effect on improper-named + preposition-named = remove ‘the’ then lowercase 1st letter of 1st word

  • effect on proper-named preceded by ‘The’ or ‘My’ = lowercase 1st letter of ‘the/my’, print rest as is

  • effect on proper-named not preceded by ‘The/My’ = print as is

  • effect on proper-named + preposition-named = print as is (won’t have a ‘the’ there by definition, because it’s proper-named)

To decide what text is (O - an object) in smart case:[will usually be a room, but could be container or vehicle, etc. Hence me using 'object'.]
	let T be "[the O]";
	if O is improper-named:
		let POSITION be 5;
		if O is preposition-named:
			if T matches the regular expression "^the ":
				replace the regular expression "^the (.+)" in T with "\1";[removes the 'the']
				now POSITION is 1;
		let CHAR be character number POSITION in T;
		replace character number POSITION in T with CHAR in lower case;
	otherwise if O is proper-named:
		if T matches the regular expression "^The ":
			replace character number 1 in T with "t"; [lower-caserise it]
		if T matches the regular expression "^My ":
			replace character number 1 in T with "m"; [lower-caserise it]
	decide on T;



Thanks, y’all! It’s like being at a buffet of all the best things, before the pandemic when it was OK to eat at buffets*. So many satisfying solutions.

*The sneeze guard never really bothered me before. Now I’m like, ew.

1 Like