Logic for after entering a location

I am trying to get a some logic to work after the player enters a certain room. But this code:

After going to crawlspace:
	if first contact is true:
		say "Boo-ba-la-looba-ba-la.";
		continue the action;
	else:
		continue the action.

gets this result:

>in
Boo-ba-la-looba-ba-la.

Crawl Space
Dim and cramped. Definitely not the kind of place you would want as a bedroom.

But I am wanting the logic to happen after the room description. Any suggestions?

How are you defining first contact? Or is that the language that the parser is using?

First contact is a truth state that varies. That seems to be working fine. Boo-ba-la-looba-ba-la is only getting printed after first contact has been switched to true.

Looking after moving is a “report” rule. So I don’t think “after” can ever get in front of it.

You can do a “last report” rule.

Or you can do adaptive text in the description itself, which might be the tidiest thing.

the description of the lab is "This is really a nice lab.[if first contact is true][paragraph break]Boo-ba-la-looba-ba-la.[end if]"

e: the other alternative, since it is a looking action, is to hook that in with an

after looking in closet when first contact is true:
	say 'another alternative'

if this is only meant to print once, there are some possibilities for that specifically

2 Likes

I’m not the best (most efficient) coder, but I got this to work:

lab is a room.

Player is in lab

second lab is a room.  The description is "A generic room in a playtesting enviornment". lab is west.

First contact is a truth state that varies.  first contact is true

instead of going to second lab:
	now player is in second lab;
	if first contact is true:
		say "Boo-ba-la-looba-ba-la.";
		now first contact is false;
		stop the action;
	

So close but I have a last report going rule that’s in effect and the “now the player is in” does not fire that rule.

lab is a room.
parlor is north of lab. "xx"

last report going when the parlor was unvisited: say "qq".

The details are complicated, but, roughly speaking there’s a report going rule that invokes a looking action if it’s your first time seeing the room. So if you want something after that, you want last report going.

You don’t need first contact; using was with unvisited will cover it.

I wouldn’t recommend moving the player manually in an instead of going rule: that’s just inviting pain.

4 Likes

This is a case of the general rule “use try phrases whenever possible when you mean to produce an action.” (Or if appropriate, silently try)

1 Like

Just for my learning – what pain is the “instead” clause bringing? I use it sparingly as it is but would like to know what it invites.

I ended up adding the logic into an already existing last report going rule.

1 Like

It’ll short-circuit any before, check, after, and report rules that may exist. Case in point:

2 Likes

Thank you, I appreciate the explanation!

1 Like