actions with new object kinds

After thinking about duplicates some more (cf maximum number of things in an Inform project, 2026 edition), I’ve decided to dump them altogether. It’s too fussy to deal with them in a lot of cases, and I really don’t want to keep track of them.

My thought: make some objects and give them properties, including a counter. I think I could do all of this with some scenery backdrops located everywhere, and that might be the best answer. But I already know how to do that, and I’d like to learn something new.

What about a new object kind? I’ve never messed with that before, so I could learn something. It’s easy to make them, make sub kinds, set properties, manipulate them, etc.

However, I don’t have a handle on using them in command grammar or handling their scope.

Directions (just thinking about another kind here) are always in scope, which I’m sure is baked in somewhere. I think I would have to add these new objects after deciding the scope of the player. Is that right?

My other question is that I can’t get actions involving two of these new objects to work. They don’t show up in rules debugging, either, so I must be doing something profoundly wrong. Example code:

Lab is a room.

medicine is a kind.
a medicine can be privately-named or publicly-named.
a medicine is usually publicly-named.
a medicine has a text called description.
an herb is a kind of medicine.

blue is an herb.
red is an herb.

frobbing is an action applying to one visible thing.
understand "frob [something]" as frobbing.

after deciding the scope of the player:
	repeat with M running through medicines:
		place M in scope;
		
carry out frobbing an herb:
	say "yes!";
	
frotzing it with is an action applying to two visible things.

understand "frotz [something] with [something]" as frotzing it with.

carry out frotzing something with something:
	say "yes! yes!";

outputs:

>frob blue
yes!

>frotz blue with red
>

I’m rambling a bit here! I tried searching the documents but looking for “object” and “action” is a rough road.

  1. Is the best way to do this particular thing like this, or something else?
  2. If this is a good way, where is the frotzing action going wrong?
1 Like

Congratulations on liberating yourself from duplicates – they’re responsible for some of the biggest headaches I’ve ever had in Inform!

I’ll wait for wiser heads to weigh in on your bigger-picture questions, but that last one is just a syntax thing that I remember running into – your last rule should be:

carry out frotzing it with:
	say "yes! yes!";

(If you want a more specific rule, like carry out frotzing red with blue, that’s just how you’d write it, though of course you’d need a separate frotzing blue with red rule as well)

2 Likes

Not exactly sure why carry out fritzing something with something didn’t work, this does.

carry out frotzing:
	say "yes! yes!";

Not sure if this is what you want either, but you can also do this to make it only work with medicines I think:

understand "frotz [medicine] with [medicine]" as frotzing it with.

carry out frotzing:
	say "yes! yes! Frotz the [noun] with the [second noun]";
1 Like

I suspect something object specific is happening. I may not be handling the scope right. Or something

hat is in lab.
table is a supporter in lab.

yields

>frotz hat with table
yes! yes!

>frotz blue with red
>

Oh, maybe I was wrong about understand doing the filtering if you used the [kind] tokens. :thinking: Would need to do more experimenting.

I think that kind of scope-limiting is elegant in theory, but can lead to issues for the player since it can lead to error messages suggesting that the action or nouns aren’t being recognized, rather than that they’re recognized and they’re just the wrong type. I think something like this is probably cleaner:

understand "frotz [something] with [something]" as frotzing it with.

Check frotzing it with:
	If the noun is not medicine or the second noun is not medicine, say "You can only frotz medicine!" instead.

carry out frotzing it with:
	say "yes! yes!";
2 Likes

It is true that frotzing it with works. but what about cases like

frotzing blue with something for instance, or the other way around

using one thing and one herb does produce the expected result, so perhaps the problem is having two herbs in the same command

ETA

Definitely! the actual program does all of this checking. We’re just looking at carry out as a minimum viable example.

I like to jam it all in the preamble just for the rules debugger (actual code). I could save some characters with mixing it with but I prefer typing the whole thing out.

check mixing something with something when the noun not an herb or the second noun is not an herb (this is the can only mix herbs rule):
	say "It is only possible to combine herbs.";
	rule fails;

The action works with 2 things (or 1 thing and 1 medicine) but not 2 medicines though, which suggests there might be something we have missed.

Honestly, I always prefer something with something over [action name] it withbecause it reads better to me, which is a very Inform reason for doing something.

I’ve been doing this for years at this point, the new thing is the object kind.

Update

Just a final comment on frotzing it with in an even more minimal example
lab is a room.

frotzing it with is an action applying to two visible things.

understand "frotz [something] with [something]" as frotzing it with.

carry out frotzing it with:
	say "frotzing it with!";
	
carry out frotzing something with something:
	say "frotzing something with something!";
	
after frotzing:
	say "whew!";
	continue the action;

yields

>frotz east with west
frotzing it with!

whew!

Whether it’s good form to say something with something, I feel we should at least get an error message out of this, or else a compile failure.

Whether this reflects best practices or not, I went ahead and made a kind and some subkinds, granted them properties, and put them in scope when their “stock” values exceed zero.

Created a new action for them, and a rulebook to go with that.

So maybe this is good enough? Seems pretty stable at the moment. Duplicates feel pretty fragile, unless I’ve missed a subtlety somewhere. By comparison, this object changeover “just works” with minimal fuss.

I’m always interested in discussing such things, but perhaps this is solved… until it breaks!

1 Like

I think the current output is correct, but this is where Inform’s refusal to be clear about when “thing” means “thing” and when it doesn’t is coming back to bite it.

2 Likes

Ah! So the issue is the lack of specificity.

an object with an object works as expected. Mystery solved!

Yeah, “something” here literally means a thing, while “two visible things” and “[something]” do not.

1 Like