sciencephile
July 5th, 2014, 15:23
Hi, I'm finally breaking down and asking for help. I know I am close to the finish line but just cannot get over this last hurdle for I know I must be missing a small detail but cannot seem to think of it.
I'm modifying a Core-based set. I am trying to create a rollable field for a custom attribute called "Inspiration Check", which totals a character's Wisdom bonus and their character level. Below is the code for the field itself (xml):
From template_char.xml:
<template name="number_inspirationtotal">
<number_linked>
<frame name="fieldlight" offset="7,5,7,5" />
<displaysign />
<rollable />
<source><name>abilities.wisdom.bonus</name><op>+</op></source>
<source><name>inspiration.level</name><op>+</op></source>
<script>
function action(draginfo)
local nodeWin = window.getDatabaseNode();
if nodeWin then
local rActor = ActorManager.getActor("pc", nodeWin.getChild("..."));
ActionInspiration.performRoll(draginfo, rActor, nodeWin);
end
return true;
end
function onDragStart(button, x, y, draginfo)
return action(draginfo);
end
function onDoubleClick(x,y)
return action();
end
</script>
</number_linked>
</template>
Here is the lua script code I have (in a lua file called "manager_action_inspiration.lua" - I used "manager_action_init.lua" as a starting point):
function onInit()
ActionsManager.registerModHandler("inspiration", modRoll);
ActionsManager.registerResultHandler("inspiration", onResolve);
end
function getRoll(rActor, bSecretRoll)
local rRoll = {};
rRoll.sType = "dice";
rRoll.aDice = { "d20" };
rRoll.nMod = 0;
rRoll.sDesc = "[Inspiration Check]";
rRoll.bSecret = bSecretRoll;
local sAbility = nil;
local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
rRoll.nMod = DB.getValue(nodeActor, "inspiration.total", 0);
sAbility = DB.getValue(nodeActor, "abilities.wisdom.bonus", "");
return rRoll;
end
function performRoll(draginfo, rActor, bSecretRoll)
local rRoll = getRoll(rActor, bSecretRoll);
ActionsManager.performAction(draginfo, rActor, rRoll);
end
function modRoll(rSource, rTarget, rRoll)
if rSource then
local bEffects = false;
sActionStat = "wisdom";
-- GET STAT MODIFIERS
local nBonusStat, nBonusEffects = ActorManager2.getAbilityEffectsBonus(rSource, sActionStat);
if nBonusEffects > 0 then
bEffects = true;
rRoll.nMod = rRoll.nMod + nBonusStat;
end
end
end
function onResolve(rSource, rTarget, rRoll)
local rMessage = ActionsManager.createActionMessage(rSource, rRoll);
Comm.deliverChatMessage(rMessage);
end
This rolls fine with the exception that it does not add the modifier onto the roll. I suspect that there may be an issue with the nodeActor area of the code or in the sType. If I put a static number for rRoll.nMod, it works fine. If I change the rRoll.sType = "init", it works fine but also changes the combat tracker so I cannot cheat and use that. There is something in the way the sType works that I just cannot seem to pinpoint.
A proper nudge in the right direction by someone out there that knows better would be greatly appreciated.
Thank you.
I'm modifying a Core-based set. I am trying to create a rollable field for a custom attribute called "Inspiration Check", which totals a character's Wisdom bonus and their character level. Below is the code for the field itself (xml):
From template_char.xml:
<template name="number_inspirationtotal">
<number_linked>
<frame name="fieldlight" offset="7,5,7,5" />
<displaysign />
<rollable />
<source><name>abilities.wisdom.bonus</name><op>+</op></source>
<source><name>inspiration.level</name><op>+</op></source>
<script>
function action(draginfo)
local nodeWin = window.getDatabaseNode();
if nodeWin then
local rActor = ActorManager.getActor("pc", nodeWin.getChild("..."));
ActionInspiration.performRoll(draginfo, rActor, nodeWin);
end
return true;
end
function onDragStart(button, x, y, draginfo)
return action(draginfo);
end
function onDoubleClick(x,y)
return action();
end
</script>
</number_linked>
</template>
Here is the lua script code I have (in a lua file called "manager_action_inspiration.lua" - I used "manager_action_init.lua" as a starting point):
function onInit()
ActionsManager.registerModHandler("inspiration", modRoll);
ActionsManager.registerResultHandler("inspiration", onResolve);
end
function getRoll(rActor, bSecretRoll)
local rRoll = {};
rRoll.sType = "dice";
rRoll.aDice = { "d20" };
rRoll.nMod = 0;
rRoll.sDesc = "[Inspiration Check]";
rRoll.bSecret = bSecretRoll;
local sAbility = nil;
local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
rRoll.nMod = DB.getValue(nodeActor, "inspiration.total", 0);
sAbility = DB.getValue(nodeActor, "abilities.wisdom.bonus", "");
return rRoll;
end
function performRoll(draginfo, rActor, bSecretRoll)
local rRoll = getRoll(rActor, bSecretRoll);
ActionsManager.performAction(draginfo, rActor, rRoll);
end
function modRoll(rSource, rTarget, rRoll)
if rSource then
local bEffects = false;
sActionStat = "wisdom";
-- GET STAT MODIFIERS
local nBonusStat, nBonusEffects = ActorManager2.getAbilityEffectsBonus(rSource, sActionStat);
if nBonusEffects > 0 then
bEffects = true;
rRoll.nMod = rRoll.nMod + nBonusStat;
end
end
end
function onResolve(rSource, rTarget, rRoll)
local rMessage = ActionsManager.createActionMessage(rSource, rRoll);
Comm.deliverChatMessage(rMessage);
end
This rolls fine with the exception that it does not add the modifier onto the roll. I suspect that there may be an issue with the nodeActor area of the code or in the sType. If I put a static number for rRoll.nMod, it works fine. If I change the rRoll.sType = "init", it works fine but also changes the combat tracker so I cannot cheat and use that. There is something in the way the sType works that I just cannot seem to pinpoint.
A proper nudge in the right direction by someone out there that knows better would be greatly appreciated.
Thank you.