Create custom characters in Inform 7

Hello guys! I am just starting out with Inform 7 and it looks to be great! While I can get the player to move between rooms, want I really want to do is let the player create a full character and then use “Instead of examining the player” to describe who you are! The game would include name, gender, age (teen, adult, codger), race (elf, ork, human, hobbit, etc), and skin colour, and this would effect the way people talk to you in game: “Hello (lad\lass\mate\me’ lady\granddad\grandma)!” Ultimately I want to create a simple but fairly imersive RPG.

Is there any way to do this? basically I want to have the player chose “New game, continue, exit” then in New game pick a gender, name (with proper capitalisation), and so on in order. I found a way of doing any one of these things on its own in the Cookbook, but I can’t work out how to make it do all of them in sequence. Anyone know how I could do this? Preferably I’d like a method I can expand as much as I want without too much fiddling. :mrgreen:

First: Inform 7 questions should go on the Inform subforum, not the General Design one.

Second: it’s helpful to post the relevant code that you’ve already got, so that people can see where your question is coming from.

Third: the following is just a hackup of Baritone, Bass.

Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.

Race is a kind of value. The races are Human, Superfluous Elf, Moomin, Fudge Golem, Tripelganger, and Concern Troll.

A person has a gender. The gender of the player is unknown.

Characteristic is a kind of value. The characteristics are sex, [...other values here...], ethnicity and irrelevance.

Current character-definition is a characteristic that varies. Current character-definition is sex.

When play begins: 
    now the command prompt is "Please choose a gender for your character. >".

After reading a command when the current character-definition is sex: 
    if the player's command includes "[gender]": 
        now the gender of the player is the gender understood; 
        if the gender of the player is masculine, now the player is male; 
        if the gender of the player is feminine, now the player is female;
        say "[line break]Many races dwell in Spoddington, including [the list of races].";
        now the command prompt is "Please choose a race for your character. >";
        now the current character-definition is ethnicity;
        reject the player's command; 
    otherwise: 
        say "Sorry, we're not ready to go on yet -- please pick a gender to begin. >"; 
        reject the player's command;

After reading a command when the current character-definition is ethnicity: 
    if the player's command includes "[race]": 
        now the race of the player is the race understood; 
        say "[line break]Please choose a race for your character. The options are [the list of races].";
        now the current character-definition is irrelevance;
        reject the player's command; 
    otherwise: 
        say "Sorry, we're not ready to go on yet -- even in these enlightened times, we still need to know your race. >"; 
        reject the player's command;
say "[line break]Thank you. We now begin..."; 
        now the command prompt is ">"; 
        move the player to First Room; 

and repeat for as long as required.

Finally, a warning: making a full-fledged RPG in I7 is likely to be a lot of work no matter how you slice it.

Ah sorry, I didn’t post any code because I didn’t have anything relevant (just rooms and stuff), sorry. I tried to run the code, but I had a problem with this line:

now the race of the player is the race understood;

It looks like the system didn’t mind the other time you put this in, just this one. :stuck_out_tongue: I’m very new to this system so I’m really not sure how to fix it.

He probably meant ‘topic understood’.

edit: corrected below

This line needs to be added toward the beginning:

 A person has a race.

Without it, Inform isn’t understanding “the race of the player,” since it doesn’t know that the player is supposed to have a race.

Also, the last chunk of code for defining the player’s race seems jumbled – I’ll try to post a corrected version in a bit.

UPDATE: OK, try this:

First Room is a room.

Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.

Race is a kind of value. The races are Human, Superfluous Elf, Moomin, Fudge Golem, Tripelganger, and Concern Troll.

A person has a gender. The gender of the player is unknown. A person has a race. The race of the player is Human.

Characteristic is a kind of value. The characteristics are sex, [...other values here...], ethnicity and irrelevance.

Current character-definition is a characteristic that varies. Current character-definition is sex.

When play begins: 
    now the command prompt is "Please choose a gender for your character. >".

After reading a command when the current character-definition is sex: 
	if the player's command includes "[gender]": 
		now the gender of the player is the gender understood; 
		if the gender of the player is masculine, now the player is male; 
		if the gender of the player is feminine, now the player is female;
		say "[line break]Many races dwell in Spoddington, including [the list of races].";
		now the command prompt is "Please choose a race for your character. >";
		now the current character-definition is ethnicity;
		reject the player's command; 
	otherwise: 
		say "Sorry, we're not ready to go on yet -- please pick a gender to begin."; 
		reject the player's command;

