Making a value depend on another value that varies

I’m working on a social-interactions prototype and am finding myself blocked. I’ve only been using inform for about a week, and any guidance on this is very greatly appreciated, as I’m finding myself up against a deadline and stressed.

Here’s a quick description of the system:

A player can perform social actions on a non-player character.

An NPC has a number called “romance”. Romance begins at zero. Using social actions increases romance by varying point levels-- "flirt, “touch,” and “kiss” would increase Romance by 10, 20, and 30 respectively.

An NPC also has a value called “state”. The states are indifferent, interested, infatuated, and seduced. An NPC is usually indifferent.

I’m having trouble correlating the states to a range of point values rather than individual social actions. I’ve been able to say “if the player flirts with the NPC, now the NPC is interested.”

But, what I actually need is:

if the romance of a person is 0, the person is indifferent.
if the romance of a person is between 1 and 10, the person is interested.
if the romance of a person is between 11 and 20, the person is infatuated.
etc.

(I will then have those states determine which social actions an NPC will allow, but I more or less have this working for now so I’m just giving context.)

How can I make the state value depend on number properties? Should this be in a rule structure? The documentation in Inform 7 is a little dense, and hard to sift through.

Thanks very much for some advice,

Natasha

I think you want

Definition: A person is indifferent if the romance of it is 0. Definition: A person is interested if the romance of it is at least 1 and the romance of it is at most 10. Definition: A person is infatuated if the romance of it is at least 11 and the romance of it is at most 20.

See chapters 6.4. and 14.2. in the manual.

Edit: And when you do it this way, you don’t need the “state” value anymore.

Thank you, I’ve tried that and it works. Though, this code causes the state values to not work, returning:

Problem. You wrote ‘The states are indifferent, interested, infatuated, or seduced’ : but this seems to say that a general description is something else, like saying that ‘a door is a number’.

As you’ve said this can eliminate the need to use state values at all, but the practical reason that I’m using them is to “understand state as describing a person,” which allows me to call the state value into a persons description if the player looks at them, etc.

How might I maintain these adjectives having a number value, but still be able to use them as descriptors?

Best Regards,
Natasha

Here you go:

Understand "indifferent" as a person when the item described is indifferent. Understand "interested" as a person when the item described is interested. Understand "infatuated" as a person when the item described is infatuated. ...
(see chapter 16.17 in the manual.)

This works, but is not quite the action I was trying to achieve. This allows me to to say “look at indifferent” and get the description of the item, if it is indifferent.

What I’d like I’d to be able to do is say in the item description: “The item appears [indifferent, interested, etc.]” depending on which the item is.

Alternatively, it might work better for my purposes to simply be able to change the description of an item depending on which adjective it is. This would be for a specific, proper named thing (person) and contingent on its description.

For instance,

If Mary is indifferent, then the description of Mary is “…”

Any pointers in the right direction would be swell :slight_smile: I’ll just be muddling through the manual until then. Thanks

Sorry, I misinterpreted the question (“understand x as describing a person” by itself does only what I showed in the last post). Here’s a solution:

[code]To say romance of ( socializer - a person ) in words:
if the socializer is indifferent:
say “indifferent”;
otherwise if the socializer is interested:
say “interested”;
otherwise if the socializer is infatuated:
say “infatuated”. [and so on]

After examining a person:
say “[The noun] looks [romance of the noun in words].”[/code]

And to have the description vary completely depending on the mood:

[code]The description of Mary is “[Mary’s mood description]”.

To say Mary’s mood description:
if Mary is indifferent:
say “Mary doesn’t look like she cares.”;
otherwise if Mary is interested:
say “Mary looks back at you and smiles.”;
[and so on] [/code]

This is great and works exactly the way I need it to, thanks so much.

Why is it that we must say
To say romance of ( socializer - a person ) in words:

instead of
To say romance of a person in words:?

I only ask so that I might broaden my understanding of I7’s temperament.

The second phrase defines the words “romance of a person in words” as a text substitution – exactly those 6 words, in exactly that order.

The first phrase defines the words “romance of ________ in words” as a text substitution, and assumes that the blank will be filled in with the name of a specific person. It then assigns the variable “socializer” to stand for that person, so you can use that variable in your code.

Could we not say:

To say romance of (a person ) in words:

?

Nope. The main problem being that the compiler would throw an error message.

But the reason why the compiler won’t let you do it is because writing it that way wouldn’t accomplish anything.

Let us suppose that the syntax you suggest does work. The most intuitive interpretation is that it defines “romance of _______ in words” as a text substitution, with the expectation that the blank will be filled in with the name of a person. So you could write statements like:

say "Bob feels [romance of Bob in words] towards you." say "Jane feels [romance of Jane in words] towards you."
etc.

The problem comes when you try to write the instructions for that text substitution:

To say romance of (a person) in words: if _______ is indifferent: say "indifferent"; otherwise if ________ is interested: say "interested"; otherwise if ________ is infatuated: say "infatuated". [and so on]
What do you put in the blanks? You can’t just say “the person”, because Inform doesn’t have any way of knowing which person you mean. (Although it sounds natural to say it that way in English, Inform isn’t capable of making those kinds of contextual assumptions, and even if it could, there might be cases where you wouldn’t want it to.) Because what the text substitution says depends on which person its referring to, you need some way of referring to the specific person mentioned in the text substitution.

