Page 2 of 2

Re: Linking Entities

Posted: Tue Sep 26, 2023 3:26 pm
by Endaris
It might have been better to provide this picture from the start.
From your description it was not possible for me to glean that you're trying to create a graphical level editor.

On your button, you could add a field for the ID of the target entity and a field for the function name. When the button is pressed, you can look up the target entity via the ID as suggested by pgimeno. And then you can simply call the function via entity[functionname](). Not elegant imo because there's no typo protection and such but should work and looks like the lowest effort solution if you don't want to build more UI for your level editor.

Re: Linking Entities

Posted: Wed Sep 27, 2023 3:45 pm
by Bobble68
Endaris wrote: Tue Sep 26, 2023 3:26 pm It might have been better to provide this picture from the start.
From your description it was not possible for me to glean that you're trying to create a graphical level editor.

On your button, you could add a field for the ID of the target entity and a field for the function name. When the button is pressed, you can look up the target entity via the ID as suggested by pgimeno. And then you can simply call the function via entity[functionname](). Not elegant imo because there's no typo protection and such but should work and looks like the lowest effort solution if you don't want to build more UI for your level editor.
Ah appologies, I didn't realise I didn't mention that.

I have managed to get it working, using a slightly modified version of what's been suggested - I've given all the entities a name attribute, which when changed automatically updated on an index table, so the table only contains objects which are named. Names were already a part of specific types of entities which had unique behaviours, so it made sense to reuse them. The system I've currently got also allows for entities to have the same name, so that you can do an action on all entities with the same name.