Creating an event

I’m new to I7 and I have been self teaching. I’ve done pretty well until i ran into this problem:

Basically, I have the player starting at the beginning of a maze and if they go north a rabbit will appear in certain rooms. same if the go either east or south. i want it to make it look as if the rabbit is leading the player through the maze so i can’t have the rabbit appearing in other rooms if the player decides to side track. Well here is a copy of what i have:

[b]Follow the Rabbit is a Scene.

Follow the Rabbit begins when the player enters either Hedge1, Hedge15 or Hedge3.
if the player enters Hedge1, say “You see the white rabbit disappears down the path heading north.”
After entering Hedge9, say “The white rabbit waits for you impatiently and upon seeing you, disappears to the path going east.”
after entering Hedge11, say “The white rabbit motions at you and hops down the path heading south.” ;
if the player enters Hedge15, say “The white rabbit waits for you impatiently and, upon seeing you, disappears to the path going north.”
After entering Hedge17, say “The white rabbit motions at you and hops down the path heading south.” ;
if the player enters hedge3, say “You see the white rabbit disappears down the path heading east.”
After entering Hedge16, say “The white rabbit waits for you impatiently and upon seeing you, disappears to the path going north.”
After entering Hedge17, say “The white rabbit motions at you and hops down the path heading south.”

Follow the Rabbit ends when the player is in the Clearing.[/b]

Can anyone help? I am really really lost and i looked over new rules, if, text and such in the manual in the program but it doesn’t help.

-Spice

Being a novice myself, what I venture is mainly guesswork. That said, I think the problem you have here is conceptual in nature. First, I’ll just formalize the problem to remove ambiguities.

You want:

  • A maze of some sort.
  • A rabbit in the maze. The rabbit leads the player through the maze.
  • The rabbit will only be visible when the player is in one of the rooms constituting the proper path.
  • As for hinting, the rabbit will do so by exiting in the correct direction.

Given that, I think you would be better off defining the path the rabbit wants you to take - in other words, where it would appear - and then (during the “find-the-way” scene) create some type of function or activity to make the rabbit act as it should in the appropriate rooms. The way you’re doing it right now is basically to abandon the world model and print messages disconnected from it. That can work, but it’s often unnecessarily hard work, and can be difficult to bug-test.

You might as well concatenate the description text, as well, like so (you’d need to define the “chosen exit” term):

Table of lagomorphic communion Byline "You see the white rabbit disappearing down the path heading [chosen exit]." "The white rabbit waits for you impatiently and upon seeing you, disappears to the path going [chosen exit]." "The white rabbit motions at you and hops down the path heading [chosen exit]."

…that is, if you even need a table for something like that. But in case you want to vary the descriptions, there you go. Plus, I like lagomorphs.

(NOTE: This is all off the top of my head. I can’t get to my I7 at the moment, otherwise I’d have error-checked by compiling it. Hopefully, it’ll be instructive in some way, regardless.)

Thank you i will try that.
Just one question, Well, two actually.

What do i do with the Chosen exit part?

And how do i say what exit i wish to use and which room i wish this to appear?

Gah. Sorry about that. The thing is, I skimmed past a lot of things that I thought you’d do anyway. Since this wasn’t the Inform 7 part of the forum, I thought I’d keep things reasonably brief. But that meant I couldn’t be very precise or informative. I’ll try to do better in this post, and hope it’s okay with Merk.

The first term, “chosen exit”, was something I came up with. The idea is, you create a term called “chosen exit” (you can of course call it something entirely different). “Chosen exit” is of the direction type - that is, it can be north, south, etc… It represents, at any given time it’s used, the direction the rabbit wants you to go.

This demonstrates the technique:

"Maze" by Björn Paulsen

[the rooms of the maze]

Origin is a room. The player is in Origin.


[Borrowed from Example 125 - Bee Chambers]

A Maze Chamber is a kind of room. The printed name of a Maze Chamber is usually "A section of maze". The description of a Maze Chamber is usually "You are in a forest maze, surrounded on all sides by tall, green hedges.[paragraph break][the exits]"


Maze 1, Maze 2, Maze 3, Maze 4, and Maze 5 are Maze Chambers.

