I wanted to add a feature for one of my games where, at the end, it listed certain items by a specific property.
I don’t want to get into the details of that code, but my major roadblock/question was: can I do this without writing code that mostly copy and pastes itself?
The example below is a very cut down version of the above.
Saying (xyz of) seems like the more elegant way to do things. It would allow me to add, say “xlarge,” and not type in any more code. If it worked. But I can’t get it to. And the reason Inform gives, makes sense.
It would be acceptable to use the smalls/larges/mediums code (e.g. one “to say” per size property), but my example may have 10 or so properties, and I suspect I’m missing a way to generalize.
I’m using 6g.
[code]“failed sizeprop try” by Andrew Schultz
a thing can be small, medium or large (this is the size property).
McDonald’s is a room.
the shake is a small thing in McDonald’s.
the big mac is a large thing in McDonald’s.
the fries are a medium thing in McDonald’s.
to say xyz of (abc - a size):
repeat with th running through things:
if th is abc, say “[th] is [abc].”;
to say smalls:
say “[list of small things].”
to say mediums:
say “[list of medium things].”
to say larges:
say “[list of large things].”
say “[one of][smalls][or][mediums][or][larges][cycling].”;
say “Above shows how I want to do things. Of course, the user will have control, and there’ll be no arbitrary cycling, but this is for demonstration purposes. The code below seems more elegant and flexible, but it gives a runtime error.”;
say “[one of][xyz of small][or][xyz of medium][or][xyz of large][cycling].”;[/code]
Thanks for any and all help!