Context Sensitive Environment - things are only shown when..

Hiya. it’s me again. Sorry.

I have things in my story that increase a counter.

I can already do a bunch of fun things with that, which i won’t spoil for ya.

But another cool thing i want to do is … well let’s put it this way.

There’s a bloody knife.

If you take the bloody knife, a counter known as “haunted” goes up by one. same if you pick up the bloody locket, the skull and the candlestick (because we’ve all played Clue).

So depending on how big “haunted” is, several things should happen.

when haunted is greater than 0, there should be a message in blood on the mirror, saying “you’re next”.

when haunted is greater than 1, there should be a message at random (based by turn) that lets you know there’s a cold breeze but there aren’t any open windows.

when haunted is greater than 2, bodyparts (that can be taken) appear and disappear at random when entering/leaving rooms.

the last bit is easy. when haunted is greater than 3, meaning you have collected all 4 haunted items, the monster shows up and killz ya stone f*ckin’ dead. no difficulties here.

… sadly my attempts to do this are all failures.

this is probably above my skill as a rookie but … it’d be cool if i could make this work :slight_smile:

thanks in advance. you guys rock.

[code]An artifact is a kind of thing.
The bloody knife, the locket, the skull and the candlestick are artifacts.

The bedroom is a room. “A dark, gloomy room filled with dust and cobwebs.”
A mirror is in the bedroom. The mirror is fixed in place. The initial appearance of the mirror is “The mirror reflects only darkness[if an artifact is handled]. Blood is smeared across its surface, forming words[end if].”
The description of the mirror is “[if an artifact is handled]It holds a message written in blood. ‘You[’]re next.’[otherwise]The mirror is dark and still like a forest pool.[end if]”

The gallery is west of the bedroom. The Library is down from the gallery.

When play begins:
repeat with item running through artifacts:
now the item is in a random room.

Every turn when at least two artifacts are handled and the remainder after dividing the turn count by 5 is 0, say “A sourceless draft unnerves you.”

Every turn when all artifacts are handled:
say “A creak of wooden boards behind you. A cold, yawning blackness at your back. And then laughter, and the tearing of flesh.”;
end the story saying “You are dead, dead, dead.”

Before going to a room when at least three artifacts are handled, redistribute unheld body parts.

A body part is a kind of thing. Some body parts are defined by the Table of the Abattoir.

Table of the Abattoir
name description
a torn-off arm “”
a bloodied foot “”
a severed head “”

To redistribute unheld body parts:
repeat with flesh running through body parts not enclosed by the player:
now the flesh is in a random room.[/code]

You still don’t need a counter variable. :stuck_out_tongue:

i need the counter for something else too ^^

also, is there a way to only show scenery when one of those things is handled?

like, say, a door that isn’t there until you pick something up, or a coffin that appears somewhere when you have all the items, and if you get into the coffin, it takes you to hell?

so not just add something to the description of the hall, but say, it adds scenery that you can examine only if it’s mentioned.

so before you pick up the knife,
“it’s a hallway.”
and trying to examine bloody prints gives you a fail

but after you pick up the knife,
“it’s a hallway and along the walls are the bloody handprints of small children.”
and trying to examine the bloody prints says “they’re all different shapes and sizes. each print must be a different missing kid. there must be hundreds of them!”

What you want is probably not a counter but scenes. Every escalation of the spookiness would be a new scene. That way, you can do constructions like

[code]The bloody prints are scenery. The description is “They’re all different shapes and sizes. Each print must be a different missing kid. There must be hundreds of them!”
The bloody message is scenery. The description is “The message is written in blood. ‘You[’]re next.’”

The Really-Full-On-Exorcist-Event is a scene. The Really-Full-On-Exorcist-Event begins when three artifacts are handled.
When the Really-Full-On-Exorcist-Event starts:
now the bloody prints are in the hallway;
now the bloody message is part of the mirror.[/code]

The reason I keep bringing up the counter is that depending on what you want to do, a number tracker of that kind could make the code more difficult to understand.

counters i understand. i tried to learn C++ in college to make video games and the counter thing is easy to me.

reasonone is a counter,

if i want reasonone to happen

i set it to one.

get a variable for everything!

show it, one. don’t show it, zero! like a light switch :smiley:

Oh, I fully understand. I primarily work in C++. The issue in this particular instance is that counters actually make it more difficult.

You can use counters to keep track of the spookiness level, and it works fine for messages. What it doesn’t do is help you when it comes to moving objects and rearranging the stage. Scenes would help better for that, so you’re going to need something like it anyway, and if you already need scenes, the counters become redundant.

I could of course be wrong, but to my experience, I’ve rarely find myself needing plain numeric values in Inform 7.

Also, you can have truth states that vary, i.e., boolean 0/1 variables. More suited to what you’re describing, methinks. Or you can define states! If something can be open or closed; if a person can be awake or asleep; if the player is in the waking world or the dream world. But wait! Instead of a variable to see in which world they are, you can lump rooms into regions and check to see which region they’re in!

…I’m just further illustrating what Eleas is saying. :slight_smile: Counters are great stuff, but in I7, although you can use them, there’s usually other ways - in-built ways - to get the same result.

Yeah, Peter has the right of it. I may actually have begun leaning too far in the other direction: the “kinds of value” functionality (“Heat is a kind of value. The heats are cold, lukewarm, warm and incandescent.”) just look so nice that I end up using them where they don’t actually belong.

That’s the fun thing about learning new languages, I guess: you pick up a shiny new hammer, and suddenly everything starts looking nail-like.