How to send event to specific object?

Ive started to do some simple game using only logic nodes (as Im not familiar yet with haxe scripting).
Im curious how to execute logic nodes tree on specific object (if I have few of of them with the same Armory trait).
When I send global event then I run code on all of them. Maybe we need kind of “Send event” node with additional “Object” slote - to point the only one exact object.
Or maybe there is anoter way to achieve this?..

Maybe you can use “Get-” and “Set Property” nodes with a boolean (in the Value input) as a replacement for the event, and the properties’ object being the object you want to do stuff. “Set Property” would then be used as “Send Event” and “Get Property” (with the object being “Self”) as “On Event”.

Something like that?

Think so, but maybe this doesn’t works because Cube.004 asks for the value for a property that may not exist yet, and if it does not exist I think the preview will crash. Maybe you have to place a “Set Property” node with the bool being set to false and that is activated by “On Init”, and if even this crashes you will have to put a sleep node after “On Update” in Cube.004. Not sure tho, can’t test right now.
If it crashes, which it may not, so it should probably work.

Thanks a lot for your answer! I will check it.
Anyway if I will not find it comfortable I will propose node modification on Github issues. Just this:


1 Like

Maybe if can help you :
if you define a name for your event and then associate the according On Event to your object,
that can play.


@ Didier
Yes, thats how it works in simple situation (inside one trait, or when you use global event that is sended to all traits which have “On Event” with “Toto”), its clear.

I was just wondering how to reuse the same trait on few objects, but run code only on selected one in specific moment.
So to have this posibility:

One Armory trait with bunch of functions (node trees) inside. Every function is started by On Event node, with single name.

I put for example 10 objects with this trait.

Than from any node tree in game I want to start one event for only one of this 10 objects.

I remember doing a test on a solution that might come close… if I remember well, it was by first coding the event name with the “event name-the object name” for which it is intended …

Finally, after some tries I coded Send Event To Object Node (tweaked regular Send Event Node).
I dont know if its ideal but it works for me :smiley:
So if someone needs there is haxe file for this node
SendEventToObjectNode.hx (569 Bytes)

and code to construct node sockets for is:

from bpy.types import Node
from arm.logicnode.arm_nodes import *
import arm.nodes_logic

class SendEventToObjectNode(Node, ArmLogicTreeNode):
    '''Test node'''
    bl_idname = 'LNSendEventToObjectNode'
    bl_label = 'Send Event To Object'
    bl_icon = 'GAME'

    def init(self, context):'ArmNodeSocketAction', 'In')'ArmNodeSocketObject', 'Object')'NodeSocketString', 'Event')'ArmNodeSocketAction', 'Out')

def register():
    # Add custom nodes
    add_node(SendEventToObjectNode, category='Action')
    # Register newly added nodes

The rest information - where to put this things are in "dev_logicnode’ example on github

1 Like

Just slowly going through the older posts to try and understand more about the node system.

With the screenshot you have here. They are not connected but they have the same name in the fields. I’m just trying to understand why?

Are you saying that the node ‘Send Event’ and ‘One Event’ will be associated with ‘Toto’?

This ‘Toto’ Even. What would you have it do?

Sorry if this question seems logical to others but its not logical to me. Even once I finish reading the full post.

@Eladd For the understanding, the discussion was about how to simply address only one among objects that have the same trait. It’s s an old post and now actual nodes allow it and it exists several ways to do it as already discussed here.
Then for your question, events allow you to send event to listeners to events ( you send event toto, and the On event with toto in it will send an out)

The send event node sends an “invisible” ( if that makes sense ) event that can will trigger the “Out” of any On Event node that has the same name in its textbox. That event can be picked up by any object in the scene and by any On Event node in the game. I doesn’t have a logic node wire connecting the Send Event node to the On Event node. That is actually why use use event nodes: so you don’t have to connect them.