Few quick questions from a beginner

To add a small point to what people have said about making something, you can get Inform to assume which bed.

does the player mean making the first bed: it is likely;

This avoids disambiguation.

I agree with other people about looking through the standard actions. If I’d known about Index::Actions in the IDE, I’d have realized a lot sooner what is good stuff to implement first, and what people expect to be able to try.

Oh, and welcome!

All right, I think I’m starting to run out of questions. Maybe. This is still tough to get the hang of, although the Inform handbook helps.

What I’m wanting to do now, is make it so that the player can ONLY leave the starting location if he’s wearing the shirt, pants, and backpack he finds in the dresser, and his roommate Jernon is in the same room as him.

I know I could do one of those things as an ‘if/end if’ thing, but I’m not sure how you do those for multiple conditions.

You can do this two ways: as nested statements, or as a big compound condition:

if the player wears the shirt begin;
 if the player wears the pants begin;
  if the player wears the backpack begin;
    if Jernon is in the location begin;
    (the player leaves the room)
    end if;
  end if;
 end if;
end if;

The advantage of the nested version is that you can provide an explanation for each thing the player has failed to do, using ‘otherwise’. But if the player can be expected to know exactly why the action failed, you can do something like this:

if the player wears the shirt and the player wears the pants and the player wears the backpack and Jernon is in the location begin;
(the player leaves the room)
end if;

You shouldn’t feel obliged to avoid if-thens, but it does help you understand the details. They do feel a bit like brute force. However, they’re often the most practical. Here’s an example of how you could do this a few different ways. Maybe you’ll find one useful. Inform generally has a few ways to do things, though the natural language sometimes gives newbies a sort of “guess/research the verb” puzzle. It’s all there and it makes sense,

[code]“jernon” by andrew

room 1 is a room.

room 2 is north of room 1. “Yay! You made it to room 2!”

an outfit piece is a kind of thing. an outfit piece is wearable.

the pants are an outfit piece. the backpack is an outfit piece. the shirt is an outfit piece.

Jernon is a person.

check going north:
say “Alternate check shows player can[if player can’t leave]not[end if] leave.”;
if Jernon is not in the location:
say “Don’t want to leave w/o jernon!” instead;
if there is an outfit piece that is not worn:
let X be a random outfit piece that is not worn;
say “You’re not wearing the [X].”; [put instead here if you want]
repeat with Q running through outfit pieces:
if player does not wear Q:
say “Jernon says ‘You really should be wearing [Q].’” instead;

to decide if player can’t leave:
if the pants are not worn:
yes;
if the backpack is not worn:
yes;
if the shirt is not worn:
yes;
if Jernon is not in the location:
yes;
no.

test x with “n/purloin jernon/drop jernon/n/purloin shirt/wear shirt/n/purloin backpack/wear backpack/n/purloin pants/wear pants/n”[/code]

Oh, and keep asking questions. It’s the best way to get better. If nothing else, I felt smart answering this one.

Hmm… would anybody mind if I put up my source, so that you all could take a look at it? I’m mostly asking to make sure my code isn’t a horrible mess, really.

Also, are there any good tutorials that specifically handle the conditional stuff? That’s what I’m having an issue with most of all, I think.

Also, what am I doing wrong here?

The spellbook is a thing. After talking to Jernon: Jernon takes the book in one turn from now; At the time when Jernon takes the book: now Jernon carries the spellbook; say "Jernon reaches under his bed and pulls out his hefty spellbook."

Also, how do I make “say hello” and “greet” the same verb? I’m trying this, and “say hello” just gives the standard “You get no response” line.

If it’s on the long side, I might provide a dropbox link. While I’m not sure of the community policy on how much people generally help with the details as coding gets bigger, I bet there are probably some things you didn’t know you could do better & once you learn them it’ll be a step up. I think you’ve been providing good chunks of code so far.

What do you mean by ‘conditional stuff’? I’d guess you are ok with if-thens and learning to do more as you need, or as you say, hey, that’s neat. I started with section 11.5 of the IDE.

