How to make a database of items to use with the same level blueprint script?

I am used to writing out my scripts. It’s the first time I am using kismet/blueprints, and it goes well, but there are still some holes. Most of the time I know what I want to do, but I just don’t know how to do it in visual scripting.

To give an example of my problem, I’ll write it out in code:



Init:

db_ButtonLights(Lightswitch01, Light01, Light02);
db_ButtonLights(Lightswitch02, Light03,_);

kb:

IF
CharacterUsedItem(_Character,_Switch)
and
db_ButtonLights(_Switch,_LightX,_LightY)
THEN
Activate(_LightX);
Activate(_LightY);

(Code is just written out quick, it’s not 100% correct, but it gives the idea)

In this instance the script recognizes which button is being pressed, and automatically checks which lights correspond with that button. I can add as many buttons and lights to the database as I want, the script will always be the same.
Right now I know how to use a button to activate a light. That is not the problem. The problem is that I am copy/pasting nodes in the level blueprint and adding the different lights to different buttons. So I have the same script repeated all over the place. I just know this can’t be the way it should be done, but I don’t know how to make that database kind of thing in blueprint.

Important to know is that the number of lights may vary, so making a class blueprint of one or more lights linked to a button doesn’t work, since the amount of lights won’t always be the same. Or can I make a class blueprint with, let’s say, 5 lights, and just delete some of the lights in the level when I don’t need all five? Would still feel like hacking the system, I guess…

Thanks in advance. If the question has already been posted, I am sorry. I did a search on the forum, on the wiki and on google, and it didn’t return anything. Maybe I’m using the wrong keywords, I don’t know.

Mod:

This is what I got right now … as you can see it’s basicly twice the same script, just with different variables. How can I combine them into one script, while still being flexible, keeping in mind the number of lights a switch toggles, may vary.

Hi, Image as attachments!!!

We are talking about simple point lights for now, ok?
You can place them all around your House, in different areas.
You place some Actors, Switch , in some room .

you can build a pretty complex blueprint to. identify wich switch you are closer , identify the room that switch is in , get all the lights in the room , set them all on , and off.
Know that you can do it , ok ? using the Get All actor of class, and placing some boxes and trigger to overlap them and find them by these boxes,
or use the distance to search them , or other milion of things.

BUT !!!
lets do it using some stored variables to make a “database”

Get your levvelblueprint and add a new variable, call her “Kitchen-Lights”, the type is pointlight / actor reference. and be carefull to make it an Array. , Now compile and save.
Now you can Edit this variable , Just click on the default_value and unreal will find the Pointlights in your level. set as many room you want with different lights.

In the image i set up a new Array , and make it empty,
I can call the EVENT with number 1, or 2, and it will set my room variable , to a specific combination of lights,
then i will call for every light in that combination and call a toggle light.
i hope is clear enough.

This is how use Arrays to list some kind of thing , and then , depending of your seelection , clone one off this array in a Operative array.
to make only 1 blueprint of instruction.