I’m playing around with 6L38 trying to create a generic die kind:
[code]“Example”
Chapter - Defining Dice
Color is a kind of value. The colors are red, orange, yellow, green, blue, purple, white, gray, brown, and black.
Sidedness is a kind of value. 1-sided specifies a sidedness.
A die is a kind of thing. The plural of die is dice. A die has a color. The color of a die is usually white. A die has a sidedness. The sidedness of a die is usually 6-sided. A die has a number called current face. Understand the sidedness property as describing a die. Understand the color property as describing a die.
To decide which number is the face count of (X - a die):
decide on the sidedness of X divided by 1-sided.
The description of a die is usually “An ordinary die with [face count of the item described] sides[if the item described is not enclosed by the player], currently showing [current face][end if].”
Chapter - Rules for Dice
Before printing the name of a die (this is the prefix die with side count in name rule):
say " [sidedness] ".
To randomly set the current face of (X - a die):
now the current face of X is a random number between 1 and the face count of X.
When play begins (this is the initialize all dice at startup rule):
repeat with subject running through dice:
randomly set the current face of subject.
Carry out dropping a die (called X) (this is the throwing a die randomizes its face rule):
randomly set the current face of X.
After dropping a die (this is the report throwing a die rule):
say “It lands with the [current face of the noun] side on top.”
Chapter - The Basics
Place is a room.
The player carries two dice.
The player carries a red die.
test me with “throw dice / showme red / x 6-sided”[/code]
So far, so good, but I’m having trouble with the following ideas:
-
How can I declare a die with a non-default number of sides? “The player carries a yellow 8-sided die.” results in a generic thing, not a die. “The player carries a die with sidedness 8-sided.” produces a white 6-sided die. I’ve found it’s possible to create named dice with non-default sidedness (“The player carries a die called an X. The sidedness of X is 8-sided.”), but this isn’t really the desired functionality.
-
I would like the player to be able to differentiate identical dice via the current face, e.g. “>GET DIE SHOWING 4”. A rule like ‘Understand “showing [number]” as a die when the number understood is the current face of the item described.’ compiles but doesn’t seem to function – the parser goes into disambiguation for all dice regardless of the value of current face.
-
Assuming it’s possible to get the above working, I would also like to be able to have the parser recognize phrases like “6-sided” or “6 sided” or “six-sided” or “six sided” or maybe even “with 6 sides” to disambiguate dice, so the player could type “>GET SIX-SIDED DICE SHOWING 3” to pick up multiple dice with those features from a set.
Anyone have any tips?