Node.LinkedInputNode()

Smart people ~ Great Scripts
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Node.LinkedInputNode()

Post by trueBlue »

When using Node.LinkedInputNode() in a scenario and the Connector is not hooked up it will throw an error!
Is there a way to stop this error?

This Test.RsObj disconnects|connects the Connector so the error does not happen.
It also runs the Watch Dog Event when it is loaded into the scene by way of an OnPostLoad function, which is twofold.
One it wakes up the notorious sleeping Watch Dog Event and two, runs the script that is hooked up to it.
Load this Test.RsObj into a scene.
In the Link Editor, enter inside this Test.RsObj and connect the Cube's "WldMatrix" to the Watch Dog Event's "Change detect".
Watch the connection disconnect | connect when you run your mouse over and away from the Cube.
You do not have the required permissions to view the files attached to this post.
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Node.LinkedInputNode()

Post by clintonman »

trueBlue wrote: 03 Feb 2023, 17:23 When using Node.LinkedInputNode() in a scenario and the Connector is not hooked up it will throw an error!
Is there a way to stop this error?

This Test.RsObj disconnects|connects the Connector so the error does not happen.
Load this Test.RsObj into a scene.
In the Link Editor, enter inside this Test.RsObj and connect the Cube's "WldMatrix" to the Watch Dog Event's "Change detect".
Watch the connection disconnect | connect when you run your mouse over and away from the Cube.
Node.LinkedInputNodeCount to be sure something is connected
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Node.LinkedInputNode()

Post by trueBlue »

I have that and it does not stop the error if it is Not connected.
ERR Source object: /Project/Space 3D/Test/LinkedInput Error: Microsoft JScript runtime error Description: Invalid procedure call or argument Error code: 0x800a0005 - (null) Line: 6, Char: 1 Script text: var inputNode = Node.LinkedInputNode(System.ThisName(), " Control In", 0)
Maybe it is wrong?

Code: Select all

	var inputNode = Node.LinkedInputNode(System.ThisName(), " Control In", 0)

	if(Node.ConExists(inputNode, "Change detect")) {
		if(Node.LinkedInputNodeCount(inputNode, "Change detect") == 0)
		return;
	}
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Node.LinkedInputNode()

Post by clintonman »

trueBlue wrote: 03 Feb 2023, 23:38 I have that and it does not stop the error if it is Not connected.
ERR Source object: /Project/Space 3D/Test/LinkedInput Error: Microsoft JScript runtime error Description: Invalid procedure call or argument Error code: 0x800a0005 - (null) Line: 6, Char: 1 Script text: var inputNode = Node.LinkedInputNode(System.ThisName(), " Control In", 0)
Maybe it is wrong?

Code: Select all

	var inputNode = Node.LinkedInputNode(System.ThisName(), " Control In", 0)

	if(Node.ConExists(inputNode, "Change detect")) {
		if(Node.LinkedInputNodeCount(inputNode, "Change detect") == 0)
		return;
	}
Backward, You have to test for the existence of a linked node before you try to use or get the linked node.

Code: Select all

	if(Node.LinkedInputNodeCount(inputNode, "Change detect") == 0)
		return;
		
	var inputNode = Node.LinkedInputNode(System.ThisName(), " Control In", 0)

	if(Node.ConExists(inputNode, "Change detect")) {
		
	}
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Node.LinkedInputNode()

Post by trueBlue »

That gives an error too.
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Node.LinkedInputNode()

Post by clintonman »

trueBlue wrote: 04 Feb 2023, 00:40 That gives an error too.
I see, I just rearranged the code. You're getting the link count of one thing and then trying to get the linked node of another thing. I can look at your actual code later.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Node.LinkedInputNode()

Post by clintonman »

trueBlue wrote: 03 Feb 2023, 17:23 When using Node.LinkedInputNode() in a scenario and the Connector is not hooked up it will throw an error!
Is there a way to stop this error?

This Test.RsObj disconnects|connects the Connector so the error does not happen.
It also runs the Watch Dog Event when it is loaded into the scene by way of an OnPostLoad function, which is twofold.
One it wakes up the notorious sleeping Watch Dog Event and two, runs the script that is hooked up to it.
Load this Test.RsObj into a scene.
In the Link Editor, enter inside this Test.RsObj and connect the Cube's "WldMatrix" to the Watch Dog Event's "Change detect".
Watch the connection disconnect | connect when you run your mouse over and away from the Cube.
I don't know if this stops the error or not. No instructions on how to make the error happen and I don't know what this is trying to do, so this is just a guess. It looks the same as before the change when using the object nav widget. Also don't know what "run your mouse over and away from the Cube" means, so I just used the widget to move the cube around.

Code: Select all

// Execute 
// Called to execute the command 
function Execute(params)
{

	//var inputNode = Node.LinkedInputNode(System.ThisName(), " Control In", 0)

	//if(Node.ConExists(inputNode, "Change detect")) {
	//	if(Node.LinkedInputNodeCount(inputNode, "Change detect") == 0)
	//		return;
	//}

	if(Node.LinkedInputNodeCount(System.ThisName(), " Control In") == 0) {
		params.SetTerminationFlag();
		return;
	}

	var inputNode = Node.LinkedInputNode(System.ThisName(), " Control In", 0);

	if(!Node.ConExists(inputNode, "Change detect")) {
		params.SetTerminationFlag();
		return;
	}
}
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Node.LinkedInputNode()

Post by trueBlue »

That works without errors.
Oddly though, the script that is hooked up to this script still runs even when it is not hooked up to the Watch Dog Event and run it from the Start button. :shock:
You would think that params.SetTerminationFlag() would stop it from running.
I can see that the Control Out = 2
LinkedInput script.png
You do not have the required permissions to view the files attached to this post.
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Node.LinkedInputNode()

Post by clintonman »

trueBlue wrote: 04 Feb 2023, 05:24 That works without errors.
Oddly though, the script that is hooked up to this script still runs even when it is not hooked up to the Watch Dog Event and run it from the Start button. :shock:
You would think that params.SetTerminationFlag() would stop it from running.
I can see that the Control Out = 2
LinkedInput script.png
You can't tell a script is running by looking at it. Try adding a trace or alert inside the Disconnect node

Code: Select all

// Execute 
// Called to execute the command 
function Execute(params)
{
	System.Trace("yes i am running")
	Node.Disconnect(System.ThisOwner() + "/Watch Dog Event", " Control Out", System.ThisOwner() + "/LinkedInput", " Control In")

}
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Node.LinkedInputNode()

Post by trueBlue »

Ah, I see now!
I was fooled because the ConnectTo script also disconnects | connects.
Not understanding why, you do not know how to see this Test object in use.
The Test object is a 2D Encapsulation with the scripts and 3D object.
It is not necessary to select the 3D object.
Just use your mouse to hoover over and away from the 3D object.
trueSpace shows pre-selection highlight color.
When you hoover over the 3D object, it connects the Watch Dog Event to the LinkedInput script.
When you hoover away from the 3D object, it disconnects the Watch Dog Event to the LinkedInput script.
Anyways, it was just a Test object to test the LinkedInput script.
And now, thanks to you, it works without throwing an error.
Thank you! :bananathumb:
When you are not busy maybe you can show how to use Node.LinkedOutputNode() :mrgreen:
Post Reply