Wow, huntsfromshadow, this is awesome. Got even better when I found out how to get rid of all that purple. Stylesheet Tiddler could use comments to tell what colors are what.
Anyway, back to the awesome. As a GM, one of my common tasks is to make a secret die roll. Thanks to the Magic of the Computing elves, I've now got one on my Wiki!
It turned out, making the roll was easy, actually closing the Tiddler window when I was finished was the hard part. Oddly enough I couldn't find a built in command to close one other Tiddler rather than hitting the button. Not familiar enough to know if I just missed it, but this method is pretty simple and will come in handy for times when I can open a group of people (like enemies in a combat) in a single Tiddler and at the same time close any individual Tiddlers for those people I have open.
For those who are interested, here's what you need to do.
First you need a way to close a single Tiddler (including the one you're calling it from), create a new Tiddler called CloseWindow, be sure to give it the systemConfig tag as it's a javascript macro
{{{
config.macros.CloseWindow = {
handler: function (place, macroName, params, wikifier, paramString, tiddler)
{
var title = params.length > 0 ? params[0] : null;
story.closeTiddler(title);
}
};
}}}
The triple brackets around the script blocks are a Tiddly formatting code for script and will display it in a colored box to identify it.
Next you need a way to generate and display a roll of Fudge dice, create a new Tiddler called DiceRoller, also give it the systemConfig tag as it's a macro
{{{
config.macros.DiceRoller = {
handler: function (place, macroName, params, wikifier, paramString, tiddler)
{
var die1=parseInt(Math.random()*3)-1;
var die2=parseInt(Math.random()*3)-1;
var die3=parseInt(Math.random()*3)-1;
var die4=parseInt(Math.random()*3)-1;
var total=die1 + die2 + die3 + die4;
confirm("Roll: ("+die1+" "+die2+" "+die3+" "+die4+") = "+total );
}
};
}}}
This shows you the result on each of the four dice as well as the final result, if all you want to see is the result, change it to
confirm("Roll = "+total );
I used confirm, instead of alert because alert beeps when called and the noise annoys me. Click either button or hit the enter key to close the box.
Finally you need a simple way to call your roller, make a new Tiddler called FudgeDice
<<DiceRoller>>
<<CloseWindow FudgeDice>>
Lastly, to put it on your menu bar, to go the MainMenu Tiddler and add
[[FudgeDice]]
where ever in the list you want it to appear, save and reload your Wiki and you're good to go.
Now that I've got that working, my next project is a random name generator. The macros will be pretty big so I'll have to test it and see what kind of performance hit they cause. I hope to use the 1990 name chart from the census and make a weighted roll against the 1000 most common first and last names for both males and females. If nothing else it will give you something to say the next time a player looks in the wallet of a nameless thug he just knocked out or wants to know the names of the patients on a hospital floor.