PDA

View Full Version : LUA help



Arion
October 1st, 2018, 15:24
I am trying again to make my own ruleset, and i am getting there...slowly.

I can just about handle the xml at the moment, but not lua.

At the moment the roll button rolls 2D6 and compares them to the target number in the "level" box:

elseif rollable_button_attack then
rActor = ActorManager.getActor(sActor, node.getParent().getParent().getParent());
sType = "ability";
sDesc = "[SKILL]";
sTargetDesc = DB.getValue(node, "name", "");
nTarget = DB.getValue(node, "level", "");
rRoll = { sType = sType, sDesc = sDesc, aDice = aDice, nMod = nMod, sTargetDesc = sTargetDesc, nTarget = nTarget };
if draginfo then
draginfo.setCustomData(node);
end;

How would i modify that to add the dice total to the number in the "level" box?

If you could explain why you suggest what you do suggest, that will help me learn.

Thanks,

Trenloe
October 1st, 2018, 15:39
I'm not sure what you're trying to do, so I could be wrong here... If you just want to add what is currently in the "level" field to the roll total, then assign that value to nMod before you roll.

Arion
October 4th, 2018, 17:24
I changed it to this:

elseif rollable_button_attack then
rActor = ActorManager.getActor(sActor, node.getParent().getParent().getParent());
sType = "ability";
sDesc = "[ATTACK]";
nMod = DB.getValue(node, "level", "");
rRoll = { sType = sType, sDesc = sDesc, aDice = aDice, nMod = nMod, sTargetDesc = sTargetDesc, nTarget = nTarget };
if draginfo then
draginfo.setCustomData(node);
end;

At the moment, there is say a 4 in the numerical box for that attack. When i click on the dice button, it rolls 2D6 and compares the total to the 4. If it rolls a 2 and a 4, it gives this:

[ATTACK]
(0+4)=(4): [Failure] by 2 (2 4 6)


What i want it to do is give:

[ATTACK] (2 4 10)

i.e. rolling both dice, totalling them and adding the nMod value to the total. This is using the GURPS ruleset to start with, and this text is above the different roll descriptions:

if node then
local rActor = ActorManager.getActor(sActor, node);
local sType = "dice";
local sDesc = "[ROLL]";
local sTargetDesc = ""
local nTarget = 0;
local aDice = { "d6","d6" };
local nMod = 0;
local sWeapon = "";
local sDamage = "";
local sMode = "";
local nRoF = 1;
local nRcl = 1;
local sOperator = "";
local nNum = 0

local rRoll = { sType = sType, sDesc = sDesc, aDice = aDice, nMod = nMod };

Moon Wizard
October 4th, 2018, 17:58
I'm sort of confused by your explanation, but it sounds like the level should be the target number to beat for the roll?

If there's any comparison to a target number going on; then you'll need to handle it differently.

There are a couple different ways that the D&D rulesets handle a similar situation for saving throws.

1. The target number of the roll (such as saving throw DC) is embedded in the description string (i.e. "[DC 15]"); and then when the roll is resolved, the DC information is parsed out from the description text, and compared against the roll total.

2. The target number of the roll is assigned to a custom field in the roll structure (i.e. rRoll.nTarget = nDC); and then when the roll is resolved, the DC information is pulled from the custom roll field, and compared against the roll total.

Regards,
JPG

Arion
October 4th, 2018, 18:09
I'm sort of confused by your explanation, but it sounds like the level should be the target number to beat for the roll?

If there's any comparison to a target number going on; then you'll need to handle it differently.

There are a couple different ways that the D&D rulesets handle a similar situation for saving throws.

1. The target number of the roll (such as saving throw DC) is embedded in the description string (i.e. "[DC 15]"); and then when the roll is resolved, the DC information is parsed out from the description text, and compared against the roll total.

2. The target number of the roll is assigned to a custom field in the roll structure (i.e. rRoll.nTarget = nDC); and then when the roll is resolved, the DC information is pulled from the custom roll field, and compared against the roll total.

Regards,
JPG

No, no target number needed, just a total. 2D6 + the number in the box.

This though is interesting because some later bits will need TN's.