intfiction.org

The Interactive Fiction Community Forum
It is currently Thu May 23, 2013 12:22 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Thu May 03, 2012 4:11 am 
Offline
User avatar

Joined: Sun Mar 27, 2011 9:01 am
Posts: 115
Location: South Australia
Code:
Check going east:
   if the window is unvisited:
      say "blah.";
      now the window is visited;
      stop the action;
   otherwise:
      say "blahdy blah.";
      end the game saying "You have died.".
      
Check going east when the player is on the broom:
   say "blahdy blah blah blah.";
   now the player is in the town.


I would have thought that the second "check going" rule (the one with the broom) would come first, since it is more specific than the first "check going" rule, but that doesn't seem to be the case. The first rule is the one that is always followed. So the first time the player goes east I get my "blah" warning, and the second time the game ends.

This is what I want except when riding the broom, but even when riding the broom I get the same message. :(

How do I make "check going east when the rider is on the broom" run at a higher priority than the first "check going" rule.

_________________
Ever stop to think and forget to start again?


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 5:18 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
Actually, I believe both rules are firing because the "check going east when the player is on the broom" rule doesn't stop the action. This should work.

Code:
Check going east:
   if the window is unvisited:
      say "blah.";
      now the window is visited;
      stop the action;
   otherwise:
      say "blahdy blah.";
      end the game saying "You have died.".
      
Check going east when the player is on the broom:
   say "blahdy blah blah blah.";
   now the player is in the town instead.


Also I'd suggest coding it like this so it's easier to see what's going on.

Code:
Check going east:
if the player is on the broom begin;
say "blahdy blah blah blah.";
now the player is in the town instead;
otherwise if the window is unvisited;
say "blah.";
now the window is visited instead;
otherwise;
say "blahdy blah.";
end the game saying "You have died." instead;
end if.


Hope this helps.

_________________
"Will you stop breaking the fourth wall? It's costing me an absolute fortune to replace it!"


Last edited by climbingstars on Thu May 03, 2012 5:54 am, edited 1 time in total.

Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 5:51 am 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 986
Location: Gothenburg, Sweden
Tanga wrote:
I would have thought that the second "check going" rule (the one with the broom) would come first, since it is more specific than the first "check going" rule, but that doesn't seem to be the case. The first rule is the one that is always followed.


The more specific rule should run first (though, since its a check rule rather than an instead rule, it won't stop the action, and the less specific check rule will run as well). I suppose there is something else in your code that messes this up – like something that prevents the condition of the specific rule preamble ("when the player is on the broom" or whatever) from being true in the first place.

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 6:15 am 
Offline
User avatar

Joined: Sun Mar 27, 2011 9:01 am
Posts: 115
Location: South Australia
I've tried various ways of writing it, so you must be right Felix. I have changed the code to the following (I think I had this at some point, I've tried a few versions of this code).

Code:
Check going east:
   if the player is on the broom:
      say "You skim through the window on the broom, your knees brushing the sides of the window.";
      now the player is in the town instead;
   otherwise:
      if the window is unvisited:
         say "You lean out the window.  It's a long way down.  Your head spins and to save yourself you grab hold of the ledge.";
         now the window is visited;
         stop the action;
      otherwise:
         say "Seeing no other alternative you climb up onto the edge.  You spring out and away from the window.  Just you and the sky.  Then the ground.";
         end the game saying "You have died.".


Is 'on the broom' correct code? I have tried 'if the player is riding the broom' instead, but that doesn't parse. Is there another way of writing it?

I'm using the 'rideable vehicles' code by Graham...

_________________
Ever stop to think and forget to start again?


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 6:17 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
Felix wrote:
I suppose there is something else in your code that messes this up – like something that prevents the condition of the specific rule preamble ("when the player is on the broom" or whatever) from being true in the first place.


I don't see what you're getting at here. From what I've seen, both rules fire when the player is on the broom.

Code:
"Test"

Check going east:
if the window is unvisited begin;
say "blah.";
now the window is visited instead;
otherwise;
say "blahdy blah.";
end the game saying "You have died.";
end if.
    
Check going east when the player is on the broom:
say "blahdy blah blah blah.";
now the player is in the town.

The Testing Room is A Room. The Window is east of The Testing Room. The Town is east of The Window. The broom is an enterable supporter in the testing room.

Test me with "e / enter broom / e".


Here, "blahdy blah blah blah." is printed, the player is moved to the town, next "blahdy blah." is printed and then the game ends. Therefore both rules are firing.

_________________
"Will you stop breaking the fourth wall? It's costing me an absolute fortune to replace it!"


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 6:20 am 
Offline
User avatar

Joined: Sun Mar 27, 2011 9:01 am
Posts: 115
Location: South Australia
Oops - just changed it back from 'rideable animal' to 'rideable vehicle' and it works again. Must be something to do with the location of the player when riding an animal. Though 'in' doesn't work either. I kind of wanted the broom to have animal like reactions when being interacted with, but I guess it will be best to write my own exceptions to 'touch' etc.

Thanks

Does anyone know where the player is when in relation to a rideable animal?

_________________
Ever stop to think and forget to start again?


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 6:28 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
Tanga wrote:
Is 'on the broom' correct code? I have tried 'if the player is riding the broom' instead, but that doesn't parse. Is there another way of writing it?

I'm using the 'rideable vehicles' code by Graham...


It sure is!

Rideable Vehicles by Graham Nelson wrote:
Code:
A rideable vehicle is a kind of supporter.


Therefore you can treat a rideable vehicle as a supporter. This seems to work OK.

Code:
"Test"

Include Rideable Vehicles by Graham Nelson.

Check going east:
if the player is on the broom begin;
say "You skim through the window on the broom, your knees brushing the sides of the window.";
now the player is in the town instead;
otherwise if the window is unvisited;
now the window is visited;
say "You lean out the window.  It's a long way down.  Your head spins and to save yourself you grab hold of the ledge." instead;
otherwise;
say "Seeing no other alternative you climb up onto the edge.  You spring out and away from the window.  Just you and the sky.  Then the ground.";
end the story saying "You have died." instead;
end if.

The Testing Room is A Room. The Window is east of The Testing Room. The Town is east of The Window. The broom is a rideable vehicle in the testing room.

Test me with "e / enter broom / e".


Hope this helps.

_________________
"Will you stop breaking the fourth wall? It's costing me an absolute fortune to replace it!"


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 6:44 am 
Offline

Joined: Wed Feb 29, 2012 2:00 pm
Posts: 674
Tanga wrote:
Oops - just changed it back from 'rideable animal' to 'rideable vehicle' and it works again. Must be something to do with the location of the player when riding an animal. Though 'in' doesn't work either. I kind of wanted the broom to have animal like reactions when being interacted with, but I guess it will be best to write my own exceptions to 'touch' etc.

Thanks

Does anyone know where the player is when in relation to a rideable animal?


Rideable Vehicles by Graham Nelson wrote:
Code:
A rideable animal is a kind of animal.


Therefore, since a rideable animal is defined as an animal, the player would be carried by the rideable animal. Unusually, you're not defined as "on" the rideable animal. I guess it's the same way as the player's possessions aren't "on" but "carried by" the player. In essence, the player is in the rideable animal's inventory. "In" won't work with any of them, because you're meant to be on a rideable vehicle or carried by a rideable animal. So, if you wanted to use the broom as a rideable animal, then you'd want to use something like this.

Code:
"Test"

Include Rideable Vehicles by Graham Nelson.

Check going east:
if the player is carried by the broom begin;
say "You skim through the window on the broom, your knees brushing the sides of the window.";
now the player is in the town instead;
otherwise if the window is unvisited;
now the window is visited;
say "You lean out the window.  It's a long way down.  Your head spins and to save yourself you grab hold of the ledge." instead;
otherwise;
say "Seeing no other alternative you climb up onto the edge.  You spring out and away from the window.  Just you and the sky.  Then the ground.";
end the story saying "You have died." instead;
end if.

The Testing Room is A Room. The Window is east of The Testing Room. The Town is east of The Window. The broom is a rideable animal in the testing room.

Test me with "e / enter broom / e".


Hope this helps.

_________________
"Will you stop breaking the fourth wall? It's costing me an absolute fortune to replace it!"


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 7:37 am 
Offline
User avatar

Joined: Sun Mar 27, 2011 9:01 am
Posts: 115
Location: South Australia
Yup! Now it works. :) - Thanks!

_________________
Ever stop to think and forget to start again?


Top
 Profile Send private message  
 
PostPosted: Thu May 03, 2012 7:49 am 
Offline
User avatar

Joined: Thu Nov 04, 2010 6:30 am
Posts: 986
Location: Gothenburg, Sweden
climbingstars wrote:
Felix wrote:
I suppose there is something else in your code that messes this up – like something that prevents the condition of the specific rule preamble ("when the player is on the broom" or whatever) from being true in the first place.


I don't see what you're getting at here.

Well, something quite like this:
climbingstars wrote:
since a rideable animal is defined as an animal, the player would be carried by the rideable animal. Unusually, you're not defined as "on" the rideable animal. I guess it's the same way as the player's possessions aren't "on" but "carried by" the player.

;)

_________________
Man ska inte tro allt man tänker.


Top
 Profile Send private message  
 
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: No registered users and 1 guest


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