Lone Wolf Development Forums  

Go Back   Lone Wolf Development Forums > Realm Works Forums > Realm Works Discussion

Notices

Reply
 
Thread Tools Display Modes
Repeater07
Junior Member
 
Join Date: Aug 2014
Posts: 11

Old August 4th, 2014, 12:39 PM
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
Repeater07 is offline   #1 Reply With Quote
Repeater07
Junior Member
 
Join Date: Aug 2014
Posts: 11

Old August 5th, 2014, 01:36 PM
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>
Repeater07 is offline   #2 Reply With Quote
Ladyofdragons
Senior Member
 
Join Date: Dec 2011
Location: NJ, USA
Posts: 130

Old August 7th, 2014, 08:00 AM
That is a pretty neat way to accomplish a random table within the program and with the current functionality. thumbs up.

-------------------------------------
"...You're going to backstab him with a ballista?"
Ladyofdragons is offline   #3 Reply With Quote
gloranphile
Senior Member
 
Join Date: Mar 2013
Location: Denver, CO
Posts: 413

Old August 7th, 2014, 09:07 AM
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.
gloranphile is offline   #4 Reply With Quote
enrious
Senior Member
 
Join Date: Sep 2009
Posts: 175

Old August 8th, 2014, 04:35 PM
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.
enrious is offline   #5 Reply With Quote
jkthomsen9
Senior Member
 
Join Date: Jun 2010
Location: Beaverton, OR
Posts: 266

Old August 8th, 2014, 10:49 PM
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.
jkthomsen9 is offline   #6 Reply With Quote
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 9th, 2014, 12:21 AM
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.
mirtos is offline   #7 Reply With Quote
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 9th, 2014, 12:55 AM
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>
mirtos is offline   #8 Reply With Quote
mirtos
Senior Member
 
Join Date: Oct 2011
Posts: 865

Old August 9th, 2014, 09:06 AM
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)
mirtos is offline   #9 Reply With Quote
jkthomsen9
Senior Member
 
Join Date: Jun 2010
Location: Beaverton, OR
Posts: 266

Old August 9th, 2014, 11:34 AM
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>

Last edited by jkthomsen9; August 9th, 2014 at 11:38 AM. Reason: mistake in code
jkthomsen9 is offline   #10 Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 07:20 AM.


Powered by vBulletin® - Copyright ©2000 - 2018, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.