Hello,
back again with another question. I’m learning Inform 7 and doing pretty well I think, but I am still grokking some concepts of what I can and cannot do.
I know that you can abstract something: A fuse is a kind of thing. fuse1 is a fuse. and in many cases you can use “the item described” to work generical for fuse1 thru fuseN. But I also understand that Inform sometimes needs a concrete object. i.e. fuse1 vs the fuse.
I have 6 sets of fuses sockets, switches and indicators.
As you can imagine, by providing concrete objects all the time, that i have a metric ton of repeated code. This makes bug fixing onerous.
So what i thought I would do would be to create concrete “holders” (fuse0). And what I wanted to do is use a (function?) to process all six sets of options.
The code below compiles, but doesn’t yield what i want to do. The code in question is below the comment: {=========================]
Thanks in advance,
d.
Release along with cover art, a website, an introductory booklet, and an introductory postcard.
Use scoring.
Use American Dialect.
Use serial comma.
The maximum score is 100.
The block giving rule is not listed in the check giving it to rules.
Sound of Bell is the file "StrongmanBell.ogg".
The Swiss Army knife is in the Electrical Room. The Swiss Army knife is an open container. The screwdriver, awl, fingernail clippers, can opener, and corkscrew are in the Swiss Army knife. Understand "screwdriver" as knife. The description of the Swiss army knife is "This is the standard issue Swiss Army knife."
instead of taking when the noun is in the swiss army knife, say "That[']s part of the Swiss Army knife. You can[']t take that!" instead.
The silver key is in the Electrical Closet One. The description of the silver key is "This is a small silver key. I wonder what it unlocks."
[electrical room]
Electrical Room is a room. "This is the Electrical Room".
Electrical Room is south of the Generator Room.
Electrical Room is southwest of Electrical Closet One.
Electrical Room is west of Electrical Closet Three.
every turn when the location is the electrical room:
say "This room is oozing with electromagnetic energy. You can feel your hair stand on end and all your nerves twitching. This feels dangerous! There are exits in all directions."
[electrical closets]
Electrical Closet One is a room northeast of the electrical room. "This is Electrical Closet One. There[']s an electrical panel here and an exit to the south west."
Electrical Closet Three is a room east of the electrical room. "This is Electrical Closet Three. There[']s an electrical panel here and an exit to the west."
[colors]
Color is a kind of value. The colors are aqua, crimson, emerald, gray, indigo, khaki, magenta, and nondescript.
[fuses]
A fuse is a kind of thing. The plural of fuse is fuses.
A fuse can be lost or found. A fuse is usually lost.
A fuse has a color. A fuse is usually nondescript.
A fuse has a number called fuse id. A fuse id is usually 0.
The description of a fuse is "This is a [color] colored electrical fuse."
The printed name of a fuse is "a [color] colored fuse".
fuse1 is a fuse. fuse1 is in the electrical room. The fuse id of fuse1 is 1. The color of the fuse1 is aqua. Understand "aqua" and "fuse" as fuse1.
fuse3 is a fuse. fuse3 is in the electrical room. The fuse id of fuse3 is 3. The color of the fuse3 is crimson. Understand "crimson" and "fuse" as fuse3.
before taking:
if the noun is a fuse and the second noun is socket1 and the socket1 is filled:
say "Taken.";
now the noun is in the player;
now indicator1 is switched off;
now switch1 is switched off;
stop the action;
if the noun is a fuse and the second noun is socket3 and socket3 is filled:
say "Taken.";
now the noun is in the player;
now indicator3 is switched off;
now switch3 is switched off;
stop the action;
[panels]
An electrical panel is a kind of openable lockable container. The plural of electrical panel is electrical panels.
An electrical panel is usually closed. An electrical panel is usually locked.
An electrical panel is fixed in place. An electrical panel is scenery.
An electrical panel has a color. An electrical panel is usually nondescript.
An electrical panel has a number called a panel id. A panel id is usually 0.
The description of an electrical panel is "Electrical Panel [the panel id] is a standard issue 200 amp electrical panel supplying 220 power throughout the ride. The electrical panel is [if the item described is open]open. Inside the panel you see a switch, a socket, and an indicator light.[otherwise]closed.[end if] [if the item described is locked]There are screws holding it shut.[otherwise]You can see the cover of the panel sitting nearby.[end if]".
The printed name of an electrical panel is "Electrical Panel [the panel id]".
panel1 is an electrical panel. panel1 is in the electrical closet one. The panel id of panel1 is 1. Understand "panel 1" and "panel" as panel1. The color of panel1 is aqua. The swiss army knife unlocks panel1.
panel3 is an electrical panel. panel3 is in the electrical closet three. The panel id of panel3 is 3. Understand "panel 3"and "panel" as panel3. The color of panel3 is crimson. The swiss army knife unlocks panel3.
instead of turning:
if the item described is a panel1:
try unlocking the noun with the second noun instead;
if the item described is a panel3:
try unlocking the noun with the second noun instead;
instead of locking:
if the item described is panel1:
continue the action;
else if the item described is panel3:
continue the action;
otherwise:
say "You can[']t lock that!" instead.
instead of unlocking:
if the noun is panel1 and the second noun is the swiss army knife:
say "Using the screwdriver on the Swiss Army knife, you remove the cover to the electrical panel.";
now panel1 is unlocked;
stop the action;
else if the noun is panel3 and the second noun is the swiss army knife:
say "Using the screwdriver on the Swiss Army knife, you remove the cover to the electrical panel.";
now panel3 is unlocked;
stop the action;
otherwise:
say "You can't unlock the [noun] with the [second noun]."
[sockets]
Definition: a socket is filled rather than unfilled if a socket contains a fuse.
A socket is a kind of open container. The plural of socket is sockets.
A socket is fixed in place.
A socket has a color. A socket is usually nondescript.
A socket has a number called socket id. a socket id is usually 0.
The description of a socket is "Socket [the socket id] is part of electrical panel [the socket id]. A fuse probably goes in here."
The printed name of a socket is "Socket [the socket id]".
socket1 is a socket. socket1 is part of panel1. The socket id of socket1 is 1. Understand "socket 1" and "socket" as socket1. The color of socket1 is aqua.
socket3 is a socket. socket3 is part of panel3. The socket id of socket3 is 3. Understand "socket 3" and "socket" as socket3. The color of socket3 is crimson.
check inserting a fuse into a socket:
if the socket is filled, say "But Socket [socket id of the second noun] is already full." instead.
check inserting something into a socket:
if the noun is not a fuse, say "That won[']t fit in the socket." instead.
check inserting the fuse (called the fuse) into the socket (called the socket) when the color of the fuse is the color of the socket:
say "You hear a satisfying snick as the fuse slides into place.";
now the fuse is in the socket;
stop the action.
instead of examining a socket (called the socket) when the socket is unfilled, say "Socket [socket id] is empty." instead.
instead of examining a socket (called the socket) when the socket is filled, say "Socket [socket id] contains [list of things in the noun]." instead.
[switches]
A switch is a kind of device. The plural of switch is switches.
A switch is fixed in place.
A switch has a color. A switch is usually nondescript.
A switch has a number called switch id. a switch id is usually 0.
A switch has a truth state called points awarded. points awarded is usually false.
The description of a switch is "Switch [switch id] is part of electrical panel [the switch id]."
The description is "Switch [switch id] is part of Electrical Panel [switch id]. It[']s a big switch. You could probably turn it [if the item described is switched off]on[otherwise]off[end if] if you wanted to."
The printed name of a switch is "Switch [the switch id]"
switch1 is a switch. switch1 is part of panel1. The switch id of switch1 is 1. Understand "switch 1" and "switch" as switch1. The color of switch1 is aqua.
switch3 is a switch. switch3 is part of panel3. The switch id of switch3 is 3. Understand "switch 3" and "switch" as switch3. The color of switch3 is crimson.
[indicators lights]
An indicator is a kind of device. The plural of indicator is indicator.
An indicator is usually switched off.
An indicator is fixed in place.
An indicator has a color. An indicator is usually nondescript.
An indicator has a number called an indicator id. an indicator id is usually 0.
The description of an indicator is "Indicator [the indicator id] [if the item described is switched on]is glowing [color of the item described] and [end if]is currently [if the indicator is switched on]indicating something[otherwise]indicating nothing[end if]."
The printed name of an indicator is "Indicator [the indicator id]".
indicator1 is an indicator. indicator1 is part of panel1. The indicator id of indicator1 is 1. Understand "indicator 1" and "indicator" as indicator1. The color of indicator1 is aqua.
indicator3 is an indicator. indicator3 is part of panel3. The indicator id of indicator3 is 3. Understand "indicator 3" and "indicator" as indicator3. The color of indicator3 is crimson.
Instead of switching on an indicator, say "You can[']t turn that on." instead.
[=============================================================]
switch0 is a switch. socket0 is a socket. indicator0 is an indicator. fuse0 is a fuse.
Instead of switching on or pushing switch1:
let switch0 be switch1;
let socket0 be socket1;
let indicator0 be indicator1;
let fuse0 be fuse1;
handle the switches.
to handle the switches:
if switch0 is switched off and fuse0 is not in socket0 and socket0 is filled
begin;
now indicator0 is switched off;
say "You push the switch.";
say "Nothing obvious happens." instead;
end if;
if switch0 is switched off and the fuse0 is in socket0 and the points awarded of switch0 is false
begin;
say "The indicator light goes on.";
now switch0 is switched on;
now indicator0 is switched on;
play the sound of Bell;
increase score by 5;
now points awarded of switch0 is true;
stop the action;
end if;
if switch0 is switched off and fuse0 is in socket0 and the points awarded of switch0 is true
begin;
say "The indicator light goes on.";
now switch0 is switched on;
now indicator0 is switched on;
stop the action;
end if;
if switch0 is switched off and socket0 is filled
begin;
now switch0 is switched on;
now indicator0 is switched off;
stop the action;
end if;
if switch0 is switched on
begin;
say "The indicator light goes off.";
now switch0 is switched off;
now indicator0 is switched off;
stop the action;
end if;