PDA

View Full Version : Roll on table on result



pr6i6e6st
August 22nd, 2019, 07:00
Hey guys. How do I make the stress dice from my Alien RPG ruleset roll on a table. Looking for a mechanic like that of the d&D5e Critical Hit/Fumble option.

Basically I want for my stress dice to automatically roll a number of dice on a table in game labeled “PANIC ROLL EFFECT RESULTS” if a 1 is rolled.

I just can’t figure out how to call up the roll in the first place. Any suggestions/examples? I think I found it in the 5e code, but there’s a lot of excess from checking other options and Booleans that I can’t determine the difference between what’s needed in my code and what needs to be changed/removed.

Zacchaeus
August 22nd, 2019, 09:52
You would need an extension to do that I think.

pr6i6e6st
August 22nd, 2019, 14:24
You would need an extension to do that I think.

Yeah I’m looking for an example of how to code that.

https://www.fantasygrounds.com/forums/showthread.php?50544-WIP-Alien-RPG-extension&highlight=

Trenloe
August 22nd, 2019, 16:14
In 5E the code to initiate the roll for a fumble or critical is handled via OOB messaging - yep, you're going to have to learn about that now! ;)

But, all that really does is call the handleApplyHRFC function that issues TableManager.processTableRoll("", msgOOB.sTable); where "msgOOB.sTable" is the table name to roll on. The dice to roll are set directly in that table.

EDIT: essentially the TableManager.processTableRoll("", "tablename") is the same as issuing a chat command: /rollon tablename

pr6i6e6st
August 22nd, 2019, 16:18
In 5E the code to initiate the roll for a fumble or critical is handled via OOB messaging - yep, you're going to have to learn about that now! ;)

But, all that really does is call the handleApplyHRFC function that issues TableManager.processTableRoll("", msgOOB.sTable); where "msgOOB.sTable" is the table name to roll on. The dice to roll are set directly in that table.

Lol ok. Yeah I thought I was in the right spot there. So I’ll just have to play around with that a bit. Once I figure out how to work with all that, I can use it for npc attacks and initiative (works by drawing cards in this game, so I’ll be trying to incorporate your card extension somehow)

pr6i6e6st
August 22nd, 2019, 20:28
Ok, cool, thank you. so I got that kind of working, or at least sort of figured out. So which function might I want to look at to tell the table to roll a variable amount of stress dice (dS) rather than what it has stored? Or is that possible?

Trenloe
August 22nd, 2019, 20:34
Ok, cool, thank you. so I got that kind of working, or at least sort of figured out. So which function might I want to look at to tell the table to roll a variable amount of stress dice (dS) rather than what it has stored? Or is that possible?
Get it working using the /rollon chat command - see the syntax here: https://www.fantasygrounds.com/wiki/index.php/Chat_Commands

Then use whatever you specify after /rollon in the chat as the second argument to TableManager.processTableRoll

For example: TableManager.processTableRoll("", "myTable -d 2dS")

If you want to see the code, look at the processTableRoll function in the CoreRPG TableManager global package (scripts\manager_table.lua).

pr6i6e6st
August 22nd, 2019, 21:23
oh man, it's so close to working. can the number of dice be a variable?

kind of like:
nValue = getValue();
TableManager.processTableRoll("", "myTable -d nValuedS")
or
TableManager.processTableRoll("", "myTable -d getValue()dS")

the above doesn't work straight like that,

Trenloe
August 22nd, 2019, 21:26
oh man, it's so close to working. can the number of dice be a variable?

kind of like:
nValue = getValue();
TableManager.processTableRoll("", "myTable -d nValuedS")
or
TableManager.processTableRoll("", "myTable -d getValue()dS")

the above doesn't work straight like that,
The argument you pass is a string. So, construct that string as you need - look up how to construct LUA strings in standard LUA tutorials. But you can use something like this: "myTable -d " .. nValue .. "dS"

Info on string construction here: https://lua-users.org/wiki/StringsTutorial

pr6i6e6st
August 22nd, 2019, 21:35
awesome! that works! it doesn't recognize my stress or base dice that way yet, it seems, but a d6 works just fine in its place. you're a legend.