intfiction.org

The Interactive Fiction Community Forum
It is currently Tue Dec 11, 2018 3:13 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Nov 07, 2018 5:17 pm 
Offline

Joined: Sat Oct 27, 2018 6:35 pm
Posts: 36
Hello! I'm getting this error when trying to create a character who follows the PC through a door.

Code:
You'll have to say which compass direction to go in.
I didn't understand that instruction.

My code is directly copied from the example with Dracula, and I've put in a print statement...

Code:
Every turn:
   if the location of Dracula is not the location of the player:
      let the way be the best route from the location of Dracula to the location of the player, using doors;
      say "Going [the way] from [the location of Dracula]";
      try Dracula going the way.

...which prints "[the way]" as "nothing". He seems to be able to move to the nearest room with no door between and wait there, but not to pass through a door. (Perhaps I need to invite him? /joke)

Any idea what's going on?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Nov 07, 2018 5:49 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 379
Your code works for me. Maybe there's a problem with one of your map connections? (The index map might give a hint.)


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Nov 07, 2018 6:42 pm 
Offline

Joined: Sat Oct 27, 2018 6:35 pm
Posts: 36
All the rooms in the index are definitely connected as far as I can tell. (Room 1 contains door to room 2, room 2 contains door to room 1, etc.) Is there anything in particular I should be looking for?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Nov 07, 2018 7:44 pm 
Offline

Joined: Mon Dec 15, 2014 9:15 am
Posts: 379
Is it one particular door that causes the problem? Or is it failing with all doors?

If it's just one door, do you have any code affecting that door specially? Can you as the player go both ways through the door without a problem?

I can't think of anything else off-hand. Feel free to post your code.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Wed Nov 07, 2018 10:41 pm 
Offline

Joined: Sat Oct 27, 2018 6:35 pm
Posts: 36
It's just this door (as of some other changes I made). So, I tried moving up all the room and door declarations and relations to make sure they were before this code, and I thought that would solve the problem (maybe it did for one door, I don't remember) but I continued having trouble. (This door was inside/outside, not sure if it made a difference.) Of course, when I dumped the sample code in a new document and ran it, it worked just fine, so THEN I tried commenting out bits of the full source bit by bit, and it's some leftover unused code from the tutorial that's messing things up for reasons I cannot fathom.
Code:
The screen door is lockable, closed and locked

Now, this door was a door to nowhere from a room two rooms over and inside from the one that "Dracula" wasn't following the PC into, so who knows!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Nov 08, 2018 12:00 pm 
Offline

Joined: Sun Feb 17, 2008 3:51 pm
Posts: 300
Hey Kit,

I figured out what you did, but in the future it would help if you posted the smallest complete example of code which reproduces your problem. If you're worried about posting a long bit of code -- don't. (Worry, that is.) If you're still worried, put the code box inside a spoiler box like this:
Spoiler: show
I think you did something like this:
Code:
"Van Helsing"

The Drawbridge is a room.
[Took out this:]
[North of the Drawbridge is the Immensely Enormous Entry Hall. West of the Entry Hall is the Vast Dining Area.]
North of the Vast Dining Area is the Colossal Kitchen. The Spooky Guano-filled Attic is above the Entry Hall.

Count Dracula is a man in the Attic.

Every turn:
   if the location of Count Dracula is not the location of the player:
      let the way be the best route from the location of Count Dracula to the location of the player, using doors;
      say "Going [the way] from [the location of Dracula]";
      try Count Dracula going the way;
   otherwise:
      say "'Muhahaha,' says Count Dracula."

[Added this:]
The Immensely Enormous Entry Hall is a room.       
The screen door is a door. It is inside from the Drawbridge and outside from the Entry Hall. The screen door is lockable, closed and locked.

resulting in this:
Quote:
Drawbridge
You can see a screen door here.

>z
Time passes.

Going nothing from the Spooky Guano-filled Attic
You'll have to say which compass direction to go in.
I didn't understand that instruction.

Try changing your every turn rule to this:
Code:
Every turn:
   if the location of Count Dracula is not the location of the player:
      let the way be the best route from the location of Count Dracula to the location of the player, using even locked doors;
      say "Going [way] from [the location of Dracula]";
      try Count Dracula going the way;
   otherwise:
      say "'Muhahaha,' says Count Dracula."

and you get this:
Quote:
Drawbridge
You can see a screen door here.

>z
Time passes.

Going down from the Spooky Guano-filled Attic

That "even locked doors" bit will get you every time. (It's in the phrasebook part of the index under "route-finding" FYI.) Notice I also changed "[the way]" to just [way]" but since you just put that in for debugging purposes, it wasn't really necessary. Having "the down" in the output just bugged me. :)

HTH

[edit] PS - Oh yeah -- the reason "the way" showed up as "nothing" is because there is no route using (unlocked) doors in the original code, so nothing is the correct result.

_________________
Skinny Mike


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 10, 2018 7:09 pm 
Offline

Joined: Sat Oct 27, 2018 6:35 pm
Posts: 36
So it was giving me this error because a locked door existed, even though the route from Dracula to me wouldn't have gone through it? I'm still not sure I can follow the logic of that. What if I want to have locked doors in my game but I don't want someone to be able to follow the player through them?


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 10, 2018 7:55 pm 
Offline

Joined: Sat Jan 23, 2010 4:56 pm
Posts: 5832
No, there was probably some ambiguous declaration that caused the compiler to think the screen door was the same as some other door.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Nov 10, 2018 8:16 pm 
Offline

Joined: Sat Oct 27, 2018 6:35 pm
Posts: 36
Thanks!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Nov 15, 2018 12:14 am 
Offline

Joined: Fri Oct 18, 2013 10:13 am
Posts: 2669
Location: The Midwest
Just to add, it's generally a good idea to add an "if the way is a direction:" check to code like that. Just in case, for example, the player locks themself into a room on their own, and some code that expects "going" to always take a direction suddenly finds itself confronted with "nothing".

_________________
Daniel Stelzer


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group