Any way to stop a script partway through?

I have a set of tables that are working well. A Sylvan hex can occur; subtables generate the contents and the script continues on, hitting a Denizens table. But I'd like to stop the script if it happens to run the Sylvan table. (In other words, keep it from rolling on anything else; the sylvans don't like any other Denizens in their hex.)

Is there some kind of Stop command, maybe put at the end of a "show-stopper" table? Or the old GOTO, lol?

Pseudocode:

Table:Results
The hex contains [HexTypes]

Table:HexTypes
1 [SylvanHex]
1 [Denizens]

Table:SylvanHex
some [@SylvanCritters]
--stop here--

Table:SylvanCritters
elves and stuff

Table:Denizens
[OtherCritters]

Comments

  • edited November 25

    Right now it looks like it if it runs SylvanHex, it can run SylvanCritters, after which it stops. You could put an entry in SylvanHex that uses the \z special character for an empty table entry. That would also stop. Then you'd end up with 50% running SylvanCritters and 50% of the time stopping.

  • If you just want the generator to run once and stop, you can put something like this up at top:

    MaxReps: 1

  • \z as a stop is a fantastic use. Didn't realize it'd do that. Thanks!

  • edited November 26

    \z doesn't stop the generator per se, its just an empty result that doesn't have any sub-tables to run. But yes, its useful!

  • Do you mean that in your pseudocode example, you might run HexTypes multiple times, unless it's a sylvan hex?

    There's nothing equivalent to a break statement to make the table quit early. Instead, you might do something akin to this:

    Table:Results
    The hex contains [HexTypes]. &
    [when]{keepgoing}=1[do] It also contains [@OtherHexTypes].[end]

    Table:HexTypes
    1 [SylvanHex]{keepgoing==0}
    1 [Denizens]{keepgoing==1}

  • Or maybe something like this...

    [@ht==HexTypes]&;
    [@{n} {ht}>>implode]

    Table: HexTypes
    SylvanHex{n==1}//there can be only 1 denizen
    OtherHex{n==1d3}//allowing multiple denizens

    Table: SylvanHex
    things you'd see in a sylvan hex

    Table: OtherHex
    things you'd see in some other hex

Leave a Comment