add_named_entity_listener - ryzom/ryzomcore GitHub Wiki
title: Add Named Entity Listener description: published: true date: 2023-03-12T16:42:17.153Z tags: editor: markdown dateCreated: 2023-03-12T16:42:13.941Z
The addNamedEntityListener native AI script function associates a listener with a named entity property. Whenever that field changes, the specified user event is triggered or a script function is called. Valid property names are:
- state
- param1
- param2
Name of the entity cannot be listened, because it cannot change. Several listeners (even with the same parameters) can be associated to each property.
()addNamedEntityListener(name: s, prop: s, event: f) // addNamedEntityListener_ssf_
()addNamedEntityListener(name: s, prop: s, cbFunc: s) // addNamedEntityListener_sss_
- name (string): The name of the named entity to listen to.
- prop (string): The property of the named entity to listen to.
- event (float): The user event to trigger when the named entity property changes.
- cbFunc (string): The name of the script function to call when the named entity property changes.
()addNamedEntityListener("Invasion", "state", 6);
This example code associates a listener with the named entity "Invasion" and the property "state". Whenever the "state" property of the "Invasion" named entity changes, user event 6 will be triggered.
()addNamedEntityListener("Invasion", "state", "onStateChange");
This example code associates a listener with the named entity "Invasion" and the property "state". Whenever the "state" property of the "Invasion" named entity changes, the script function "onStateChange" will be called.