Is it possible to list an object in a table? Here’s an illustration of what I want:
The testing ground is a room.
The Box of Goodness is in the testing ground.
Meat is a thing.
Present is a thing.
Apple pie is a thing.
Chocolate is a thing.
Table of Goodness
Object Displaytext
chocolate "A bar of Cadbury's materialises in the Box of Goodness."
present "A large gift-wrapped item appears in the Box of Goodness."
apple pie "A steaming apple pie emerges from a flash of colour in the Box of Goodness."
meat "A lightning bolt streaks down into the Box of Goodness, and lo, Meat appears."
goodnesscount is a number variable. It is 0.
Every turn when goodnesscount is less than 4:
choose a random row in the Table of Goodness;
now (Object entry) is in the Box of Goodness;
say "[Displaytext entry]";
now goodnesscount=goodnesscount+1
I don’t think this code will work in Inform though, as I tried something similar earlier and it didn’t work. Is my syntax bad, or is it just plain impossible?
It will work, with a few tweaks. You have one line break too many in the table. The variable definition is a bit off and the last line in the every turn rule must be rephrased.
[code]Table of Goodness
Object Displaytext
chocolate “A bar of Cadbury’s materialises in the Box of Goodness.”
present “A large gift-wrapped item appears in the Box of Goodness.”
apple pie “A steaming apple pie emerges from a flash of colour in the Box of Goodness.”
meat “A lightning bolt streaks down into the Box of Goodness, and lo, Meat appears.”
goodnesscount is a number variable. Goodnesscount is 0. [You can’t use “it” with variables.]
Every turn when goodnesscount is less than 4:
choose a random row in the Table of Goodness;
now object entry is in the Box of Goodness;
say “[Displaytext entry][line break]”;
increase goodnesscount by 1;
blank out the whole row. [presumably you don’t want duplicates so I added this line.][/code]
You don’t actually even need the variable, you can just check whether there’s anything left in the table:
Every turn when the Table of Goodness is not empty:
choose a random row in the Table of Goodness;
now object entry is in the Box of Goodness;
say "[Displaytext entry][line break]";
blank out the whole row.