Check going heirachy problem...?

[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.[/code]

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. :frowning:

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.

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.[/code]

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

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.

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.

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).

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…

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”.[/code]

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.

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?

It sure is!

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”.[/code]

Hope this helps.

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”.[/code]

Hope this helps.

Yup! Now it works. :slight_smile: - Thanks!

Well, something quite like this:

:wink:

That’s definitely a facepalm moment right there! :blush: