Allowing actions only after a given point

Hey All-
All the actions in my game (except examine) are novel actions based on emotions: love something, hate something, etc. Over the course of the game, the player examines objects that trigger allowing them to use the new action, but I don’t wish these actions to be available before those points in the story. When the precocious player tweaks to what’s going on, s/he may try to use an emotion action out of curiosity: Hey! If I can love something, maybe I can hate it, too!
And then chaos would ensue, since all sorts of things might happen out of order.

My novel action code reads like this:
Understand the command “love” as something new. Understand “love[something]” as loving. Loving is an action applying to visible things.

And this works great, but allows early usage of “love.”
I’ve tried dozens of ways to make this conditional: Afters, before, ifs, etc. None of them work. An example of something I tried:

If we have examined the box:
Understand the command “love” as something new;
Understand “love[something]” as loving;
Loving is an action applying to visible things;
Otherwise:
Understand loving as nothing.

Can someone help me figure out how to phrase this correctly?

PS- I did do the tabs correctly- they just didn’t translate to this post. I should probably learn how to use the “show code” function here.

2 Likes

I think the way I would go about doing this would be via check rules rather than understand statements. The reason for that is that if, as a player, I type in a command and get back a default Inform response that it’s not understood, I’m likely to assume it doesn’t work and not try it again even after circumstances have changed to “unlock” the command. A check rule is also likely going to be easier for you to work with than nested understand statements. So here’s one way to do that:

The chamber is a room.  The box is in the chamber.  

Understand the command “love” as something new.  Understand “love[something]” as loving.  Loving is an action applying to one visible thing.

Check loving:
	If we have not examined the box:
		Say "No one ever taught you how to love!";
		Stop the action.
		
Carry out loving:
	Say "You wrap the [noun] in a big old hug."

If you’re still wrapping your head around check, carry out, and report rules vs. before, instead, and after rules, it might be worth re-reading the documentation about this. I know when I was learning Inform, I didn’t quite get the differences and wound up just using before, instead, and after, which caused me some headaches!

By the way, I noticed you’d written “Loving is an action applying to visible things”, but also “Understand “love [something]” as loving.” If you really want to allow the player to love multiple objects with a single command, that won’t quite work – there’s more detail in the relevant bit of the Recipe Book.

Oh, and you can insert formatted code into your posts by using the preformatted text option – it’s the button that looks like this in the ribbon: </>

Hope this is helpful!

3 Likes

If you just want to blanket-disallow the action with a quick message, an even easier way might be just to use understand ... as a mistake ... when, something like this:

The player wears a spiffy hat.
Understand "love [something]" as a mistake ("You haven't unlocked that verb yet, cheater!") when we have not examined the spiffy hat.
2 Likes

Just to summarise the strategies that are being used here. In your original post, Amanda, you are trying to put the ‘understand’ lines in an if-block. The underlying idea of this is that whenever the player types a command, the game will go through your code to search for appropriate ‘understand’ lines, hopefully arriving at the right ‘understand’ lines only if the condition in the if-statement is met. This strategy doesn’t work because that’s not how Inform handles grammar. Instead, the grammar is built up before play even starts; it’s static, not dynamic, and cannot change during the game.

So that leaves two possibilities. Either we bake into the grammar rules something that is conditional and makes sure that a verb is handled differently in different circumstances. Or we leave the grammar simple and handle the different circumstances in our handling of the action itself. The latter is Mike’s option. There the grammar is simple; “love table” always generates the action of loving the table; but then a check rule intervenes if the condition for loving isn’t met.

Patrick’s solution uses the former strategy. Understand-rules can themselves involve conditions: see paragraph 17.17 in the manual. Thus, we could have something like:

Understand "love [something]" as loving when loving-activated is true.

And then ‘loving-activated’ could be a truth state that is set to true when some action happens. Patrick uses a neat trick, which is that we can use ‘understand … as a mistake’ as a sort of check-rule for understanding: it comes before the real understand grammar, and can filter out certain commands based on circumstances.

Hope this helps you understand why your strategy didn’t work, and these two others do!

2 Likes

Thanks to all of you!
Earlier on, when I was going through the documentation and treating it like an exercise book, I did write a check rule that worked great, then promptly forgot about it.
I’ve been vacillating between 2 ways of learning this:
1.) Reading the documentation and then devising something in the game to fit what I read.
2.) Wanting to do something and trying to find out how in the documentation.

The problem with #1 is that there isn’t a desire to do that specific thing; it’s just an exercise in learning, so I easily forget it after succeeding at it.

The problem with # 2 is that the needs are specific in some way and combing through all the documentation to find something to adapt to specific needs is a daunting task. But I remember better this way.

And of course trying to organize the code is ridiculously hard. It took me forever to go back and find the check rule I wrote earlier and see why I did that and what it accomplished.

I have to say, this is the awesomest forum ever. Where is the snark? Where is the meanness? It’s just grand to ask a dumb newbie question and be treated patiently and kindly, and get thorough answers that help me learn.

3 Likes

I have to admit that I usually do it this way, fail to find it in the docs, and ask here. This really is a very helpful forum!

2 Likes

Although that’s what the documentation states, it isn’t actually true: Precedence of mistakes in grammar