Complicated construction

I’m trying to randomly generate a character in a given location, and at the same time i’m trying to tell I7 to place that character in the location. I tried this, but it didn’t work"

Every turn when player is in Great Northern Road: say "[bold type][one of]An abbot on horseback crosses your path. What's in those saddlebags?"; now the abbot is in location; [or]"A gaunt peasant crosses your path. It looks like he could use some kindness."; now the peasant is in location; [or]"One of the sheriff['] men crosses your path. Fight or flee?"; now the sherrif's man is in location; [or]"A fat merchant crosses your path. You wonder how heavy his purse is."; now the merchant is in location; [or]"A well-dressed lady on horseback crosses your path."; now the lady on horseback is in location.[at random][roman type].

Problem message:

Problem. In the text at ‘say “[bold type][one of]An abbot on hor […] path. What’s in those saddlebags?”’ , the text substitution ‘[one of]’ seems to start a complicated say construction, but it doesn’t have a matching end.

(The construction I’m thinking of is ‘[one of] … [or] … [at random]/[purely at random]/[then at random]/[then purely at random]/[sticky random]/[as decreasingly likely outcomes]/[in random order]/[cycling]/[stopping]’.)

See the manual: 5.7 > 5.7. Text with random alternatives


Problem. You wrote ‘“A gaunt peasant crosses your path. […] s like he could use some kindness.”’ : but this is a phrase which I don’t recognise, possibly because it is one you meant to define but never got round to, or because the wording is wrong (see the Phrasebook section of the Index to check). Alternatively, it may be that the text immediately previous to this was a definition whose ending, normally a full stop, is missing?


Problem. You wrote ‘"One of the sheriff[’] men crosses your path. Fight or flee?"’ : again, this is a phrase which I don’t recognise.


Problem. You wrote ‘now the sherrif’s man is in location’ : again, this is a phrase which I don’t recognise.

I was trying to match this phrase:

now (sherrif’s man is in location - a phrase)

But I didn’t recognise ‘sherrif’s man is in location’.


Problem. You wrote ‘“A fat merchant crosses your path. You wonder how heavy his purse is.”’ : again, this is a phrase which I don’t recognise.


Problem. You wrote ‘“A well-dressed lady on horseback crosses your path.”’ : again, this is a phrase which I don’t recognise.

The use of “[one of]” and “[or]” has to be strictly within a quoted string of text. You can’t pop out of the text and do something else with [or].

I kinda figured that, but I thought I would give it a shot. Any ideas about how I might accomplish my end?

This code will work – but I don’t think it will do what you want in terms of the story.

Every turn when player is in Great Northern Road: let X be a random number from 1 to 5; if X is 1: say "An abbot on horseback crosses your path. What's in those saddlebags?"; now the abbot is in location; else if X is 2: say "A gaunt peasant crosses your path. It looks like he could use some kindness."; now the peasant is in location; else if X is 3: say "One of the sheriff's men crosses your path. Fight or flee?"; now the sheriff's man is in location; else if X is 4: say "A fat merchant crosses your path. You wonder how heavy his purse is."; now the merchant is in location; else if X is 5: say "A well-dressed lady on horseback crosses your path."; now the lady on horseback is in location.
What will happen is, the people will be transferred randomly into the location – and then they’ll stay there. So a crowd will soon develop. Also, the abbot might be the randomly chosen person three times in a row, in which case you’ll see the message about the abbot three times in a row. I don’t think that’s going to read well.

What would be an alternative way to do that?

I think I have an answer. I’ll start these five characters out in a room called Holding Area, to which I will banish them when I’m done with them. At least, I think this may work.

A person has some text called the announcement. To approach is a verb. To depart is a verb.

Every turn when the player is in the Great Northern Road:
    if a random chance of 1 in 5 succeeds:
        let the subject be a random person in the Waiting Room;
        if the announcement of the subject is empty:
            say "[A subject] [approach].";
        otherwise:
            say the announcement of the subject;
        move the subject to the location;
    if a random chance of 1 in 5 succeeds and there is a person (called the subject) in the location:
        say "[The subject] [depart].";
        move the subject to the Waiting Room.

The Waiting Room is a room. An abbot is a man in the waiting room. The announcement of the abbot is "An abbot on horseback crosses your path." [Add more NPCs here.]

This is how I’d do it. A person shows up about every fifth turn, and a person leaves about every fifth turn as well. To change these rates adjust the “random chance of 1 in 5” lines.

EDIT: Your idea about the “holding area” is a good one; I’ve called it the “waiting room” but it’s really the same thing. A place to store these characters when they’re not on-stage, which marks them as being able to be brought on.

I’ll keep that code in mind, Daniel.
Right now I like my solution, but I’m having another problem running a scene when any of these characters do make it to the location.

If the abbot is in location: say "You pull your dagger from its sheaf and dangle it before the abbot's nose. The abbot panics and thrusts his saddlebags into your hands before hastilly mounting the horse and going back the way he came."; now player carries the saddlebags; now abbot is in Holding Area.

Problem message:

Problem. You wrote ‘If the abbot is in location’ : but the punctuation here ‘:’ makes me think this should be a definition of a phrase and it doesn’t begin as it should, with either ‘To’ (e.g. ‘To flood the riverplain:’), ‘Definition:’, a name for a rule (e.g. ‘This is the devilishly cunning rule:’), ‘At’ plus a time (e.g. ‘At 11:12 PM:’ or ‘At the time when the clock chimes’) or the name of a rulebook, possibly followed by some description of the action or value to apply to (e.g. ‘Instead of taking something:’ or ‘Every turn:’).

It looks like you have an if-statement outside a rule. You need to put it inside a rule or phrase to tell Inform when it should run. (“Every turn: if…” for example.)

Thanks!

I’d do it like that, too. I’d make one change, though: switch the “leaving” code with the “showing up” code. That way, you prevent the occasional chance of a given person both arriving and departing in the same turn.