PDA

View Full Version : Potential Buyer Question: Custom Dice



Kioma
March 7th, 2012, 14:19
Hello, all!

I'm very seriously considering purchasing Fantasy Grounds II and one of the main things my decision will hinge upon is the capacity to make custom rulesets.

Now, the main thing I'm concerned about is the custom dice creation. Realistically all custom dice are made functional through Lua scripting, as I understand it. Unfortunately I know only a little about Lua.

Here's my question: is there a simple but effective way of making a custom die completely change a number result?

To be clear, I don't mean changing the overall number of sides. I mean a die in which all results except one function normally.

Would it be as simple as defining a separate custom die and scripting in the Lua equivalent of, as an example, 'if dieresult = 20 then dieresult = 200'?

Thanks in advance!

Moon Wizard
March 7th, 2012, 16:42
The most likely answer to your question is yes, but without details of what you are trying to do, it's hard to tell.

There are 7 die models in the program (standard 6 RPG dice plus d100 die). If you want to be able to virtually roll the dice (as opposed to having code auto-generate result), then you will have to use one of these physical models.

As the dice are rolling, the numbers on the die will correspond to the standard die enumeration on physical dice. However, the results can be customized before they are displayed in the chat window. This is how d2 and d3 are implemented using the d6 model.

Also, others have implemented logic to perform exploding dice, rerolls and success calculations.

If you give more information, I can be more specific.

Regards,
JPG

Kioma
March 7th, 2012, 16:53
Well, to be honest I'm not sure how much more specific I can be.

I'm looking for a way of making a function like the d3, but instead of dividing the result in half with return math.ceil(result/2) it replaces one of the numbers with a different number (such as replacing the 6 with a 10 or the 1 with a -4). Not a modifier to the roll, but making one of the die faces equal a different number.

Sort of, 'if the number comes up as a 6 then count it as a 10, but otherwise count it as its original value'. 'if result = 6 then return result = 10' I suppose.

Moon Wizard
March 7th, 2012, 18:45
Yeah, that would be exactly the same sort of code as the d2 or d3.

if result == 6 then return 10; end

Regards,
JPG

Kioma
March 7th, 2012, 18:48
Oooh, hmm. Lua's that straightforward? Okay. This is looking better and better.

Would your above resolution, out of curiosity, be treated in any calculations as 10 or would it just display 10? What I mean to say is, does the 'return' function act as 'print' or does it actually alter the mathematical value to 10 for the purposes of display and any later calculations?

Sorry for all the questions... I think I'm falling in (purely Platonic and non-creepy) love with Fantasy Grounds 2, and want to make sure I'm understand it correctly.

Moon Wizard
March 7th, 2012, 19:12
Here is the current implementation of d3 from our 3.5E ruleset:



function onValue(result)
return math.ceil(result/2);
end


And a picture of what it looks like on the screen. The 3D die shows the number rolled using the 3D model (standard die numbering), but the result displayed in the chat window use the output of the custom die function.

Regards,
JPG