The notation “(socializer - a person)” is short-hand for “(a person, whom for the purposes of these instructions we will refer to as ‘the socializer’)”. The word “socializer” is arbitrary – you could instead use “potential love interest” or “dude” or “X”, whatever makes it easier for you, the author, to read your own code. Whatever you use (let’s just assume you stick with “socializer”) then becomes the label for the specific person that you were referring to, and you can use that label in your instructions. So:

To say romance of (socializer - a person) in words: if the socializer is indifferent: say "indifferent"; otherwise if the socializer is interested: say "interested"; otherwise if the socializer is infatuated: say "infatuated". [and so on]
Does that make sense?

Hm,

I suppose my contention with the format is that it’s not particularly intuitive to assign an arbitrary variable to something that one wants to make a blanket statement about. The way I would intuitively assume Inform would translate the following:

To say romance of (a person) in words: if _______ is indifferent: say "indifferent"; otherwise if ________ is interested: say "interested"; otherwise if ________ is infatuated: say "infatuated". [and so on]

is that it (a person) refers to any and every person, and applies to all of them in the world …which is in fact the way I’d hoped it would work. As far as I could tell from the way the code is working, assigning the variable didn’t actually modify the thing (a person) in anyway, it still makes a blanket statement about all people. Now the term “socializer” is used interchangeably with “a person,” so why not just say “a person”?

Unless, if now “socializer” is a term used to mean any person but only in the context of referring to their romance level? That, I might be able to wrap my mind around.

~

On a different note, I have a new thorn in my side to solicit advice about.

I’d like an actor to do something once it reaches a certain romance level. It will be different things for different actors, but let’s say in this case it’s for Gwen to give the player a rose. Gwen should give the player a rose when she becomes infatuated.

I couldn’t find any leads on delivering the piece of text and the rose item at any point when Gwen enters the range of romance points that specifies that she is infatuated, which would be cool.

Instead, I tried:

To get the rose:
	say "...";
	now the player carries the rose.

After doing something to Gwen:
	if Gwen is infatuated, get the rose.

It didn’t break the build, but neither did it work. Using “instead of doing something to Gwen,” of course, caused the other action rules to not work on her.

Ideas?

Because the condition “if a person is indifferent” will return true if any person in your game is indifferent. You might invoke the say-phrase in reference to Mary (e.g., “Mary feels [romance of Mary in words] towards you.”), but asking “if a person is indifferent” will get a positive response if Tom, Jane, Brian, or anyone happens to be indifferent, even though Mary herself might be infatuated.

Your if-then statement needs to be able to refer to the specific person that you referred to when you invoked the say-phrase. So we give that person – and only that person – the temporary label of “socializer” (or whatever), so you can refer to her specifically in your instructions.

Yes, that’s exactly right. “Socializer” only has meaning within the instructions for that specific say-phrase. Everywhere else in your code it is meaningless.

This one is a little hard to diagnose without seeing your code.

First, make sure you have some way of verifying in-game that Gwen is actually infatuated when you think she is. The bug might be simply that Gwen is never becoming infatuated.

Assuming that’s all working, using an after rule might be problematic. Some actions (like kissing) don’t ever get to the after rulebook. They’re designed to stop at the check stage, and the usual way to override them is with instead rules, so your after rule will never fire if you KISS GWEN. Also, “doing something to Gwen” assumes that Gwen is the noun. Some of the actions you’ve designated as affectionate might be treating Gwen as the second noun. In particular, GIVE CHOCOLATES TO GWEN treats “chocolates” as the noun and “Gwen” as the second noun, so again, your after rule would not fire.

A better solution would be to use an “every turn” rule:

Every turn while Gwen is infatuated: if Gwen is in the location and Gwen has the rose: say "Gwen blushes and hands you a rose."; move the rose to the player.
Every turn rules fire at the end of the turn, after the player has done whatever was necessary to make Gwen infatuated. Note the if-then statement checks to make sure that 1) it only happens if Gwen is actually in the room with the player, and 2) it only happens if Gwen is carrying the rose, which ensures that the message doesn’t fire over and over again while Gwen is infatuated.

Aha!

I did have a way of checking the demeanor of the actor in game by examining it, it’s part of what my mess of romance point values and associated moods was for. Incidentally, it did turn out that the problem was that I was “kissing Gwen,” among other actions. The “after” rule worked by examining Gwen, but the every turn rule is much more elegant because, as you’ve said, it alleviates the problem of repeated actions by voiding it once she doesn’t have the item anymore.

Thanks!

Just to clarify, “socializer” doesn’t have any meaning in Inform unless you give it one - in other words, I pulled that out of my hat. You could have “x”, “party-goer”, “foobar”, “minced meat” or whatever you want. I just chose that word because it seemed to fit the context.

Here’s another example why placeholder words are necessary:

To say (lover - a person) likes (target - a person): say "[The target] is the love interest of [the lover]."

If you wrote: To say a person likes a person: say “[The person] is the love interest of [the person].”, the compler would get confused for obvious reasons.