Daniel Lepage on Sat, 16 Dec 2006 16:29:00 -0700 (MST)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [s-d] dice server enhancements

Language features I would like:

1. Array indices. For example,
{{let x = 3#d5 in x[1]+x[2] - x[3]}}
x[i] is syntactic sugar for "last 1 first i x".

2. Global variables. For example,
{{let x = sum 3#d5 in everything}}
Wonko gains {{x}} points and loses {{x/2}} Charisma.
This has two major benefits.
1) It solves the problem of referring to earlier rolls, as in "{{let  
x = 3#d5 in everything}} Wonko gains {{x[1]}} + {{x[2]}} + {{x[3]}} =  
{{sum x}} points."
2) It allows you to put in a bunch of constants to start off your  
script, e.g.
{{let weapons = ("Sword of Truth","Spear of Lies","Axe of  
Kindness","Prong of Tickles") in everything}}
Wonko gets a {{first 1 perm weapons }}.

3. Assignment lists. For example,
let x=1d5, y=2d x in (x+y,x-y)
This is syntactic sugar for
let x = 1d5 in let y = 2d x in (x+y,x-y)

4. Some sort of bottled expression syntax, like code blocks in Ruby,  
or even just like functions in other languages. For example,
{{define choose_weapon = first 1 perm weapons in everything}}
Wonko gets a {{choose_weapon}} and a {{choose_weapon}}. /* The two  
weapons could differ */

5. Some sort of textual if-else? For example, suppose I need to roll  
some dice, and the outcome determines whether I live or die. If I  
live, then a set of rolls needs to be made to determine by how much;  
if I die, then a different set of rolls needs to be made to determine  
how I am reborn. Ideally, whole blocks of text and instructions would  
be kept or thrown out depending on these rolls. An example:
let wonko_dies = > 4 d6 in
	if wonko_dies then
Wonko dies. E is trapped in limbo for {{2d3}} ndays, and will emerge  
then on square ({{d20}},{{d20}}).
Wonko survives the attack. E gains {{4d3+1d2}} experience and finds a  
{{ first 1 perm("Sword","Axe","Stick")}} of {{ first 1 perm 
("Smiting","Power","Suckiness") }}.
I tried a few months ago to write a python-based dice rolling  
language that had this feature, and being unable to come up with a  
good way to handle this was really what killed the project (well,  
that and prelims). The two ideas I had were first to do it as above,  
where ifs and elses can just contain the end-of-code delimiter and  
the resulting text becomes part of the conditional, and second to do  
it with special penup and pendown functions that would disable and re- 
enable the production of text. But neither is a very clean solution.


spoon-discuss mailing list