As for learning conditional stuff, I tended to rely on games that I liked that had released their source. I’d say “How’d they do that puzzle” and then searched for the game text to find the source text. Inform’s friendly that way.

You can see games with source released at ifdb.tads.org as they are tagged with “I7 source available” and just pick a 5 star game and have fun.

As for what you’re doing wrong in coding:

The spellbook is a thing. After talking to Jernon: Jernon takes the book in one turn from now; At the time when Jernon takes the book: now Jernon carries the spellbook; say "Jernon reaches under his bed and pulls out his hefty spellbook."

You need to define talking to. I think I stole this from example 168 in the IDE. I also find that searching for an action in upper case, or in the Standard Rules, can turn stuff up. In this case, you can’t find “talking to” in the Standard Rules or in the Action Tab. It seems like it should be there, but it isn’t.

(In the Windows IDE you can hit File:Open Extension:Graham Nelson:Standard Rules and search for, say, “talking to.” Or you can search the documentation, or go to the actions index, which I didn’t know about until I bought Aaron Reed’s book.)

[code]Talking to is an action applying to one visible thing.

Understand “talk to [someone]” as talking to. Understand “talk to [something]” as talking to.
Understand “greet [someone]” as talking to. Understand “greet [something]” as talking to.[/code]

Does the above do this?

I assume you mean “Jernon,hello” … as plain old “say hello” may ask you whom you want to say hello to if there’s more than 1 person in the room.

I’ve defined “talking to”, it still doesn’t work.

Talking to is an action applying to one visible thing. Understand "talk to [someone]" as talking to. Understand "talk to [something]" as talking to. Understand "greet [someone]" as talking to. Understand "greet [something]" as talking to.

Also, I’ve come across another issue.

[code]Jernon Enters is a scene. Jernon Enters begins when Jernon in Bathroom for 3 turns.

When Jernon Enters begins:
now the bathroom door is unlocked;
now the bathroom door is open;
move Jernon to Dormitory;
say “Jernon enters through the bathroom into the main living area, clad in his usual boring school clothes. ‘Morning,’ he says, chipperly. [if the first bed is made]Jernon stares at your nice, neat bed, his eyes widened in surprise. ‘You actually cleaned up after yourself for once. Is there something you’re not telling me, lizard?’”[end if];
say “[paragraph break](You can ‘greet’ Jernon to say hello to him, or you can ‘talk’ to him multiple times to see what he has to say. If a word shows up in [italic type]this kind of text[roman type], you can ask him about it.)”;.
[/code]

When I run the game, it automatically runs this scene the first time the player does anything.

Do you mean the action is blocked, or you just see no text? In any case, you may need to add…

carry out talking to jernon: say "[one of]Jernon says hi back.[or]Jernon points a friendly finger gun at you.[or]Jernon offers you a high-five, then pulls back.[or]Jernon claps you on the back.[stopping]"

Should be a start.

Jernon Enters is a scene. Jernon Enters begins when Jernon in Bathroom for 3 turns.

Inform actually recognizes tenses. It sees was (true at start of turn,) has been, is differently, which is tricky. The “is” seems to trump the “for 3 turns.”

[code]when Jernon has been in Bathroom for 3 turns[code]

This’ll actually make him come in after 2 waits–so you may want to change 3 to 4. Inform seems to count before the first turn as a sort of turn. Maybe others can clarify this.

All right, I’m trying to get Jernon to follow the player around by using the code from Van Helsing:

Every turn:
	if the location of Jernon is not the location of the player:
		let the way be the best route from the location of Jernon to the location of the player, using doors; 
		try Jenon going the way;

But Inform doesn’t seem to like the words ‘going the way’. What’s the issue, here? Also, how would I make it he doesn’t follow the player into certain rooms?

By the way, when I say I want to know what the conditions are, I mean, stuff like, say ‘when this thing has been in this thing for 4 turns’, ‘when this thing encloses this thing’, basically, any time Inform wants a condition, I’d like to know what I’m able to put there.

You wrote Jenon instead of Jernon. Adding the r fixes it for me–after I got the same error you did. Yeah, Inform finds it tough to pinpoint typos, and there’s a learning curve about what the errors actually mean. Unfortunately, since Jernon isn’t a regular word, it’s not so easy to spell-check, either.

