PDA

View Full Version : making Dice string rollable



damned
August 28th, 2014, 13:54
For a character sheet Im working on weapons will be entered with damage ratings/rolls like 2d6+2.
Where can I find an example of how to make this "rollable"?
Can I use the new /die commands somehow? Is there another way?

Trenloe
August 28th, 2014, 15:46
The rRoll.aDice (details of rRoll are in the header of the CoreRPG \scripts\manager_action.lua file) is a table of valid FG dice. If you want to roll 2d6 you need to define the rRoll.aDice table with two d6's: {"d6"," d6"}.

Then set rRoll.nMod to be the modifier, e.g. 2 (a number, not a string).

See desktop\scripts\manager_chat.lua and the processDie function - this is what is ran when the /die slash command is used in the chat window to roll dice. See how the local aDice, nMod = StringManager.convertStringToDice(sDice); command takes the dice part of the /die command and breaks it out into the aDice table and the nMod modifier (put into the rRoll structure at the end of the function). Then further code checks for valid FG dice (to be rolled via the 3D dice) or non-standard dice to be rolled via math.random.

You could use ChatManager.processDie("", "2d6+2") to roll your dice with mod, but the action type would always be "dice" and so you couldn't use this as part of a custom action handler (with a custom rRoll.sType).

You're best understanding the rRoll.aDice table struture and how to add dice to that table - perhaps using the StringManager.convertStringToDice function.

damned
August 28th, 2014, 15:54
you are a funny fellow. speak english for me!

ok... 2d6+2 is an example. it could be 1d8+3 or 2d4 etc.

would I still be going at this the same way?

due to the limited scope of my project (eg character sheet only, no combat tracker, no npcs and no effects) this would not be an opposed roll and nor would it be applied automatically against another object/entity. it would just need to report the result to the chat windows - eg [Damage] <2><5>+2 9

Trenloe
August 28th, 2014, 16:02
you are a funny fellow. speak english for me!
Come on! You've already been through a lot of this with your Maelstrom dice roll antics.

Remember the rRoll.sDesc part from that? This is just another part: rRoll.aDice being a table of dice - it can be anything that FG supports: {"d4","d4"} for 2d4, {"d8"} for 1d8, etc..


would I still be going at this the same way?
Yes. rRoll.aDice = the dice you want to roll in a LUA table format. rRoll.nMod = the modifier you want to apply.


Take a deep breath, go through my first post - look at what I reference, these are examples in the code of the CoreRPG ruleset showing you how it is done.

damned
August 28th, 2014, 16:06
thanks Trenloe. Tomorrow. Today I finished the Main Tab of the Character sheet. Well - have to remove one field still.
https://www.fg-con.com/wp-content/uploads/2014/08/maelstrom-char-main.jpg

Valarian
August 28th, 2014, 16:35
Ooo. Nice.