Diablobob
April 17th, 2019, 06:12
I was having issues with OOB messages.
description of situation: in the character sheet, I am trying to change a value. Changing that value triggers a script to create a child, save the value of field2 to the child node, and then update field2.
Obviously to create a child, you need to be host.
when I pass the node of the charsheet through the msgOOB, everything goes in right... verified with debug statements... but when I pull the info out in the triggered function, the node is nil...
UPDATE: continued from explanation above: so I use x.getNodeName() to turn the node name into a string. I then send the string through the OOB message. Then I have the GM pull the string, and turn it back into the node using DB.findNode(x) Then I have the GM use that correct node to run the original function again.
LESSONS LEARNED: OOB messages can transfer some nodes, but not all. And the ones it can, seam to be inconsistent. So turning it into a string and sending that, is a very stable way to perform this function so that the player can initiate the GM to process a function for them (inside FG).
CORRECTED AND WORKING CODE:
my XML code for the trigger:
function onValueChanged()
local nodeWin = window.getDatabaseNode();
DoStuffManager.sendFunction(nodeWin);
end;
my LUA code:
function onInit()
OOBManager.registerOOBMsgHandler(RUN_FUNCTION, runFunction);
end
send code function: (to see if the Host is running the script, if not send OOB message, if host run the rest of the code)
function sendFunction(nodeWin)
if not User.isHost() then
Debug.console(nodeWin);
local CharShtNm = nodeWin.getNodeName();
Debug.console(CharShtNm);
local msgSCT = {};
msgSCT.type = RUN_FUNCTION;
msgSCT.CharShtNm = CharShtNm;
Debug.console(msgSCT);
Comm.deliverOOBMessage(msgSCT);
return;
end
Debug.console("yay, made it!");
REST OF CODE!
end
Then I pull data in the OOB triggered function: (have the host turn the OOB string sent back into a node, and then have the host run the sendFunction using the correct node)
function runFunction(msgSCT)
Debug.console("doing stuff");
if not User.isHost() then
return;
end
local CharShtNm = msgSCT.CharShtNm;
Debug.console(CharShtNm);
local nodeWin = DB.findNode(CharShtNm);
sendFunction(nodeWin);
end
This is the corrected code... I figured out with your guys’s Help that OOB messaging should mainly send string data, and find the node in the other side... that’s the only reliable way to use it... things like nodeCT and such being transferred, is dependent on too many things to be truly reliable as a method to trigger the functions.
I also figured I’d post what I learned, so others could get some help from it as well!
description of situation: in the character sheet, I am trying to change a value. Changing that value triggers a script to create a child, save the value of field2 to the child node, and then update field2.
Obviously to create a child, you need to be host.
when I pass the node of the charsheet through the msgOOB, everything goes in right... verified with debug statements... but when I pull the info out in the triggered function, the node is nil...
UPDATE: continued from explanation above: so I use x.getNodeName() to turn the node name into a string. I then send the string through the OOB message. Then I have the GM pull the string, and turn it back into the node using DB.findNode(x) Then I have the GM use that correct node to run the original function again.
LESSONS LEARNED: OOB messages can transfer some nodes, but not all. And the ones it can, seam to be inconsistent. So turning it into a string and sending that, is a very stable way to perform this function so that the player can initiate the GM to process a function for them (inside FG).
CORRECTED AND WORKING CODE:
my XML code for the trigger:
function onValueChanged()
local nodeWin = window.getDatabaseNode();
DoStuffManager.sendFunction(nodeWin);
end;
my LUA code:
function onInit()
OOBManager.registerOOBMsgHandler(RUN_FUNCTION, runFunction);
end
send code function: (to see if the Host is running the script, if not send OOB message, if host run the rest of the code)
function sendFunction(nodeWin)
if not User.isHost() then
Debug.console(nodeWin);
local CharShtNm = nodeWin.getNodeName();
Debug.console(CharShtNm);
local msgSCT = {};
msgSCT.type = RUN_FUNCTION;
msgSCT.CharShtNm = CharShtNm;
Debug.console(msgSCT);
Comm.deliverOOBMessage(msgSCT);
return;
end
Debug.console("yay, made it!");
REST OF CODE!
end
Then I pull data in the OOB triggered function: (have the host turn the OOB string sent back into a node, and then have the host run the sendFunction using the correct node)
function runFunction(msgSCT)
Debug.console("doing stuff");
if not User.isHost() then
return;
end
local CharShtNm = msgSCT.CharShtNm;
Debug.console(CharShtNm);
local nodeWin = DB.findNode(CharShtNm);
sendFunction(nodeWin);
end
This is the corrected code... I figured out with your guys’s Help that OOB messaging should mainly send string data, and find the node in the other side... that’s the only reliable way to use it... things like nodeCT and such being transferred, is dependent on too many things to be truly reliable as a method to trigger the functions.
I also figured I’d post what I learned, so others could get some help from it as well!