Noob needs help simulating a balance scale

The balance is a supporter in the Yellow Room.  Description of the balance is "A balance for measuring mass.  One side is loaded with weights totalling 12.4 kilograms."
Understand "scale" as the balance.
[The balance has carrying capacity 1.]

Levelness is a kind of value.  The levelnesses are off and on.  The balance has a levelness.  The levelness of the balance is usually off.

After putting the ingot on the balance for the first time:
	increase the score by 1;
	now the levelness of the balance is on;
	say "The balance levels out.  You hear a loud creaking sound from somewhere to the east.";
	change the down exit of the Black Room to the Sewer;
	change the up exit of the Sewer to the Black Room.

The Black Room is southeast from the Blue Room.  "The entire room is painted black.  An exit opens to the northwest.[if the levelness of the balance is on]  A secret exit has opened, leading down.[end if]"

I’m trying to create a balance scale that opens a secret passage and awards a point the first time an ingot is placed on it. If I don’t give the scale a carrying capacity of 1, then its behavior is not very balance-like in that it works when multiple objects are on the scale.

If I give the scale a carrying capacity of 1, then somehow the scale becomes broken; and placing another object on the scale and removing it before trying the ingot results in the ingot not triggering the secret door.

Any ideas on how I can change the code to make the balance function properly?

1 Like

The intent of the action rulebooks’ use is that the main effect of an action happens in a Carry out rule. After rules follow the carry out rules. By default, the action is stopped after the first applicable After rule fires, and you don’t go on to the Report rules where the normal “You put the thing on the other thing” message comes from.

And for the first time refers to the first attempt to do something, whether it succeeded or not. So if you have a carrying capacity of one, and something else already on the balance, and a player tries to put the ingot on, the rule would fire.

I take it you want the effect to happen when the only thing on the balance is the ingot? And it’s one-way, i.e., once the passage is open it remains open? (Right now, you don’t have any kind of message for the balance changing from level to not level, and the room connections don’t change on going from level to not level, but the Black Room description of the passage relies on the current levelness.)

Assuming it’s one-way and happens when the ingot is the only thing (players are going to put all sorts of things on the balance. You’ll have to decide for yourself whether you want to give everything masses and report on which way the balance tilts…) then you also want to account for the case in which the player puts something else on the balance, then puts the ingot on, then takes the other thing off.

Since this is possibly a side effect of multiple actions, it’s more of a job for an Every Turn rule than an action rule.

[ I did this just to make the below if-then more readable and because you might want to test balance elsewhere.]
Definition: the balance is level if the balance holds the ingot and the number of things held by the balance is 1.

Every turn:
  if the balance is level and the Sewer is not adjacent to the Black Room begin;
    say “The balance levels out. You hear a loud creaking sound from somewhere to the east.”;
    change the down exit of the Black Room to the Sewer;
    change the up exit of the Sewer to the Black Room;
  end if;
4 Likes

Thanks a million! That was very helpful, not just in fixing my code but also in helping me understand why my previous code was not working!