If, unless: efficient syntax

Hi everyone, I’ve done some reading, clearly not enough, but I’m trying to maintain some momentum.

I have a simple phrase I’m trying to get right as efficiently as possible.

After going south:
move red crab to shallows;
unless red crab is taken;
continue the action;

Basically I want the red crab to move unless it has been taken. Likely “taken” is not the right condition, should it be in inventory or something. Maybe I can’t put stuff together like this…

Thanks in advance.

Probably:

After going south when the red crab is not carried by the player:
     move the red crab to shallows.

Just realize “after going south” will fire in every location unless you make it specific.

After going south from sandy beach when the red crab is not carried by the player...

That’s great. I appreciate the help. I write BASIC adventures 35 years ago. It’s taking some time.

Along those lines when i write

After examining small blue crab:
move blue crab to the shallows;
stop the action;

Do I need to specify
After examining small blue crab in shallows:

No, because you can only examine the small blue crab when you’re in the location with the small blue crab. You can go south (and thus trigger “after going south”) in any room that has a map connection leading south.

Also: After rules by default stop the action (essentially canceling the Report phase) so you don’t need to write “stop the action” in After rules. You’d need to write “continue the action” if you didn’t want it to stop.

Makes sense. The logic is coming back now.

I truly appreciate you taking the time to answer easy questions and help me keep moving forward.

Too many folks default response is “read the manual”. People like yourself are often the difference between flourishing and a spark of interest dying.

I hope I get knowledgeable enough to do the same for someone else in future.

2 Likes

Clarification: you don’t need to specify the location in this rule unless you want something special to only happen when you examine the small blue crab in the shallows as opposed to any other location.

The description of the small blue crab is "He's a crab who is also small and blue."

After examining the small blue crab when the location is Shallows:
     say "Hey, you can tell in the shallow water that the crab has a symbol painted on his shell!"

That’s exactly what I was just thinking! So if you take a thing out and look at it in a certain place you can progress the story.

Neat.

So I don’t need to have stop or continue in either of these statements?

After examining small blue crab:
	move blue crab to the shallows;
	*stop the action;*
After going south from beach when the red crab is not carried by the player:
	 move the red crab to shallows;
	*continue the action;*

An After rule will stop rule-processing unless you specify “continue the action”.

After examining the crab when the location is Shallows and the crab is not carried by the player:
     say "You notice the crab has an intricate symbol that only seems to appear when it is submerged in the water..."

Report examining the crab:
     say "Watch out for the pincers!"

In the above code, the player won’t see “Watch out for the pincers!” if the location is the Shallows and the crab is not carried by the player since After stops processing rules by default and Report rules occur after the After rules phase. You can change this by adding “continue the action” at the end of the After rule.

Ah.

That’s a tantalizing possibility.

I understand the syntax for After now but how would you implement a conditional for say needing to use tongs to pick up a piece of radioactive material?

I looked through the index and there didn’t appear to be a “use with” command so is this an “after” situation as well?

After getting the isotope when the tongs are carried by the player:
add isotope to inventory
otherwise:
say “that’s too dangerous.”

This is in addition to the other thread about the tongs, but here’s an answer in case you want to do something pretty old-school, where instead of having the player type “get isotope with tongs” you have them type “get isotope” and it works only if they have the tongs.

First of all, we need to say “taking the isotope”–as discussed in the other thread, the internal name of the action is taking.

Second, “After” is too late to intervene here–by the time you hit the “after” stage the normal action-processing stuff has already happened. Action processing goes before-instead-check-carry out-after-report; any “instead” and “after” rules stop the action unless you add “continue the action.”

So in this case we could just add a check to taking the isotope:

Check taking the isotope when the tongs are not carried: say "You need tongs to hold that." instead.

The word “instead” here stops the action. (It’s not quite the same as a rule starting with “instead.”)

So the effect is, if the player tries to take the isotope and they’re not holding the tongs, the check rule fires and interrupts the action with our message. If they are holding the tongs, the check rule gets skipped, and it goes through the built-in carry out rule (which moves the isotope to the inventory) and report rule (which prints “Taken.”)

Hope this is helpful!

1 Like