-
April 17th, 2019, 06:12 #1
- Join Date
- Jun 2018
- Posts
- 112
Problems passing node information through OOB message
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:
Code:function onValueChanged() local nodeWin = window.getDatabaseNode(); DoStuffManager.sendFunction(nodeWin); end;
my LUA code:
Code:function onInit() OOBManager.registerOOBMsgHandler(RUN_FUNCTION, runFunction); end
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
Code: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
I also figured I’d post what I learned, so others could get some help from it as well!Last edited by Diablobob; April 18th, 2019 at 11:24.
-
April 17th, 2019, 06:51 #2
first part to test
msgSCT.type = CREATE_NODE;
i think should be
msgSCT.type = RUN_FUNCTION;
in your example?
-
April 17th, 2019, 12:12 #3
- Join Date
- Jun 2018
- Posts
- 112
It is, I just edited the name of the message to try not to make it confusing... I’ve gone through many stages of troubleshooting... after I posted the question, I changed it in to meet the post for ease of problem solving. Good catch! But unfortunately that is not my issue... I wish it was... the output is the same...
-
April 17th, 2019, 12:21 #4
- Join Date
- Jun 2018
- Posts
- 112
What is the function to find a node using it’s name?
Would it work with getCTNode?
-
April 17th, 2019, 13:16 #5
I think you’re on this track now - You need to pass the complete node name as a string to the OOB process, and then get the node from that on the other side.
Use <databasenode>.getNodeName to get the complete node name as a string: https://www.fantasygrounds.com/refdo...cp#getNodeName
Use DB.findNode to get the databasenode object from the node name: https://www.fantasygrounds.com/refdoc/DB.xcp#findNodePrivate Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
April 18th, 2019, 03:12 #6
- Join Date
- Jun 2018
- Posts
- 112
Thank you, wonderful guys, for the help!
-
April 18th, 2019, 05:43 #7
-
April 18th, 2019, 11:02 #8
- Join Date
- Jun 2018
- Posts
- 112
I did. I edited the original posted code, to be the current and working code.
I figured that’d Be less confusing than having multiple versions, only one that worked.
I also updated that post to try to better explain what’s going on and the thought process behind it.
Please let me know what you think, and if I missed anything.
Thank you again!Last edited by Diablobob; April 18th, 2019 at 11:23.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks