The problem is with the statement âYou would have to get out of a brown quarterhorse first.â
Horse is treated like an enterable vehicle. Is there a quick fix for this?
I think this is because the allow rideables to be going vehicles rules rule has already fired (and failed) when going on foot, and so the rideable doesnât become a going vehicle.
Re-starting the going action lets the rule run again, so this works. Obviously youâll have to add tests to make sure the horse has been mounted, or itâll just infinitely re-run the action.
Before going when horse is not carrying player:
try mounting horse;
say "Clip clop.";
Try going noun instead.
Yup, this is the issue. Another approach would just be to manually call the allow rideables rule again, which might be cleaner:
Before going north in lab when the horse does not enclose the player:
Try silently mounting the horse;
say "You remount your horse and continue north.";
follow the allow rideables to be going vehicles rule.
(I added the âsilentlyâ since the default mounting report is redundant with the one you wrote, though per Stephenâs point, you might want to make that conditional on the horse actually being mounted!)
I was able to get it to work with the following, but it hurts my purist sensibilities.
Instead of going north in Clayborn Journey when horse is not carrying player:
try silently mounting horse;
say "You remount Bravo and continue north.[paragraph break]";
try silently going north;
I think the difference between Before rule and Instead rule, which throws away the initial command, is why it works.
Mike,
Yep, that works the same, but when I read the code later, I might forget what that fourth statement is actually doing. It does appease my sensibilities though.
Is there something in the Extension that could be added that might neutralize the need to add this statement to every Before rule?
The going action has a room called the room gone from (matched as "from").
The going action has an object called the room gone to (matched as "to").
The going action has an object called the door gone through (matched as "through").
The going action has an object called the vehicle gone by (matched as "by").
The going action has an object called the thing gone with (matched as "with").
Rule for setting action variables for going (this is the standard set going variables rule):
now the thing gone with is the item-pushed-between-rooms;
now the room gone from is the location of the actor;
if the actor is in an enterable vehicle (called the carriage),
now the vehicle gone by is the carriage;
let the target be nothing;
if the noun is a direction:
let direction D be the noun;
let the target be the room-or-door direction D from the room gone from;
otherwise:
if the noun is a door, let the target be the noun;
if the target is a door:
now the door gone through is the target;
now the target is the other side of the target from the room gone from;
now the room gone to is the target.
The Setting Action Variables rules run before the Before rules â they run before the action-processing rules of which the Before rules are a part even begin. If a Before or Instead rule (or other rule prior to the Check Going rules) invalidates those Going Action variablesâ values, youâre going to have problems, which you did.
This is what I might do. Iâm assuming you always know the horse is in Clayborn Journey when the player is, that neither of them will be on any supporters or in any containers, and that there will never be darkness or any reason why mounting would fail (as you can see, Iâm not even doing the mounting action per se, just moving the player to the horse).
The going action has a truth state called remounted.
Setting action variables for going: now remounted is false.
first check going north from Clayborn Journey when the player is not on the horse:
surreptitiously move the actor to the horse;
follow the setting action variables rules;
now remounted is true;
first report going when remounted is true:
say "You remount your horse and continue [noun].";
Iâm not sure itâd be appropriate to change Rideable Vehicles to anticipate this case, but I definitely think it would be appropriate to document those Going action variables and call attention to the perils of invalidating one mid-action.
I considered this, but Iâve been bitten in the past by this kind of thing, where thereâs some other rule that needed to be run and was missed, so I figured re-starting the action would do the trick.
Zed,
Thanks for this. The code philosophy here is quite different from what I use. It will take a minute for me to absorb this. I was not familiar with the âsurreptitiouslyâ adverb. I couldnât find it in the Docs either.
I think this will help me on a different issue too.
Revised in acknowledgment of Stephenâs justified qualms regarding fiddling with the action in situ vs. taking it from the top, my approach would becomeâŚ
remounted is initially false.
instead of going north from Clayborn Journey when the horse does not hold the player and remounted is false:
silently try mounting the horse;
if the horse does not carry the player, instead say "you couldn't mount your horse.";
now remounted is true;
try going north;
after going when remounted is true:
say "You remount your horse and continue [noun].";
now remounted is false;
The conditional I originally had, `the player is not on the horseâ, was wrong: I forgot that rideable animals carry you; itâs rideable vehicles that support you.
You want âcontinue the actionâ there, or else it will skip the room description of the destination.
if the horse does not carry the player, instead say "you couldn't mount your horse.";
If the mounting action fails because of a check rule, this will print a double refusal. (The failure message isnât silent even though you write âsilently try mountingâ.) E.g:
Check mounting the horse when the player is not wearing the cowboy hat:
instead say "The horse shies away.";
>remove hat
You take off the cowboy hat.
> n
The horse shies away.
you couldnât mount your horse.
This may or may not be what you want. If not, you could change the line above to
if the horse does not carry the player, instead stop the action;