I think you have the basic idea with what to do. Section 9.16 gives the general wrap-up of what you can do with regard to tenses. It’s an ongoing process for me, certainly. The stuff near the end gives a lot of tenses.

The only way to know everything is to look at the standard rules file, and I think it may be best just to look at code examples you can find. That might be a bit too much for right now, so my advice is to go with your intuition and when something seems like it should work, you probably don’t have the exact language yet. I think it’s a good idea to ask for where in the standard rules or docs a person found this, too–this bit of information has helped me a lot.

There are lots of relevant links in the sticky post at top of this forum (“The list of Inform 7 documentation”).
For your purpose I guess the I7 Cheatsheet by Oliver Reiser should be interesting.
There is also Emily Short’s I7 Syntax Reference, which is from 2007 and so not completely up to date with the language, but it’s still useful.

Yes, that error is a bit–vague to new programmers.

But I think where Inform gets confused is, you haven’t defined ‘making the first bed.’

I took the liberty of chopping up your code to make it more general.

[code]“firstbed-bobinator” by Andrew

A bed is a kind of container. It is enterable. A bed can be made or unmade. A bed is usually unmade.
[note: this is more general than saying bed 1 can be made or unmade. It also allows you to try to make bed 2 w/o much additional code.]

Dormitory is a room.

bedmaking is an action applying to one thing.
[this is the key thing that is missing. Inform doesn’t know bedmaking is an action or what it applies to. When you said Making the First Bed, it could’ve been an action applying to nothing–but that’d get confusing because it, well, was meant to apply to 1 thing.]

Before bedmaking:
if noun is not a bed:
say “You can only MAKE beds in this game.” instead;
if noun is unmade:
now the first bed is made;
say “You put in a tremendous level of effort hoisting the covers back onto the bed, carefully smoothing them back under the pillows. Why you do this, even though you know you’ll just make a mess of them again, you aren’t entirely sure.” instead;
otherwise:
say “This is added to the example to make sure there’s a message if you try to make the bed twice. You did, so, bam.” instead;

Understand the command “make [something]” as something new.
[you also need this before understanding something as something concrete.]

Understand “make [something]” as bedmaking.

The first bed is a bed. the first bed is in Dormitory.

The printed name of first bed is “bed”.

The description of the first bed is “Quite possibly one of the best friends you’ve made during your time at the school. Sure, you hate the way the covers are stitched in, leaving your feet to roast under them. Sure, you hate the way one of the springs jab into your back if you lean into it a certain way. But, when it all comes down to it, it helps you get to sleep.[If bed is made]The pea-green covers are neatly straightened out.[Otherwise]The pea green covers are dangling over the edge of the bed where you left them.[END IF]”[/code]

No problem about the help. It’s good you’re dropping by to say thanks. I hope the advice is making things clearer!

One thing to try if an error message is confusing is to write down what you did wrong and what it gave for the next time. Also you can try deleting certain lines from sample documentation code you -know- works. Then you can see what the errors mean. One piece of documentation I would love would be one that categorizes samples and common mistakes that lead to semi-cryptic Inform errors and examples of how to get certain errors and specific things to check. That could save a lot of time and frustration.

Hey, I know it’s been a while, I’ve just been busy with other things. A couple of quick questions, though:

  1. How do I make it so that if the player tries to go in a direction from a specific room, they get a special message for it, instead of just “You can’t go that way?”

I tried doing it like this:

Carry out going east from Main Grounds:
	say "That way leads over towards the movie theatre. While you'd love to catch 'Boy Gets Hit In Face With Rather Large Pie 2' again, you're too busy right now."
After going west from Main Grounds:
	say "That wasy leads towards the classrooms. Since you've got a good excuse today to skip class, you'd rather make use of it."
After going northwest from Main Grounds:
	say "That goes towards the girl's dorms. If you wanted to sneak over there, it'd be better to not do it in broad daylight."
After going northeast from Main Grounds:
	say "That way leads to more dorms that don't belong to you."
