At the risk of going to the well too many times, i have this:
I wish to display an figure name sourced from a table.
I create and initialize the ControlPanelImage object outside my routine.
Inside my routine it is using a local variable and so, never varies.
What am i doing wrong here so that the incorrect image is displayed.
images available upon request.
Figure of ControlPanel is the file "ControlPanel.png".
Figure of ControlPanelStocks is the file "ControlPanelStocks.png".
Figure of ControlPanelGallows is the file "ControlPanelGallows.png".
Figure of ControlPanelStake is the file "ControlPanelStake.png".
Figure of ControlPanelDungeon is the file "ControlPanelDungeon.png".
Figure of ControlPanelGuillotine is the file "ControlPanelGuillotine.png".
Figure of ControlPanelExit is the file "ControlPanelExit.png".
The lab is a room. "This is the lab."
The monitor is a thing. The monitor is in the lab.
every turn, display the monitor.
Color is a kind of value. The colors are aqua, crimson, emerald, gray, indigo, khaki.
ControlPanelImage is a figure name that varies. ControlPanelImage is Figure of ControlPanel.
to display the monitor:
let C be a random color;
let a figure name that varies called ControlPanelImage be the figure text corresponding to the link number of C in the Table of Monitor Descriptions;
say "ControlPanelImage: [ControlPanelImage][line break]";
let D be the description corresponding to the link number of C in the Table of Monitor Descriptions;
say "The monitor flickers for a second and the scene it displays changes to something different.";
say "[D][line break]";
display ControlPanelImage.
Table of Monitor Descriptions
link number figure text description
aqua "Figure of ControlPanelStocks" "The monitor now shows a tableau of poor unfortunate townsfolk locked in stocks."
crimson "Figure of ControlPanelGallows" "The monitor now shows a scene of someone waiting to be hanged."
emerald "Figure of ControlPanelStake" "The monitor now displays a scene of witches being burned at the stake."
gray "Figure of ControlPanelDungeon" "The monitor now shows the implements of torture in the dungeon."
indigo "Figure of ControlPanelGuillotine" "The monitor now shows a tableau of a guillotine rising and falling over the ride exit."
khaki "Figure of ControlPanelExit" "The monitor shows a the gift shop located at the Hell Ride exit."
A few syntax mistakes, mostly. Plus the name of an image and the image itself are two different things. At the moment youâre sort of confusing the two as one and trying to get both from one column in the table. It will take two columns.
At the bottom is a working demo. Iâve given the columns what I think are better names. e.g. the link number was never a number. Itâs a colour. So I call that column link colour.
Your table lookups would have worked, but Iâve switched to the method where you choose a row in the table, then can refer to data in columns from that chosen row for a little while by saying (column name) entry. Youâll understand when you see the code.
The line
ControlPanelImage is a figure name that varies
established ControlPanelImage as a variable. But then in the display the monitor routine, you said:
let a figure name that varies called ControlPanelImage be the...
âletâ is for creating temporary variables that evaporate when the code block ends. And they canât be defined in this way. e.g. You canât say âlet a number that varies called BLAH be 6.â You could just say âlet BLAH be 6â. The data you put in the temp variable will create the correct type of variable. In the demo, I just use the real variable you already created.
Summary
Figure of ControlPanel is the file "ControlPanel.png".
Figure of ControlPanelStocks is the file "ControlPanelStocks.png".
Figure of ControlPanelGallows is the file "ControlPanelGallows.png".
Figure of ControlPanelStake is the file "ControlPanelStake.png".
Figure of ControlPanelDungeon is the file "ControlPanelDungeon.png".
Figure of ControlPanelGuillotine is the file "ControlPanelGuillotine.png".
Figure of ControlPanelExit is the file "ControlPanelExit.png".
The lab is a room. "This is the lab."
The monitor is a thing. The monitor is in the lab.
every turn, display the monitor.
Color is a kind of value. The colors are aqua, crimson, emerald, gray, indigo, khaki.
ControlPanelImage is a figure name that varies. ControlPanelImage is Figure of ControlPanel.
to display the monitor:
let C be a random color;
choose a row with a link colour of C in the table of monitor descriptions;
now ControlPanelImage is figure choice entry;
say "ControlPanelImage: [figure text entry][line break]";
say "The monitor flickers for a second and the scene it displays changes to something different.";
say "[description entry][line break]";
display ControlPanelImage;
Table of Monitor Descriptions
link colour figure choice figure text description
aqua Figure of ControlPanelStocks "Figure of ControlPanelStocks" "The monitor now shows a tableau of poor unfortunate townsfolk locked in stocks."
crimson Figure of ControlPanelGallows "Figure of ControlPanelGallows" "The monitor now shows a scene of someone waiting to be hanged."
emerald Figure of ControlPanelStake "Figure of ControlPanelStake" "The monitor now displays a scene of witches being burned at the stake."
gray Figure of ControlPanelDungeon "Figure of ControlPanelDungeon" "The monitor now shows the implements of torture in the dungeon."
indigo Figure of ControlPanelGuillotine "Figure of ControlPanelGuillotine" "The monitor now shows a tableau of a guillotine rising and falling over the ride exit."
khaki Figure of ControlPanelExit "Figure of ControlPanelExit" "The monitor shows a the gift shop located at the Hell Ride exit."
Note that in that example, the âfigure textâ column is used only for the line
say "ControlPanelImage: [figure text entry][line break]";
That column is not used for matching or displaying the image. So if you drop that print line (which looks like a debugging aid), you could drop the âfigure textâ column too.