Diablobob
July 25th, 2019, 17:31
I am trying to figure out how to make an addHandler to watch the exp field of the party, and trigger a message when they receive xp..
I do not know the best way to trigger it... I'm also not sure if the node I'm having it watch is the correct node... This script is completely off the top of my head... but it is something I am trying to figure out how to approach
I'm not sure if it would be easier to watch the charsheet exp field or the partysheet exp field...
What I am trying to do is when xp is awarded, I am trying to generate a chat message saying how much xp / xp needed each character in the party has...
onInit()
DB.addHandler("charsheet.*.exp", "onUpdate", sendMsg);
end
function sendMsg(expNode)
local expWindow = expNode.getParent();
local nodeChar = expWindow.getParent();
local exp = expNode.getValue();
local expNeeded = DB.getValue(DB.findNode(expWindow),"expneeded","");
local charName = DB.getValue(nodeChar, "name", 0);
local msg {};
msg.text = charName.." has "..exp.."/"..expNeeded.." XP";
Comm.deliverChatMessage(msg);
end
any suggestions? corrections?
V/r,
Diablobob
I do not know the best way to trigger it... I'm also not sure if the node I'm having it watch is the correct node... This script is completely off the top of my head... but it is something I am trying to figure out how to approach
I'm not sure if it would be easier to watch the charsheet exp field or the partysheet exp field...
What I am trying to do is when xp is awarded, I am trying to generate a chat message saying how much xp / xp needed each character in the party has...
onInit()
DB.addHandler("charsheet.*.exp", "onUpdate", sendMsg);
end
function sendMsg(expNode)
local expWindow = expNode.getParent();
local nodeChar = expWindow.getParent();
local exp = expNode.getValue();
local expNeeded = DB.getValue(DB.findNode(expWindow),"expneeded","");
local charName = DB.getValue(nodeChar, "name", 0);
local msg {};
msg.text = charName.." has "..exp.."/"..expNeeded.." XP";
Comm.deliverChatMessage(msg);
end
any suggestions? corrections?
V/r,
Diablobob