Random Tables lookups?
I was wondering if I just haven't see the feature or it isn't there, but is there a way as a GM to create a random table.
Seems like it would be a custom snippet that would allow you to give the number of rows in the table, and the table would have a roll number and then description. Then you would have an option to "roll" the dice to look up in the table. something like fumbles: 1 - Your incompetent blow makes you the laughing stock 2 - You damage yourself |
I couldn't find a way to do this, but I was able to create one using html attachments. It would be by nice if this was a feature in line, but I figured I would share what I did, in case others have the same use.
I come across a lot of tables that you roll results for (such as critical hit lists or miss lists), so I wanted some way to have a button that randomly selects from that list. What I did was a simple javascript and I do an add HTML (complete) to have the javascript code, then you can select the html and it will pull it up. here is an example: <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Moods and Attitudes</TITLE> </HEAD> <BODY> <script language="JavaScript"> rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function rnd() { rnd.today=new Date(); rnd.seed=rnd.today.getTime(); rnd.seed = (rnd.seed*9301+49297) % 233280; return rnd.seed/(233280.0); }; function rand(number) { return Math.ceil(rnd()*number); }; function makeArray(n) { this.length = n; for(var i = 1; i <= n; i++) this[i] = ""; return this; } ;// End of function makeArray function BitchRule() { var WIndex = rand(6) ; RClass = new makeArray(7); RClass[0] = "happy, cheerful, optimistic, helpful, friendly"; RClass[1] = "happy, cheerful, optimistic, helpful, friendly"; RClass[2] = "self-pity, unhelpful, brooding, pessimistic"; RClass[3] = "pissed off, vengeful, cruel"; RClass[4] = "playful, energetic, daring, foolhardy, practical joker"; RClass[5] = "vain, proud, lazy, bored, omnipotent feeling"; RClass[6] = "restless, impatient, takes control, urge to get on with things, roll 1d6 for obsession check"; return RClass[WIndex]; }; </script> <form> <input type="button" name="Button1" value="Moods and Attitudes" onClick="this.form.textField1.value = BitchRule()" size="" /> <textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea> </form> </BODY> </HTML> |
That is a pretty neat way to accomplish a random table within the program and with the current functionality. thumbs up.
|
Oh, this is awesome! If someone could do this for a variety of tables I use, I would be so happy!
Either that, or it's time I start learning how to code. :) |
Nice, I use Inspiration Pad Pro and just put the table files directly in RW as attachements, but that looks like it'd work as well.
|
This is great.
Could someone who can code please modify the above code to roll a percentile instead of a D6, and make the results a range vs a single digit. I would like to use it as a random encounter generator. |
easy enough. but how many options do you want, and do you want it evenly distributed, if not, please provide the numbers.
Thanks. Range vs a single digit is still a percent, but happy to do so. |
ok, here you go. I changed a couple things.
1. array can be any size (you dont need a makeArray method) 2. using "ranges" (technically percentile from 1-100) it actually only looks at the max. (you dont need to specify a min) Now i havent tried this inline yet, but this is vanilla javascript. <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Moods and Attitudes</TITLE> </HEAD> <BODY> <script language="JavaScript"> rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function rnd() { rnd.today=new Date(); rnd.seed=rnd.today.getTime(); rnd.seed = (rnd.seed*9301+49297) % 233280; return rnd.seed/(233280.0); } function rand(number) { return Math.ceil(rnd()*number); } function BitchRule() { var randomNum = rand(100) + 1; console.log(randomNum); var arrayOfChoices = []; arrayOfChoices.push( {"max": 15, "content": "happy, cheerful, optimistic, helpful, friendly" }); arrayOfChoices.push({"max": 30, "content": "happy, cheerful, optimistic, helpful, friendly"}); arrayOfChoices.push({"max": 45, "content": "self-pity, unhelpful, brooding, pessimistic"}); arrayOfChoices.push({"max": 60, "content": "pissed off, vengeful, cruel"}); arrayOfChoices.push({"max": 75, "content": "playful, energetic, daring, foolhardy, practical joker"}); arrayOfChoices.push({"max": 99, "content": "vain, proud, lazy, bored, omnipotent feeling"}); arrayOfChoices.push({"max": 100,"content": "restless, impatient, takes control, urge to get on with things, roll 1d6 for obsession check"}); var chosenString = ""; for (var itemIndex in arrayOfChoices) { var item = arrayOfChoices[itemIndex]; if (randomNum <= item.max) { chosenString = item.content; break; } } return chosenString; } </script> <form> <input type="button" name="Button1" value="Moods and Attitudes" onClick="this.form.textField1.value = BitchRule()" size="" /> <textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea> </form> </BODY> </HTML> |
btw, if you dont like the "max" and "content", i could easily make it more array/index based, i just prefer that because its easier to look at the code, and if you want to add other pieces of data, you could. (say you had two fields, one for a short description, one for a long description)
|
Thank You Mirtos. There seems to be something wrong with the code. Nothing displays when to click the button. I have started to modify the code to become the Crown of the World Random Encounter table. This is what I have so far. Not sure what values to change to make a different array for each button. Again thank you mirtos for your help.
<HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE>Crown of the World Random Encounters</TITLE> </HEAD> <BODY> <script language="JavaScript"> rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function rnd() { rnd.today=new Date(); rnd.seed=rnd.today.getTime(); rnd.seed = (rnd.seed*9301+49297) % 233280; return rnd.seed/(233280.0); } function rand(number) { return Math.ceil(rnd()*number); } function BitchRule() { var randomNum = rand(100) + 1; console.log(randomNum); var arrayOfChoices = []; arrayOfChoices.push( {"max": 18, "content": "1 draugr; CR 2; Bestiary 2 110" }); arrayOfChoices.push({"max": 31, "content": "1 bunyip; CR 3; Bestiary 2 50"}); arrayOfChoices.push({"max": 59, "content": "1 orca; CR 5; Bestiary 88"}); arrayOfChoices.push({"max": 72, "content": "1 selkie; CR 5; Pathfinder #50 pg 88"}); arrayOfChoices.push({"max": 84, "content": "1 glacier toad; CR 6; Bestiary 2 268"}); arrayOfChoices.push({"max": 100,"content": "1 qallupilluk; CR 7; Pathfinder #51 pg 88"}); var chosenString = ""; for (var itemIndex in arrayOfChoices) { var item = arrayOfChoices[itemIndex]; if (randomNum <= item.max) { chosenString = item.content; break; } } return chosenString; } </script> <form> <input type="button" name="Button1" value="Aquatic" onClick="this.form.textField1.value = BitchRule()" size="" /> <textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea> </form> <form> <input type="button" name="Button2" value="Forest" onClick="this.form.textField1.value = BitchRule()" size="" /> <textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea> </form> <form> <input type="button" name="Button3" value="Hills" onClick="this.form.textField1.value = BitchRule()" size="" /> <textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea> </form> <form> <input type="button" name="Button4" value="Mountains" onClick="this.form.textField1.value = BitchRule()" size="" /> <textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea> </form> <form> <input type="button" name="Button5" value="Tundra" onClick="this.form.textField1.value = BitchRule()" size="" /> <textarea name="textField1" cols="40" rows="1" wrap="soft"></textarea> </form> </BODY> </HTML> |
All times are GMT -8. The time now is 07:38 PM. |
Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.