Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference between 'LiteGraph.ON_EVENT' and 'LiteGraph.ON_TRIGGER' #485

Open
LeMoussel opened this issue Jun 13, 2024 · 1 comment
Open

Comments

@LeMoussel
Copy link

LeMoussel commented Jun 13, 2024

I don't really understand the difference between LiteGraph.ON_EVENT and LiteGraph.ON_TRIGGER.

For each link linked to the node

  • If the node mode is LiteGraph.ON_TRIGGER when the trigger fires, does it call on_execute() of linked nodes?
  • When the node mode is LiteGraph.ON_EVENT does this call on_action() of linked nodes?

In the documentation it is stated
To define slots for nodes you must use the type LiteGraph.ACTION for inputs, and LIteGraph.EVENT for outputs:

function MyNode()
{
  this.addInput("play", LiteGraph.ACTION );
  this.addInput("onFinish", LiteGraph.EVENT );
}

isn't there an error with this.addInput("onFinish", LiteGraph.EVENT )?
It should not be this.addOutput("onFinish", LiteGraph.EVENT );?

Can you explain and provide some examples?
For example how to use with the Console node - Console.prototype.onAction?

@atlasan
Copy link
Contributor

atlasan commented Jun 18, 2024

Not having yet the time to reprocess the whole and make a good doc about, but essentially:
The basic is that nodes executes and produce outputs with their own code placed usually in onExecute.
LiteGraph.ACTION and LiteGraph.EVENT actually have the same values, and both represent an "action/event" slot type. The distinction is just to help understanding when it comes in or comes out.
onAction is called when an input slot of type "action/event" is triggered, that happens when a link connected to it fires the event. That is parallel to default node execution. Node execution happens every frame and calls onExecute on every (normal) node. Different node modes will generally allow to prevent the normal execution (onExecute) and leave it to be coded internally.
On trigger is a mode that has been created later on, that executes the node only when a specific "action" name "onTrigger" is triggered. That would be similar to other event-based visual coding system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants