Well, here I’m seriously not an expert. In fact, this is kind of kicking my rear at the moment; the solution that I thought would be simple turns out to be not so. To give non-equal random weights to the rows, you could put in a column for the rank (in your example, 5 for discovering the mountains, 15 for foo, up to 100 for bar), choose a random r, and pick the row whose rank is at least r; but that turned out to be surprisingly difficult, at least for me. Here’s the start of the rule I came up with:
To say explore (L - a place):
if L is the forest:
let r be a random number from 1 to 25;
let N be 0 [this is a very unlovely hack because I can't figure out how to say "choose a row with rank at least r"];
repeat with M running from 1 to the number of rows in the Table of Forest Explorations: [can't even use "repeat through the Table of Forest Explorations" because I'm not sure how to reverse-engineer M from that]
if N is 0:
choose row M in the Table of Forest Explorations;
if rank entry is at least r:
now N is M; [and now I don't know how to just quit the loop, so we repeat through the rest of the table even though it's pointless]
if N is 0:
let N be the number of rows in the Table of Forest Explorations; [panic in case we never chose a row]
choose row N in the Table of Forest Explorations;
Then there’s a question of what you want to do with the Table of Forest Explorations. My original idea was to have a column for the description you print when you hit your random entry, and a column with a stored action that would be carried out if applicable. But most of those entries would be blank, and I couldn’t get my blank entries to behave. I kludged it up by creating a dummy action that does nothing, which went wherever I really wanted a blank entry, but that’s awful.
One alternative would be to reuse the say-phrase trick; instead of having a stored action, pop “[discover mountains]” into the text that gets said in that row, and use “To say discover mountains” (or something even more generalizable) to add the mountains to the table of locations. That might even be more generalizable, since you could put as many of those say-phrases in as you want, instead of being restricted to one stored action.
Anyway, I’ll paste what I currently have below a spoiler tag. You’d want to generalize it in some ways – every place would have a table of outcomes associated with it (some of them might be a table with one row, saying “nothing happens,” and the carry out rule for discovering would also be something you’d want to generalize. Maybe someone more competent than I will explain why blank entries are the messenger of my doom and destruction.
[spoiler][code]“Locations test” by pashaimeru
Volume 1 - Engine stuff
Book 1 - Prep
Include Menus by Emily Short.
Use no scoring.
The printed name of yourself is “you”.
A thing can be usable or not usable. A thing is usually not usable.
Book 2 - Locations
Section - Using
The crystal ball is a thing. It is fixed in place. It is usable. Crystal ball can be operated or not operated. Crystal ball is not operated.
Using is an action applying to one thing. Understand “use [thing]” as using.
A place is a kind of thing. The forest is a place. The mountains is a place. The pointless valley is a place.
Check using:
If noun is not usable, say “You can’t use that.”.
Carry out using:
if noun is crystal ball:
now the current menu is the Table of Crystalball;
carry out the displaying activity;
clear the screen;
try looking.
Table of Crystalball
title subtable description toggle
"Location" Table of Locations -- --
Table of Locations
title subtable description toggle
"Forest" Table of Location_forest -- --
"Pointless Valley" -- "[explore the pointless valley]" --
["Mountains" Table of Location_mountains -- --]
with 5 blank rows
Table of Location_forest
title subtable description toggle
"Explore" -- "[explore forest]" --
Table of Location_mountains
title subtable description toggle
"Explore" -- "You found a rubber ball somehow. [explore mountains]" --
Part - Exploring
A rubber ball is a thing.
To say explore (L - a place):
if L is the forest:
let r be a random number from 1 to 25;
let N be 0 [this is a very unlovely hack because I can’t figure out how to say “choose a row with rank at least r”];
repeat with M running from 1 to the number of rows in the Table of Forest Explorations:
if N is 0:
choose row M in the Table of Forest Explorations;
if rank entry is at least r:
now N is M;
if N is 0:
let N be the number of rows in the Table of Forest Explorations;
choose row N in the Table of Forest Explorations;
say the description entry;
try the outcome entry; [I’d like to have this be conditional on “if there is an outcome entry:” but that never seems to trigger; even with that condition in, when it hits a blank outcome entry it produces a run-time error]
now the description entry is “Nothing happens.”;
now the outcome entry is the action of booping; [I’d like to say “blank out the outcome entry” but that doesn’t seem to do anything]
otherwise if L is the mountains:
now player is carrying a rubber ball;
otherwise:
say “You explore [the L] but don’t find much of anything”;
decrease the menu depth by 3.
Table of Forest Explorations
rank description outcome
15 “Mountains found etc.” the action of discovering the mountains
20 “foo” the action of booping [these really should be blank entries, but I can’t get that to work]
25 “Nothing happens.” the action of booping
Discovering is an action applying to one visible thing. [“visible” because it won’t be “touchable”; see 12.7 of the documentation]
Carry out discovering:
if the noun is the mountains:
choose a blank row in Table of Locations;
now title entry is “Mountains”;
now subtable entry is Table of Location_mountains;
otherwise:
stop the action.
Booping is an action applying to nothing. [and it does nothing]
Volume 2 - The world
Test room is a room. The player is in test room. The crystal ball is here.[/code][/spoiler]