Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

ProtoFlux:FieldHook: Difference between revisions

From Resonite Wiki
Clarify hooking
m Formatting.
 
(3 intermediate revisions by 3 users not shown)
Line 20: Line 20:


The '''Field Hook''' node takes in a target [[Type:IField`1|field]] and the source field value, then returns if this field is [[Drive|driving]], as well as allowing the [[User|user]] to start and stop driving this field. This node gives the user more control to programmatically drive fields directly using ProtoFlux. This node hooks the given field, so whenever something external tries to write to it, it will receive a pulse from OnHook as well as the value it tried to write from HookedValue.
The '''Field Hook''' node takes in a target [[Type:IField`1|field]] and the source field value, then returns if this field is [[Drive|driving]], as well as allowing the [[User|user]] to start and stop driving this field. This node gives the user more control to programmatically drive fields directly using ProtoFlux. This node hooks the given field, so whenever something external tries to write to it, it will receive a pulse from OnHook as well as the value it tried to write from HookedValue.
Manually unlinking the drive in an inspector behaves the same as triggering StopDrive.


== Inputs ==
== Inputs ==
Line 37: Line 39:
=== Source (Generic) ===
=== Source (Generic) ===


The source to drive from.
The source to drive Target from. While active this acts like any other drive.


== Outputs ==
== Outputs ==
Line 60: Line 62:


Returns the value that was written by the OnHook call.
Returns the value that was written by the OnHook call.
== Examples ==
The example saves the current position of the cube on loading so it can will return to that spot 5 seconds after being moved.
It stores the inital position in a DataModel Store as well as triggering StartDrive. When the cube is moved, it uses the OnHook impulse to write HookedValue to a DataModel Store connected to Source, allowing the cube to behave like normal. And 5 seconds latter overwrites this with the initial position. When saving the cube, OnSave triggers StopDrive so to the cube is ready for next time.
Item: <code>resrec:///U-1cLc1qmP4CG/R-fcdb06e2-dfb2-475c-9161-6c2169720704</code>
[[File:FieldHookExample.jpg|thumb|Cube that returns to initial Position after 5 seconds.]]
A much more advanced set of practical examples can be found in by Baxer can be found in their MMC25 world "Swangin' Doors":
https://go.resonite.com/record/U-Baxter/R-f8cf3c37-d4bb-4d9d-a19b-227790c19af5


[[Category:ProtoFlux:Core]]
[[Category:ProtoFlux:Core]]
[[Category:Listener nodes]]

Latest revision as of 13:49, 28 January 2026

Field Hook
StartDrive
OnStartDrive
StopDrive
OnStopDrive
Target
OnHook
Source
IsDriving
HookedValue
Core

The Field Hook node takes in a target field and the source field value, then returns if this field is driving, as well as allowing the user to start and stop driving this field. This node gives the user more control to programmatically drive fields directly using ProtoFlux. This node hooks the given field, so whenever something external tries to write to it, it will receive a pulse from OnHook as well as the value it tried to write from HookedValue.

Manually unlinking the drive in an inspector behaves the same as triggering StopDrive.

Inputs

StartDrive (Call)

Calls an impulse to start driving the target (hooking into it).

StopDrive (Call)

Calls an impulse to stop driving the target (unhooking it).

Target (IField`1)

The target field to drive.

Source (Generic)

The source to drive Target from. While active this acts like any other drive.

Outputs

OnStartDrive (Continuation)

Fires when we started driving the target field.

OnStopDrive (Continuation)

Fires when we stopped driving the target field.

OnHook (Call)

Fires when something writes to the target field while it is being driven by this node.

IsDriving (bool)

Returns if the target field is being driven.

HookedValue (Generic)

Returns the value that was written by the OnHook call.


Examples

The example saves the current position of the cube on loading so it can will return to that spot 5 seconds after being moved.

It stores the inital position in a DataModel Store as well as triggering StartDrive. When the cube is moved, it uses the OnHook impulse to write HookedValue to a DataModel Store connected to Source, allowing the cube to behave like normal. And 5 seconds latter overwrites this with the initial position. When saving the cube, OnSave triggers StopDrive so to the cube is ready for next time.

Item: resrec:///U-1cLc1qmP4CG/R-fcdb06e2-dfb2-475c-9161-6c2169720704

Cube that returns to initial Position after 5 seconds.

A much more advanced set of practical examples can be found in by Baxer can be found in their MMC25 world "Swangin' Doors":

https://go.resonite.com/record/U-Baxter/R-f8cf3c37-d4bb-4d9d-a19b-227790c19af5