After reading a command when the current character-definition is ethnicity: 
	if the player's command includes "[race]": 
		now the race of the player is the race understood; 
		now the current character-definition is irrelevance;
		say "[line break]Thank you. We now begin..."; 
		now the command prompt is ">"; 
		move the player to First Room;
		reject the player's command; 
	otherwise: 
		say "Sorry, we're not ready to go on yet -- even in these enlightened times, we still need to know your race. The options are [the list of races]."; 
		reject the player's command;

Thanks a lot, but it still doesn’t work. :confused:

I went through line by line and replaced the spaces with tabs, but it still tells me the above. It’s pretty maddening, I don’t know any other parser that does this. Can anyone tell me what I’m doing wrong?

The usual cure for this is to switch from the tabbed notation to the begin/end notation, as described here. (You don’t have to do this for the entire game, just individual bits of code.)

The problem is that all the examples are given in the tabbed notation, but a lot of editing, copy-pasting, and transferring code between formats tends to screw up tabs in difficult-to-track-down ways. So, sorry about that.

Converting the spaces to tabs one-to-one won’t work. Every line in that rule is indented either once or twice, so replace the spaces with one or two tab stops as needed. The depth of indentation shows which code block the lines fall under (I understand that this comes from Python). There was an extraneous space in one of the lines which I’ve edited now; it might have thrown you off a bit.

Anyway, if you don’t want to convert them manually and I’m sure you don’t, you can use this one weird trick:

Hit the “quote” button under the original post.
Find the code in the quoted post (between the “code” and “/code” tags).
Copy that out and paste it into your Inform source window.

That will preserve the tabs from the original post. In practice this means you’ll get tab stops if the author copied them from Inform and not if the author just typed them into the post window (maga just typed his code into the post window, so you can’t use this trick to tab his code up properly).

If you hate the tab-stop formatting, there’s an alternative way to do conditions using bits of code like “begin” and "end if, which is explained in section 11.7.

0k, thanks, I’ve gotten the code to stop giving me that error, but now it says:

I have no idea why it’s doing this. :stuck_out_tongue:

Sorry, forgot to say, the line in question is:

I tried swapping the . for a ; but it didn’t work.

This is a shot more or less in the dark, but do you by any chance have ‘now the command prompt is “Please choose a gender for your character. >”.’ as a stand-alone line?

If so, Inform will think that you want to create 1) an object called ‘now the command prompt’ and 2) the text “Please choose a gender for your character. >” and that you want to declare that object as identical to that text.

To work as expected the line needs to be inside a rule, like this:

When play begins: 
	now the command prompt is "Please choose a gender for your character. >".

And there mustn’t be a blank line between the name of the rulebook and the content of the rule.
So the following will NOT work:

When play begins: 

	now the command prompt is "Please choose a gender for your character. >".

Well, the code in my post compiles fine for me in 6G60, so either something went awry in copy-pasting or something elsewhere in your code is creating a problem. Can you whittle the code you’ve got down to something that still reproduces the error and is short enough to post?

Yeah, that fixed it. :stuck_out_tongue: Sorry, this thing is just so picky about what it does and doesn’t do. Thanks a lot everyone, I’m going to try and add in something to ask for a name now!

0k, I’m adding the name part, but I’m still having problems. My full script so far is:

Gender is a kind of value. The genders are masculine, feminine, and unknown. Understand "male" or "man" or "M" as masculine. Understand "female" or "woman" or "F" as feminine.

Race is a kind of value. The races are Human, Superfluous Elf, Moomin, Fudge Golem, Tripelganger, and Concern Troll.

The player's forename is an indexed text that varies. The player's full name is an indexed text that varies. 

A person has a gender. The gender of the player is unknown. A person has a race. The race of the player is Human.

Characteristic is a kind of value. The characteristics are sex, [...other values here...], ethnicity and irrelevance.

Current character-definition is a characteristic that varies. Current character-definition is sex.

When play begins:
	now the command prompt is "Please choose a gender for your character. >".

After reading a command when the current character-definition is sex: 
	if the player's command includes "[gender]": 
		now the gender of the player is the gender understood; 
		if the gender of the player is masculine, now the player is male; 
		if the gender of the player is feminine, now the player is female;
		say "[line break]Many races dwell in Spoddington, including [the list of races].";
		now the command prompt is "Please choose a race for your character. >";
		now the current character-definition is ethnicity;
		reject the player's command; 
	otherwise: 
		say "Sorry, we're not ready to go on yet -- please pick a gender to begin."; 
		reject the player's command;
