Linking Entities

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Endaris
Prole
Posts: 12
Joined: Sun Oct 09, 2022 11:55 pm

Re: Linking Entities

Post 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.
User avatar
Bobble68
Party member
Posts: 162
Joined: Wed Nov 30, 2022 9:16 pm
Contact:

Re: Linking Entities

Post 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.
Dragon
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 5 guests