New commands What did I mess up?

I wrote a little bit of code and I am now stumped as to why its not working… It compiles and runs but when I type pour water onto van it get the failure option every time.

doorcool is a number that varies. doorcool is 0.

understand the command "pour" as something new.
pouring it onto is an action applying to two things.
understand "pour [something] onto [something]" as pouring it onto.
	
Instead of pouring the Water Bottle onto something:
	if the second noun is van:
		now the Water Bottle is nowhere;
		move the Empty Bottle to the Player;
		now doorcool is 1;
		say "The water hisses as it hits the card door handle, cooling it off.";
	otherwise:
		say "Why pour the Water Bottle onto [the second noun]?"`Preformatted text`


Im confused, can anyone see an error?

Thanks

An INSTEAD rule’s default outcome is failure, but are you getting the correct message and is it incrementing the variable?

Im not sure if it is incrementing it. Is there a command to saee that? If I shouldn’t use instead then what should I use?

By “default outcome” I mean if you have actions turned on, it will say something like “pouring the water bottle onto the van failed the Instead of pouring the Water Bottle onto something rule” but behind the scenes that doesn’t matter unless you have other rules depending on the outcome being successful.

To prevent that, you’d want to split this into normal Check/Carry Out/Report rules.

You can also put a debug command into your rule

Instead of pouring the Water Bottle onto something:
	if the second noun is van:
		now the Water Bottle is nowhere;
		move the Empty Bottle to the Player;
		now doorcool is 1;
		say "The water hisses as it hits the card door handle, cooling it off.";
        say "(debug - doorcool is [doorcool].);
	otherwise:
		say "Why pour the Water Bottle onto [the second noun]?"`Preformatted text`

You could write a check rule and then an After rule pertaining to the van.

Check pouring the water bottle onto something:
    if the second noun is not the van:
        instead say "Why pour the water bottle onto [the second noun]?"
After pouring the water bottle onto the van:
    now the water bottle is nowhere;
    move the empty bottle to the player;
    now doorcool is 1;
    say "The water hisses as it hits the car door handle, cooling it off."

Just a suggestion. And you don’t need the ‘Understand the command ‘pour’ as something new’–‘pour’ is not in the original lexicon.

Of course Hanon’s suggestion of Check/Carry out/Report rules is the best approach for new actions and how they are to normally be handled.

1 Like

Ok Ill have to read up on those.

Oddly enough another place in my code has the almost exact same code and it works the way its supposed to…

Instead of throwing the rock at something:
if the second noun is cars:
now the Attendant is in More Parking Lot;
Move Van to More Parking Lot;
say “The rock shatters a window causing the alarm to go off, the Attendant rushes to you.”;
now the rock is in a van;
otherwise:
say “Why throw a rock at [the second noun]?”

So I replaced the code with the code here…and was stuill getting the error. Turns out I was using the alias of he noun name The actual text for the second noun should have been minivan as that is the original name of the object. Once I fixed that it all worked, including the oeiginqal code.

Thanks for the pointers and Ill use the check thing from now on.

Thanks guys!

2 Likes

Spoke too soon…

(Each time Go or Replay is clicked, Inform tries to translate the source text into a working story, and updates this report.)

Problem. You wrote ‘Check pouring the water bottle onto something’ , which seems to introduce a rule taking effect only if the action is ‘pouring the water bottle onto something’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.

You will probably find the debugging phrase showme – not to be confused with the showme command – useful as well.

For example:

Instead of pouring the Water Bottle onto something:
  showme the second noun;
  if the second noun is van:
    (...)

tells you what the second noun is.

Please post the new code you are using so we can see if there are any issues, including the understand statements, etc., like you did before, thanks.

doorcool is a number that varies. doorcool is 0.
understand the command “pour” as something new.
pouring it onto is an action applying to two things.
understand “pour [something] onto [something]” as pouring it onto.

Check pouring the water bottle onto something:
if the second noun is not the minivan:
instead say “Why pour the water bottle onto [the second noun]?”
After pouring the water bottle onto the van:
now the water bottle is nowhere;
move the empty bottle to the player;
now doorcool is 1;
say “The water hisses as it hits the car door handle, cooling it off.”

Looks like you’ve got a second “van” in the After bit of your code (which sounds like it needs to be “minivan”).

Yeah, I didn’t get the “Check pouring the water bottle onto something” error message described above, but I did get a problem related to the van/minivan mix up that @DeusIrae points out. And his suggestion fixes that problem anyway.

The only thing I can think of here is that, if you are getting the ‘didn’t make sense as a description of an action’ error, maybe in some of the code you are calling the water bottle ‘Water Bottle’ capitalized. How are you defining the water bottle?

Yep. I had the definition commented out for testing. Good catch. I wish the erros were more descriptive3 tho,.

Thanks to all for the help.

1 Like

Or another easy way to test conditionals is with the showme whether or not phrase. Using your original code example again:

Instead of pouring the Water Bottle onto something:
  showme whether or not the second noun is the van;
  if the second noun is van:
    (...)

It can help you if your conditionals are not acting the way you expect them to act.