damned
September 16th, 2014, 01:33
Im having trouble extending my INIT rolls.
Together with Trenloe we scripted the action for the NPCs.
Now I need to take that code and check whether it was a PC or an NPC that rolled and then update a different database field depending on who did it...
This function checks where the INIT roll came from:
function getSkillRoll(rActor, vSkill)
local rRoll = {};
rRoll.sType = "init";
rRoll.aDice = { "d10","d10" };
local sInit = DB.getValue(vSkill, "Speed", "");
Debug.console("sInit:" .. sInit);
local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
Debug.console("nodeActor: " .. nodeActor);
Debug.console("sActorType: " .. sActorType);
rRoll.sDesc = "[INIT] " .. DB.getValue(vSkill, "value", "");
return rRoll;
end
returning pc or npc for sActorType
In the case of npc I need to update the npc.init database field (which works) but I cant work out the right syntax to check if its a PC or a NPC rolling and in the case of PC update the char.init field instead...
function onRoll(rSource, rTarget, rRoll)
local rMessage = ActionsManager.createActionMessage(rSource, rRoll);
-- Get the total of the roll - this includes and modifiers
local sRollTotal = ActionsManager.total(rRoll);
-- Get the actor type and the database node of that actor (the record that made the roll).
local sActorType, nodeActor = ActorManager.getTypeAndNode(rSource);
-- If we have a valid actor database node:
if nodeActor then
--Get the npc init node and set the total value
local npcInitDBNode = nodeActor.getChild("npc.init");
npcInitDBNode.setValue(sRollTotal);
end
rMessage.text = rMessage.text .. " " .. sRollTotal;
Comm.deliverChatMessage(rMessage);
end
Together with Trenloe we scripted the action for the NPCs.
Now I need to take that code and check whether it was a PC or an NPC that rolled and then update a different database field depending on who did it...
This function checks where the INIT roll came from:
function getSkillRoll(rActor, vSkill)
local rRoll = {};
rRoll.sType = "init";
rRoll.aDice = { "d10","d10" };
local sInit = DB.getValue(vSkill, "Speed", "");
Debug.console("sInit:" .. sInit);
local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
Debug.console("nodeActor: " .. nodeActor);
Debug.console("sActorType: " .. sActorType);
rRoll.sDesc = "[INIT] " .. DB.getValue(vSkill, "value", "");
return rRoll;
end
returning pc or npc for sActorType
In the case of npc I need to update the npc.init database field (which works) but I cant work out the right syntax to check if its a PC or a NPC rolling and in the case of PC update the char.init field instead...
function onRoll(rSource, rTarget, rRoll)
local rMessage = ActionsManager.createActionMessage(rSource, rRoll);
-- Get the total of the roll - this includes and modifiers
local sRollTotal = ActionsManager.total(rRoll);
-- Get the actor type and the database node of that actor (the record that made the roll).
local sActorType, nodeActor = ActorManager.getTypeAndNode(rSource);
-- If we have a valid actor database node:
if nodeActor then
--Get the npc init node and set the total value
local npcInitDBNode = nodeActor.getChild("npc.init");
npcInitDBNode.setValue(sRollTotal);
end
rMessage.text = rMessage.text .. " " .. sRollTotal;
Comm.deliverChatMessage(rMessage);
end