DICE PACKS BUNDLE
  1. #1

    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
    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)
    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)
    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
    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!
    Last edited by Diablobob; April 18th, 2019 at 11:24.

  2. #2

  3. #3
    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...

  4. #4
    What is the function to find a node using it’s name?

    Would it work with getCTNode?

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    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#findNode
    Private 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!

  6. #6
    Thank you, wonderful guys, for the help!

  7. #7
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,678
    Blog Entries
    1
    Quote Originally Posted by Diablobob View Post
    Thank you, wonderful guys, for the help!
    Nah - you have to post your working code for the next person...!

  8. #8
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Starfinder Playlist

Log in

Log in