After going southwest from Main Grounds:
	say "A crowd of students block any movement towards that direction."
After going southeast from Main Grounds:
	say "Nothing's over that way besides some training grounds, which you have no time for at the moment."

I’ve tried all of these with Instead and Before rules, too, and that didn’t work, either.

  1. How do I have a character not follow the player into a certain room? My following code works like this:
Every turn when Jernon Follows is happening:
	if the location of Jernon is not the location of the player:
		let the way be the best route from the location of Jernon to the location of the player;
		silently try Jernon going the way;
		say "Jernon follows after you.";

The problem is this means that Jernon will follow the player into the bathroom, and… well. That’s something I’d rather fix.

a) this is one of the most common problems in the book. Going a direction from a room happens only when the movement has already succeeded; going a direction in a room happens before that’s checked.
b) you want to use an Instead rule for this, thus:

Instead of going east in Main Grounds: say "That way leads over towards the movie theatre..."

You could just add a little bit into your condition:

Every turn when Jernon Follows is happening:
	if the location of Jernon is not the location of the player and the player is not in the bathroom:
		let the way be the best route from the location of Jernon to the location of the player;
		silently try Jernon going the way;
		say "Jernon follows after you.";

But that might get annoying if you had a lot of rooms you didn’t want Jernon to enter, so you could do it with a value instead:

A room can be forbidden or permitted. A room is usually permitted. The bathroom is forbidden.

Every turn when Jernon Follows is happening:
	if the location of Jernon is not the location of the player and the player is not in a forbidden room:
		let the way be the best route from the location of Jernon to the location of the player;
		silently try Jernon going the way;
		say "Jernon follows after you.";

Or if you have different parts of the map you don’t want Jernon to enter for different reasons – perhaps under different conditions – you can use regions.

A jacket is a wearable thing. Arctic is a region. Ice Floe is a room in Arctic. Snowy Field is a room in Arctic, north of Ice Floe. Base Entry is north of Snowy field.

Jernon is a man in Base Entry. Yourself is in Base Entry.

Jernon Follows is a scene. Jernon Follows begins when play begins.

To decide if (R - a room) is Jernon-friendly:
	if R is regionally in Arctic and Jernon does not wear the jacket, no;
	yes.

Every turn when Jernon Follows is happening:
	if the location of Jernon is not the location of the player:
		if the location is Jernon-friendly:
			let the way be the best route from the location of Jernon to the location of the player;
			silently try Jernon going the way;
			say "Jernon follows after you.";
		otherwise if the player was in the location of Jernon:
			if the location is regionally in Arctic and Jernon does not wear the jacket:
				say "Jernon hangs back. 'I'm freezing already!'"

You probably should use this.

[code]A room can be forbidden or permitted. A room is usually permitted. The bathroom is forbidden.

Every turn when Jernon Follows is happening:
if the location of Jernon is not the location of the player and the player is not enclosed by a forbidden room:
let the way be the best route from the location of Jernon to the location of the player;
silently try Jernon going the way;
say “Jernon follows after you.”;[/code]

Otherwise, if you have a toilet (an enterable supporter) in the bathroom, Jernon will enter the bathroom as soon as you get on the toilet! :astonished:

OK, I think I’m getting close to finishing this game. It’s very short, but that’s because it’s more of an interactive story than anything else. There is one final ‘puzzle’ I’d like to make, though.

Basically, how do I make it so you have a car you can start by putting the key in the ignition and turning it? Would I make the key slot a container?

Yes, the ignition would be an open, unopenable, container, and a part of the car. Also, throw in a rule to prevent putting other things in the ignition. (e.g. Check inserting something into the ignition: if the noun is not the keys, say “That’s a monumentally ill conceived plan.” instead). Inform’s Standard Rules already define a turning action that you can use for turning the key (Check turning the key when the key is in the ignition: etc.)

By the way, I’m having a weird issue where if you try to do an action without a specific target, it always assumes it’s talking about the player’s underwear. How would I fix this so it just doesn’t DO something without a specific target?

The parser won’t infer an object if there is more than one possibility around. So this probably won’t happen once you’ve put more objects in the starting room.