How to save/load more booleans of the same name?

Hi guys, here is something to give you some kind of idea of what I have.

I have Character Blueprint called : "Master_NPC"

The “Master_NPC” have 3 booleans called:

"HasQuest?" “QuestIsCompleted?” "CompletedQuest"

Child classes of “Master_NPC” called “NPC_Test” , “NPC_Test2” and “NPC_Test3” have those booleans setup but every Child class have different Value or whatever it is called. (True/False)

My question is how to save/load all of them together so the Value is as it should be? Should i use Boolean Array in “SaveGame” blueprint to save them? I have saving system for other things but I am really stuck here and I do not know how to do it.

Depends how scalable you want the method to be. For 3 actors you could just get reference to each and from the save/ load game mechanism grab each one from a hard coded array and set the values. If you want it more scalable I would create an integer variable in the parent class and use this as an identifier for each child, so you would increment that integer for each child you create. Then have a function in like the game instance that gets all actors of class, loops through looking for the specific integer variable. Now you have a method for identifying each child in an array. Then from the Boolean variables when you save them you would need to have a separate function that loops through the actors and saves the Boolean variables to the specific slot of the actor index value. So child 1 has index 0, in your save function you would set the array index to equal the actors integer variable and save the Boolean data to that slot this way the child integer index and the location of it’s corresponding Boolean data is the same. When you load you get the Boolean data at the child integer variable index and set it. I know that’s prob confusing as hell but it’s the best I could do from my phone. Basically you’re gonna make 2 arrays and loop through each setting the actor Boolean data. The trick is getting the indexes to match.

Wow that really is confusing man. I will try it tomorrow. I got another question for you if it not bothers you. Every NPC got its own ID (Integer), could that ID help me for this save system that you mentoined?

Hmmm I do not know where did you got the boolean array because every boolean that I have is normal bool not an array.

I know what array means and how to create them i just did not understood that i need to create one that is null. So if I am correct after that loop i will get my array bool and set array element with the index of Npc ID (Integer) and item will be that bool that I want to store?

Yea, that is basically what you need. Some integer ID to identify the different copies. So basically this is what I was trying to say. Probably have this in the game instance or other high level BP

  1. When you save, “get all actors of class” (creates NPC array)
  2. Call a function that runs a “for each loop” on this array
  3. Have the loop body pull each element out and get the “boolean data” as well as the “integer” identifying the specific copy (ID in your case)
  4. With these 2 pieces of data available the next thing the loop body should do is create an array of boolean data by using the “add” node to add the boolean data to an empty array
  5. Take the array element boolean data from step 3 and use a “set array element” and set it to the integer value from step 3. (This will order the boolean array data to match the NPC integer ID index, so NPC 0 will have it’s boolean data stored at index 0 in the boolean array)
  6. Now when you “load” the data you will again “get all actors of class” to pull all NPCs into an array
  7. Call a function to use a “for each loop” on this array of NPCs with the loop body set up to pull out a specific NPC copy, then pull out its “integer ID” and plug that into a “Get” node of the boolean array. This will pull out of the boolean array the same index as the NPCs integer ID, which if the previous steps were done properly should be the initial boolean data saved for that NPC
  8. You can now set the newly instanced NPCs boolean data to the data stored in the boolean array.

You just need to create a variable that is a boolean and next to it the little red bar if you click it, you have options to make it an “array”. You just create this empty array in the details panel and you will add data to it with these functions. Or you can just drag off one of your boolean variables and search for “make array” then promote that output array to a variable, then delete everything. Same difference. You just need a boolean array as a variable in the details panel to store the data you feed to it later.

Something like this is what I mean. “Special Array” is an empty array that gets filled.

I do not know if I done it correctly so I am posting it here if you want to have a look at it but I still do not know that when I am loading them how to pull out a specific copy of an NPC?

Try something like this. Make sure to fill both boolean arrays with as many elements as you have so there is something to “set” during the loop.

.

Glad I could help! Good luck with your game.

Man it is Working!!! Thanks really. Now I just have to tweak it for myself a little but really thank you.