Putting on a portable

I want to have something happen when the player puts one thing onto another thing. But Inform always responds, “Putting things on the Electric Lantern would achieve nothing.”

The Electric Lantern is a portable device in the Store Room. It is switched off. 

The Cloudy Glass Chimney is a thing. "There seems to be some patterns on the glass but they're difficult to make out."

Putting is an action applying to one thing.
Understand "put the [thing] on" as putting.

After putting the Cloudy Glass Chimney on the Electric Lantern:
	say "The flame illuminates some illustrations on the chimney you couldn’t see before. Also there are words scrolled around the glass bottom that asks, 'What provides all of these states?'"

I don’t think you have to tell Inform what putting is. Say

The electric lantern is a supporter.

And then your “after” code should work.

3 Likes

Can something be both a supporter and portable?

Oh, sorry- I missed that you want it to be portable- even though it’s the name of the topic!

The electric lantern is a portable supporter.

That worked in my sample code.

1 Like

Yes, although by default they’re not. You can just declare them to be portable, though. (See Writing with Inform 3.6 and 3.7.)

However, the bigger problem is that something cannot be both a device and a supporter – to Inform, those are fundamentally different kinds of things. Probably the easiest thing to do is just to make the lamp a portable supporter, then declare that it has a part that’s a device:

Cave Entrance is a room. The bulb is a device. The electric lantern is a supporter in Cave Entrance. The bulb is part of the electric lantern.

And then redirect some actions from the lamp to the bulb:

Instead of switching on the lantern, try switching on the bulb. Instead of switching off the lantern, try switching off the bulb.

(Notice that that doesn’t redirect every action and there’s a good chance I missed things there that you’ll want to cover.)

(EDIT. You could of course do it the other way around: make the lamp a device, and then declare The top of the lamp is a supporter. The top of the lamp is part of the lamp., and then redirect a different set of actions to the top of the lamp instead of directing the switching on/off actions to the bulb. This seems less intuitive to me but should work just as well in theory.)

And then of course write some rules to handle what happens when the bulb is switched on:

Report switching on the bulb:
	say "With a CLICK! the light bulb begins to glow.".

Carry out switching on the bulb:
	now the bulb is lit.

Report switching off the bulb:
	say "You switch off the lantern, and the bulb goes dark".

Carry out switching off the bulb:
	now the bulb is not lit.

One of the standard limitations of Inform’s world model is that it has no concept whatsoever of limitations for supporters based on size, so you might want to write some additional rules to avoid absurdity:

Instead of putting the full-sized mechanical elephant or the Volkswagen Vanagon on the lantern:
	say "That would crush the lantern.".
3 Likes

It’s possibly easier to just make it a pseudo-device, like so:

The Lab is a room.
The lamp is a supporter in the Lab.
The lamp can be switched on or switched off. [defaults to switched off]

Carry out examining something when the noun provides the property switched on (this is the examine device-ish things rule):
say "[The noun] [are] [if story tense is present tense]currently [end if]switched [if the noun is switched on]on[otherwise]off[end if].";
    now examine text printed is true.

The examine device-ish things rule is listed instead of the examine devices rule in the carry out examining rules.

It’s pretty easy to pretend the device kind doesn’t exist while still getting all of the switched on/off utility. The Standard Rules literally only uses device in one place (the examine devices rule I provided a replacement for above) after defining them and stating that they have the switched on/off property. The other rules you might expect to mention devices actually test for “if the noun provides the property switched on” instead of testing that it’s a device per se, which is what makes it so easy to make a pseudo-device.

(Edited: what I had before would have resulted in two messages for real devices. I replaced it with something simpler and cleaner that works better…)

4 Likes