How would I go about creating a random description at the start of the game, which stays the same throughout? “one of” and “or” don’t seem to help for this, since they vary every time the object is viewed.
What I want to do is, I want to assemble a description for the player which is random at the outset of the game, but then stays consistent throughout. I’m imagining something like “You have [long / short / medium] [blond / black / brown / red] hair”, where the program randomly assembles a combination and then lets you keep it.
You should be able to piece something together from Writing with Inform 8.18, 8.19, an 9.1 and the accompanying Recipe Book examples. (Sorry I can’t be more helpful right now, but I have a sleeping baby on my chest.)
Thank you kindly - sticky random did the trick! Follow-up question though, one which is slightly more difficult:
I want to create a handful of bandits, say five or so, with randomly-generated descriptions like I did for the player. Is there a way to do this without writing "Bandit One is a bandit. The description is “He is [one of]fat[or]thin[sticky random]” for each individual bandit? I’ve tried playing around with lists, but that hasn’t yielded any results, so far.
The description of a bandit is usually "He is [one of]fat[or]thin[or]purple[or]uninterested in your body-shaming categories[or]wicked nasty[or]obsessively posting about his demisexuality on Tumblr[sticky random]."
but it turns out that doing so doesn’t actually duplicate the description when you make new bandits: they all refer to the same piece of text, so if one of them’s thin then they all are. So you need to do this in a slightly more code-reliant way:
[code]A bandit has some text called bandit-variance. The description of a bandit is usually “He is [bandit-variance].”
When play begins:
let desclist be [“fat”, “thin”, “stinky”];
repeat with N running through bandits begin;
sort desclist in random order;
now the bandit-variance of N is entry 1 in desclist;
Ah, thank you very much! I tried it out with more variables, and it works out quite perfectly.
Another question, though - I made the description “He is [bandit-variance] and carries [a list of things held by the bandit]”, thinking I could randomize or perhaps manually give each bandit slightly different things, for flavor. This results in every bandit being listed as carrying every weapon, though. What syntax is needed here? “A list of things held by this bandit” didn’t work out.
Except at the very beginning of a ‘say phrase’ or when declaring objects, Inform with few exceptions treats “the”, “a”, “an”, and “some” as synonymous (indeed, using the articles are optional in these contexts) – in effect you’re asking for a list of things held by some bandit.