[Nothing incredibly arcane here, all the magic in 125 was actually cut]





[Setting the path manually because I'm too tired to do it procedurally]

Maze 1 is west of Origin and south of Maze 2. Maze 3 is east of Maze 2 and west of Maze 4. Maze 5 is north of Maze 4.

Destination is a room. Destination is east of Maze 5.




[Some magic, courtesy of Example 103 - Bumping into Walls]

Definition: a direction (called thataway) is viable if the room thataway from the location is a room. 

To say the exits:
	let count of exits be the number of viable directions;
	if the count of exits is 0, say "You appear to be trapped in here.[run paragraph on]";
	if the count of exits is 1, say "From here, you can only go [list of viable directions].[run paragraph on]";
	otherwise say "From here, you can go [list of viable directions].[run paragraph on]" 

[This lists the available exits, which may be useful]



Pathing is an action applying to nothing. Understand "path" as pathing.


Carry out pathing:
	say "[chosen exit]".




[Now, the bunny path]

Golden Path relates various rooms to various rooms. The verb to lead to (he leads to, they lead to, it will lead to, she has lead to) implies the Golden Path relation. 



Origin leads to Maze 1. 
Maze 1 leads to Maze 2. 
Maze 2 leads to Maze 3. 
Maze 3 leads to Maze 4. 
Maze 4 leads to Maze 5. 
Maze 5 leads to Destination.

[This is a poor way of doing it. Better would probably be to create a maze programmatically in some way, instead of by hand, then track a good path, then have the rabbit traverse the path one step at a time, only continuing as long as it can see you.]





To say chosen exit:
	let M be the next step via the Golden Path relation from the location to Destination;
	let way be the best route from location to M;
	say "You should go [way].".
	
	
	

Test me with "path/w/path/n/path/e/path/e/path/n/path/e".

As I indicated in the comments, it’s a pretty bad way of doing it. If you want the rabbit to lead your character, but not backtrack, consider having the rabbit implemented as an animal. You define a new relation similar to the golden path, but you only define the start (“origin” in my example) and the end (“destination” in my example).

Now. Every turn when the rabbit can see you, have the rabbit use a “next step” type of connection to move one room closer to its goal. Report this so the player can see that the rabbit was there, but is no longer present. That way, the rabbit will see the player, say something, and then move on.

As you can see above, I didn’t bother creating the rabbit, but created a “path” command that more or less created a compass. The technique is the same, though, and I thought this way would be easier to demonstrate that yes, you can link together rooms by relations, and the relations can then be used in path-finding.

Is this something along the lines of what you wanted?

EDIT:
As for the maze itself - what I mean by programmatical creation is that you probably don’t want to create the entire maze by hand. It should be much more effective to make a program loop so the computer places the rooms. But that’s probably something for another time, so I did it by making the rooms by hand.

Yes! this would work! THANK YOU!

To say I’m a noob would be an understatement. This is my very first story. My father introduced this to me just a couple of months ago (with Zork 1) and i wanted to try writing one.

Thank you so much for your help. You explained in very nicely and even showed me how to go on with the next steps. Plus you taught me a new techinque. Thank you!

No problem, I’m happy that I could help. I’ve yet to finish my first game (practise game or real one), but I’ve learned a lot from the good people on the forum. Don’t be afraid to experiment, and if you want to know something, just ask around on the Inform 6/7 section of the forum. You’ll be in good hands there.

A tip, by the way: if you find that I7 behaves weirdly, and you want to ask about that, see if you can make a game that demonstrates the problem. Post that as an example.

Take myself, for instance. A few months back, I had a problem with possessive pronouns. If you made something a part of a person, you couldn’t refer to the part as being (for example) John’s part. So when I asked for help, I described the problem as follows:

"Written on the body"
A body part is a kind of thing.
A face is a kind of body part. A face is part of every person.
A pimple is a kind of body part. A pimple is part of every man.

Definition: a person is other if it is not the player.
Definition: a thing is selfish if it is part of the player and the player can see an other person.
Does the player mean doing something when the noun is a selfish thing: it is very unlikely.

The Hall of Testing is a room. "This place is curiously empty."
Manny is a man in the Hall of Testing. The player is Manny.
Jane is a woman in the Hall of Testing. "Jane is here. She's, most emphatically, not you."

Test me with "look at Jane's face/look at your face/look at pimple"

Thing is, this is just an example; no game I’ve written would focus on whether people had pimples or not. But since I had the little “test me” command at the end, anyone who wanted to answer my question or see what was wrong could simply copy the text into Inform 7, start the game, and then type “test me” to see the problem themselves.

That sort of thing can be a big help. It’ll also let other people play with the code easier, and respond much faster.

ok technically there is no problem (the program is working) but i can’t get the the rabbit to appear in any of the rooms. I am trying to figure out what i am missing to get it to work.

can you explain the purpose of this part?

To say chosen exit: let M be the next step via the Golden Path relation from the location to Destination; let way be the best route from location to M; say "You should go [way].".

i don’t fully understand it so i don’t know what i am missing

This is my current variation of that:

To say chosen exit: let M be the next step via the GoldenPath relation from the current location to Clearing; let way be the best route from location to M; say "The white rabbit waits impatiently for you and at your arrival, hops down the path heading [chosen exit]."

I also don’t understand the purpose of this either:

[code]Pathing is an action applying to nothing. Understand “path” as pathing.

Carry out pathing:
say “[chosen exit]”.[/code]

That’s because I didn’t put in a rabbit. What I posted was a demonstration of pathfinding. In other words, if you’re ON the path, the chosen exit is the path you take to go in the direction of the exit.

Your own game would require additional work.

That’s the part you’re going to need. It means:

  • the variable named “M” now means the next step from where the player is right now (the location) toward the room called “Destination”. The next step uses the Golden Path relation, which I described just above that code. So basically, the first row makes M become the nearest room you should go to in order to get closer to the Destination.
  • Now that we have the room, we have to find the direction it’s in. So now, we let the variable named “way” become the best route from the location (where we are) to M.
  • The last row simply prints this direction.

But you’ll need a variation of the code that actually returns not indexed text (a “say” phrase) but an actual direction. Then, as soon as the rabbit is in the same room as the player (while in the maze), move the rabbit in the direction you just calculated. Then, you should be able to write a “report the rabbit exiting” rule that looks like what you wanted.

Well… I suppose you could make this work in that way, but I’d recommend instead that you try to use the code above not to say the direction. Instead, you’d want to create an actor, and then make it move in the correct direction as soon as the player is in the same room. As it is now, the rabbit isn’t really there at all.

True, that’s not going to do exactly what you want, either. Essentially, I created a command. In my example, I didn’t want to mess about by creating an animal and asking it to move around (I was tired), so I just made a command to allow the player to find the correct direction they should go by typing “path”.

An “action applying to nothing” is simply a command in the game. When you type “look” in Zork, that’s an action applying to nothing. The next statement, “understand”, means that when someone types “path”, the command will activate.

Carry out is a rule telling what happens when we use the command. It uses the “to say chosen exit” code.

Anyway, my point is, the quick example has elements of the same thing as what you want. You’re not going to be able to do what you want by copying my code; you’re probably going to have to change a few things. But essentially, this is how finding the way through a maze can be done.

A person works. Three subtypes of person is man, woman and animal, so you could use an animal too, I guess. Anyway, you might create an “every turn” rule for that.

Anyway, since I couldn’t sleep, I thought I’d try writing up something along the lines of what you wanted. Bear in mind that there are probably bugs here and there. Anyway, here’s my attempt.

"Rabbitato" by Björn Paulsen


Section One - Maze Plantation

[the rooms of the maze]

Origin is a room. The player is in Origin. The description of Origin is "Not much to see here, really."


A Maze Chamber is a kind of room. The printed name of a Maze Chamber is usually "A section of maze". The description of a Maze Chamber is usually "You are in a forest maze, surrounded on all sides by tall, green hedges."


Maze 1, Maze 2, Maze 3, Maze 4, and Maze 5 are Maze Chambers.
Maze 6, Maze 7, Maze 8, Maze 9, and Maze 10 are Maze Chambers.



[Rooms placed by hand.]

Maze 1 is west of Origin and south of Maze 2. Maze 3 is east of Maze 2 and west of Maze 4. Maze 5 is north of Maze 4.

[Creating random passages.]

Maze 6 is north of Maze 2 and east of Maze 7.
Maze 8 is south of Maze 4 and west of Maze 9.
Maze 10 is west of Maze 5.

[Finally, the destination]

Destination is a room. Destination is east of Maze 5. The description is "This is the wondrous place of Destination, where all your dreams come true."






Section Two - Printing available exits


[Some magic, courtesy of Example 103 - Bumping into Walls]

Definition: a direction (called thataway) is viable if the room thataway from the location is a room.

To say the exits:
	let count of exits be the number of viable directions;
	if the count of exits is 0, say "You appear to be trapped in here.";
	if the count of exits is 1, say "From here, you can only go [list of viable directions].";
	otherwise say "From here, you can go [list of viable directions]."

Every turn:
	say "[the exits][run paragraph on]".







Section Three - Bunnies Behaving Oddly


[Now, the activity. This finds the path, and each time it's triggered, the rabbit goes one step closer to the goal.]

Rabbit-stepping is an activity.

For rabbit-stepping:
	if the location is not Destination:
		let chosen path be the best route from the location to the Destination;
		try the rabbit going the chosen path.




[The rabbit]

The white rabbit is an animal. The rabbit is in Origin. The description is "White, fluffy, and gifted with an incredible sense of direction."



[The scene. The idea is that we restrict the rabbit's wandering to only happen until we're through the labyrinth.

Scenes are awesome. You can hook anything into the scene. For instance, you can trigger behavior by the ending of a scene.]

Dances-With-Bunnies is a scene. 
Dances-With-Bunnies begins when the player is in Origin. 
Dances-With-Bunnies ends when the player is in Destination.


[Restricting the behavior to only happen during the scene]

Every turn during Dances-With-Bunnies:
	if the white rabbit is in the location:
		carry out the rabbit-stepping activity.

[Example of triggering behavior]

When Dances-With-Bunnies ends:
	say "The white rabbit nods gravely at you, then hops off into the sunset.";
	now the rabbit is off-stage.



[Replacing the "Report going" text with our own requires us to get the direction to where the rabbit went. So we have to repeat the instruction for finding directions earlier, more or less. It's a bit ugly, but I could find no better way on short notice.]

Report the rabbit going:
	let the chosen exit be the best route from the location to the holder of the rabbit;
	say "[one of]You see the white rabbit disappearing down the path heading [chosen exit].[or]The white rabbit waits for you impatiently and upon seeing you, disappears to the path going [chosen exit].[or]The white rabbit motions at you and hops down the path heading [chosen exit].[at random]" instead.

Was this more along the lines you wanted?

Edit: Odd - I answered a post you made, but that post seems to have disappeared. Regardless, I hope this is something you can find a use for.

I was try you activity but i couldn’t get it to work so i had to delete it. So i had to create something different (based off of the Odyssey example in the inform recipe book) However
that wouldn’t work with the scene so i have to delete that too. (which is a shame)

Well anyway this is what i have.

[code]
Table of White Rabbit’s Movements
Hedge Maze Entrance
Hedge1
Hedge7
Hedge8
Hedge9
Hedge10
Hedge11
Hedge12
Clearing

Every turn when White Rabbit is active:
Repeat through the table of White Rabbit’s Movements
Let the Last space be the location of White Rabbit;
If White Rabbit can be seen by the player, say “[one of]You see the white rabbit disappearing down the path heading [chosen exit].[or]The white rabbit waits for you impatiently and upon seeing you, disappears down the path going [chosen exit].[or]The white rabbit motions at you and hops down the path heading [chosen exit].[at random]”
Move White Rabbit to destination entry;
Blank out the whole row;
Rule succeeds.

White Rabbit can be active or passive. White Rabbit is passive.

Every turn the white rabbit can be seen by the player:
Change White rabbit to active.

(this part won’t work for me)[/code]

I am trying to make the rabbit only be active when it is seen by the player but i don’t know how to do it.

Can you help?

Well, firstly, you lack a lot of colons and semicolons in the syntax. That would make the program impossible to run. Is that the problem?

Secondly, I’m not sure what you’re saying. If the code doesn’t do what you want, then of course you may need to write something else. If you can’t get the code I wrote to run at all, the problem can be two things: either you pasted the code I wrote without correcting the tabs (this forum converts tabs to spaces, which ruins the code), or you’re running an older version of Inform 7.

Does the code I sent compile on your computer at all? What version of Inform are you running?

I’m running GNU General Public License, version 3 on a Linux.

And your scene did work. The activity didn’t and i am such a noob that without a working example i don’t know how to fix it. Also i’ve corrected my code since my last posting so that part at lest works. what i have currently is that the rabbit only moves when it is active. i’m trying to make it so that the rabbit is only active when the player can see him. ( that way the rabbit wouldn’t run off without the player.)

Every turn: If the white rabbit can be seen by the player then change white rabbit to active; Otherwise: the rabbit is passive.
any ideas? right now i am combing through the manual/recipe book for examples/ideas i can use.

Allright, but which version number? If you’re using the very latest, that should be 6E72. If you have an earlier version, especially 6E59, that may be the reason why things fail to work.

Wait, maybe we’re saying different things. I’m saying the last example I gave is a complete one. I.e., in my version of Inform (6E72 running in Windows 7), what I presented to you is the full example game, and (for me) it compiles without error. If you copy and paste the code I submitted into an empty Inform project, that code ought to run without error message.

So this is a bit weird and interesting. When you try to run the code, what error messages do you get? Does it happen when you try to compile, or does something odd happen at runtime (in the game itself)? Did you try using the entire code I gave you, or did you only use pieces? Alternatively, did you add your own modifications right away, before trying to see if it works?

Any of those things might change the result. Since I can’t tell what you have, I can’t really give much in the way of advice, I’m afraid.

I see. If you want that, you don’t have to switch between active and passive. Really, all you have to do is something like this:

Definition: the rabbit is active if the player can see it. Definition: the rabbit is passive if it is not active.

That means you can do something along the lines of “every turn when the rabbit is active…”, without having to manually check whether it’s in the same room.

Easier, maybe, to use a simple phrase, something like “every turn when the player can see the rabbit and Follow-the-Rabbit is happening…” followed by getting the right direction and moving the rabbit thataway. But not having seen the code you have right now, I can’t be sure if that’s what you’re looking for.

umm… i’m using 5Z71. (is that what you mean? when i go to About it says GNOME inform 7 5Z71)

and i tried out your code first (i don’t use copy and paste but i do copy it). Afterwards i start to mess with it, building off of it. (fixing if it doesn’t work- or trying to)

oh and earlier i just copied the error thing down for you to see. it is in one of my earlier posts. I can copy another one down though.

by the way, how do i can i make the rabbit push the player down a hole?

Oh yes indeed. :slight_smile: That’s good news. I’d actually recommend you install the newest version. There’s been a lot of improvement, and (at least on the Windows 7 version) I feel 6E72 runs significantly faster (as in, compiling in less than half the time compared to before).

Come to think of it, that could be the reason: it’s quite possible that the examples I gave you won’t run on 5Z71. I’d recommend installing the latest version, really; it doesn’t take long, and I for one was very impressed with the changes.

That’s a good solution. Expanding on that, a good technique for when you have a project is to make a small game with just that functionality and nothing else. That way, you can quickly isolate how it’s done and what works. When it works, you paste it into the real game.

I think that may be it. If there was an error and you put the tabs right, the problem is probably because something changed between 5Z71 and 6E72 (or 6E59). In other words, it’s quite possible you’re doing everything right at your end.

As for making the rabbit push a player down the hole… hm. It depends. If you don’t need to let the player try to stop the rabbit or react in anyway, the push is basically “unblockable,” right? If so, it’s probably easiest just to make the “rabbit pushes you” event something that would move the player to the new location (bottom of hole, maybe?), while at the same time printing a message saying what happened. Again, you can fire this sort of event when the player is in the same room as the rabbit, when that room is the room with the hole in it.

You don’t really have to model any complex behaviour if this is the case. Describing how the player falls down and lands with a thump at the bottom of a dark hole would do the trick, yeah? Then the player finds himself/herself at the bottom of the hole. And then the next turn begins.