Here you go.
I have not tested it, but that’s the logic i had in mind. Every time you commit text in your TextBox, it will save the Submitted Name in a variable.
(I do this to hold things clean, so i don’t have tons of wires in my blueprints. Normally i would create a function for all of this and create local variables,
because i only need them for this part. But that’s up to you and something that doesn’t matter here.)
So back to the logic: After saving it, i set a boolean to false that i use to make sure that an empty slot was found. It will stay false if all 3 slots already exist (because then it will never be
set to true in the for loop). The i call a For Loop with Break from 1 to 3 to check 3 slots.
The Break Event is a Custom Event to also avoid long weird wires. You can’t do this in a function though, so in a
function you would need to have a long wire from the break call to this break input. In the Loop Body i create the slotnames by adding
the current index (1,2 or 3) to the word “Slot”. Saving it again, to reuse it later without long wires. Then i check if that SaveGame exists.
If not, then i found an empty savegame and set the boolean to true, also calling the break (here you would need the long wire from here to
the for loop input in a function, because CustomEvents can only be created in the EventGraph).
When calling “Break” or when all 3 iterations are through, the “Completed” exec will be called. Here i check if we found an empty slot.
If yes, i creat a new SaveGame object, cast it to my custom SaveGame class and again save it to a variable. Then i set the selfcreated “PlayerName”
variable of my test SaveGame Class to the one of the TextBox that we saved earlier and save the game to the slot that we saved during the loop iteration.
Don’t get confused by the Variable Name of the PlayerName. Forgot to rename it. If you want to display this as the Button text or something,
you just need to get Slot1 to Slot3 and get the PlayerName if the SaveGame exists. Then you can use it to display that name for the buttons in your UI.
If you have any more question, feel free to ask (:
http://puu.sh/lyxtH/48c3866ca4.png
http://puu.sh/lyxw7/4518b9e77f.png
http://puu.sh/lyxz3/aa446acff9.png