Coding involving people

I have tried the follow code in many ways but none of them will compile. Basically, the main character casts a spell called “Weak Bladder” on a person and they leave to the bathroom, returning two turns later.

The code I have:

person has a text called past location.

bladdering is an action applying to one thing.  Understand "weak bladder [someone]" as bladdering.

check bladdering:
	if noun is not person:
		say "You can only cast Weak Bladder on a person.";
		stop the action;
	otherwise:
		continue the action;
		
carry out bladdering:
	now past location of person understood is location;
	now person understood is in Room-18;
	person understood returns in two minutes from now;
	continue the action;
	
At the time when person understood returns:
	now person is in past location;
	continue the action;
	
report bladdering:
	say "[Person] returns to the room.";
	stop the action

with this code I get three errors:

 In the sentence 'now past location of person understood is location', I was expecting to read a condition, but instead found some text that I couldn't understand - 'past location of someone understood is location'.

and

In the sentence 'now person understood is in Room-18', I was expecting to read a condition, but instead found some text that I couldn't understand - 'person understood is in Room-18'.

and

In the sentence 'now person is in past location'  , it looks as if you intend 'person is in past location' to be a condition, but that would mean applying the containment relation (between objects) to kinds of value which do not fit - a texts valued property and an object - so this must be incorrect.

Obviously, I have the wrong syntax. I tried defining the action as applying to one person, but you can only applying actions to things and values.

I tried the code with person, someone, and someone understood as substitutes for person understood, the same responses.

As always, I appreciate the guidance.

2 Likes

So, a couple things here:

  • Action definitions have to specify whether they apply to things or kinds of values, so that’s why “applying to one person” doesn’t work. Defining it so the grammar only accepts a particular kind of thing, as you have here (using the “[someone]” token in the understand statement) will serve the same purpose, but I think it’s actually a bad idea to restrict the action this way, rather than via a check rule as you’ve also done – as you’ve implemented it here, the player will only get the default “you can only do that to something animate” response, rather than the custom one you’ve written in the check rule.

  • You’re storing the past location as a text, but actually that’s a room, and you want it to be a room (this is the third error, where Inform is confused because it seems like you’re trying to cram the player into a text variable!)

  • “Person understood” doesn’t mean anything by default in Inform; when you have an action that takes a text, like ASK SOCRATES ABOUT MORALITY, you can use “the topic understood” to access the player’s input. But for more run of the mill actions, the way to figure out what objects the player is attempting to do stuff to is to just refer to “the noun” (or for actions applying to two things, “the second noun” too).

  • Your report rule will fire when the player casts the spell, but I think that’s when the target is supposed to leave, not when they return (and meanwhile the return doesn’t have any text associated with it, so the player might not notice it).

  • You generally don’t need to, or want to, put a bunch of continue the action/stop the action statements into your rules – if you’re using the right kind of rule, it should all work as intended (and if you aren’t manual tweaks like that might mess something up!)

  • I don’t think you can schedule an event with a particular parameter (like, saying X character returns) – or at least if you can, I don’t know how to do it :slight_smile: So you might work around that with an every turn rule (I took a stab at one below).

  • What’s supposed to happen if the player casts the spell on themselves? I don’t think you want them teleporting willy-nilly as a result, so maybe address that in the check rule.

So putting all that together, here’s something that might work:

bladdering is an action applying to one thing.  Understand "weak bladder [someone]" as bladdering.

check bladdering:
	if noun is not a person:
		say "You can only cast Weak Bladder on a person.";
		stop the action;
	otherwise if the noun is the player:
		Say "You did that once on a dare at university -- never again.";
		stop the action.
		
carry out bladdering:
	now past location of the noun is location;
	now the noun is in Room-18;
	Now the pee timer of the noun is 2.
	
Every turn:
	Repeat with X running through people in Room-18: 
		If the pee timer of X is 0:
			now X is in past location of X;
			If the player is in past location of X, say "[X] returns, looking much relieved.";
		Decrement the pee timer of X.
	
report bladdering:
	say "[The noun] flees the room.";
7 Likes

Thank you so much, as always!

1 Like

whatever is Matt’s story, I candidate it as “best new angle on a classical puzzle” (the “get rid of guard” one) XYZZY award/Springthing ribbon. I’m delighted on the mean of ridding off the guard :smiley:

Best regards from Italy,
dott. Piergiorgio.

Interesting mechanic. Somehow I cannot stop giggling when I see this timer…

1 Like

Onno, if you see my learning code… I hate so much the hunger & thirsty daemons, so in learning their implementation, I have “reversed” said daemons…

Best regards from Italy,
dott. Piergiorgio.

1 Like