After reading a command when the current character-definition is ethnicity: 
	if the player's command includes "[race]": 
		now the race of the player is the race understood; 
		now the current character-definition is irrelevance;
		say "[line break]So what is your name..."; 
		now the command prompt is "My name is.... > ". 
		reject the player's command;
	otherwise: 
		say "Sorry, we're not ready to go on yet -- even in these enlightened times, we still need to know your race. The options are [the list of races]."; 
		reject the player's command
	To decide whether collecting names: 
		if the command prompt  is "My name is.... > ", yes; 
		no. 
After reading a command when collecting names: 
	if the number of words in the player's command is greater than 5: 
		say "[paragraph break]Who are you, a member of the British royal family? No one has that many names. Let's try this again."; 
		reject the player's command; 
	now the player's full name is "[the player's command in title case]"; 
	now the player's forename is word number 1 in the player's full name; 
	now the command prompt is ">"; 
	say "Hi, [player's forename]![paragraph break]"; 
	say "[banner text]"; 
	move the player to the location; 
	reject the player's command. 
	Instead of looking when collecting names: do nothing. 
Rule for printing the banner text when collecting names: do nothing. 
Rule for constructing the status line when collecting names: do nothing. 
Your Bedroom is a room. The printed name of Your Bedroom is "[player's forename]'s Bedroom". 
The player carries a letter. The description of the letter is "Dear [player's full name], [paragraph break]You have won the Norwegian Daily Lottery! ...". 

Inform is telling me that:

This feels like another formatting issue, but I can’t work out what. :stuck_out_tongue:

Yes, Inform 7 is picky; just as, indeed, any computer programming language is. I7 is hardly more picky than other such languages, but it can be more unexpectedly so: I7 is a fragment of (nearly) natural English, but where the boundaries lie of that fragment is not always easy to guess – and, compared to natural English, Inform 7 is certainly very picky, indeed. However, you’ll soon get the hang of it, I’m sure. Just keep it in the back of your head that I7 kind of only pretends to be real English.

At the end of one line, you have a period in place of a semicolon; at the end of another, nothing where a semicolon is needed.
Both occur before instances of the phrase ‘reject the player’s command’.

After reading a command when the current character-definition is ethnicity: 
	if the player's command includes "[race]": 
		now the race of the player is the race understood; 
		now the current character-definition is irrelevance;
		say "[line break]So what is your name..."; 
		now the command prompt is "My name is.... > ";[.] [change this period to a semicolon] 
		reject the player's command;
	otherwise: 
		say "Sorry, we're not ready to go on yet -- even in these enlightened times, we still need to know your race. The options are [the list of races]."; 
		reject the player's command;[] [add a semicolon here]
	To decide whether collecting names: 
		if the command prompt  is "My name is.... > ", yes; 
		no. 

Ok, I want to check that the game is saving the values of race and gender and that I can call them up if I want, so I added in the following code at the end:

say "[line break]Hello [player's full name]! You are a [player's gender] [player's race]!"; 

Unfortunately this doesn’t work and typing [gender] or [race] compiles 0k but breaks the program. Can anyone tell me what I need to do?

By the way, is there a way to make it so that I can use the [] tags in speech to insert correct pronouns for the player? Say, you have someone who calls you “lad\lass”, “sir\madam” or “gramps\grandma” depending on your age bracket (young, regular or old)?

You need [full name of the player], etc.

Yes, there is. You can do a great deal of things by making new ‘say’ statements.

To say nickname:
if the gender of the player is male begin;
 if the age of the player is young begin;
 say "lad";
 otherwise if the age of the player is adult;
 say "sir";
 otherwise;
 say "gramps";
 end if;
otherwise;
 if the age of the player is young begin;
 say "lass";
 otherwise if the age of the player is adult;
 say "ma'am";
 otherwise;
 say "grandma";
 end if;
end if;

Then you just need to use [nickname] in your text, as appropriate.

(Note: these are not pronouns, though pronoun-handling is a related issue. For that, I would use the built-in extension Plurality.)

Thanks a lot for the pronouns, but I’m not too sure what you mean by this bit:

Sorry I didn’t say, but at the moment the full name of the player does work, but gender and race don’t. :mrgreen:

To clarify: [gender of the player] should work, but [player’s gender] won’t.