Download

New/Continue Game Text?

Hi,

I would like to save the players file name to one of my three continue slots, where after they enter their name it saves to slot 1, and if slot one is used it saves to slot 2,…etc. for slot 3.

Right now when they enter their account name it’s binded to Slot 1’s text. If another account was to be made, how could I have it bind to slot 2 instead?

Thanks for any help.

There is a node called “Does SaveGame Exist”. Name your slots something like “Slot1” “Slot2” “Slot3”.
If the player enters a new name, use a for loop from 1 to 3 and check with “Does SaveGame Exist” if the slot is already used.
Use the Index of the For loop, together with an “Append” node to do this “SlotIndex” which leads to “Slot1”, based on the current index.

If the SaveGameDoes not exist, save it and break the for loop. There are for loops with a “Break” input. If you call “Break” it will stop.

Thanks for your help! This’ll be incredibly useful.

Could you please help me out on setting up the BP? I tried to do it myself but gave up and decided to come back to you, sorry.

Here’s the mess I made so far:
748ac09424d6c92dbda3dab1245de60273f68ebd.png

I’m still stuck on this, could you please explain how to set up the blueprint? You’d be helping me so much…

Hey there, i can look at it tomorrow or so. A bit busy. Leave me a PM so i won’t forget.

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

Hey eXi,

thank you so much for taking the time to explain this to me, people like you are awesome. :slight_smile:

I finally got around to working on this. I think i’m very very close but I just had a question about that last part, I’m not sure how I should save the player name to the slot and display it on the button UI. Do I need to bind it or something?

Also, I checked what happens when I commit text to the newgame slot (In-Game) to see if this works, obviously I don’t have any text in the continue game slots yet, but interestingly when I checked the SaveGames folder of my Project files all three slots had a save file. I don’t think that’s a problem right? It’s just saving the empty slots as well? I just thought I’d let you know.

The first time you press it, it should only create Slot1. Make sure the “Break” is actually called, otherwise the For loop might iterate through the whole indices.

Other than that, i have no idea why it would create all 3 slots. As soon as the loop breaks or ends, it will only create the slot that is saved in “CurrentSlotName”.
Maybe something else is calling your function multiple times?

For displaying it: Create a function similar to the one i posted. Create a for loop from 1 to 3 and check again if the SaveGameExists (With Slot appended to the Index like
in the function above). If it exists, you load the save game, cast it to your custom savegame class and get the PlayerName that you saved earlier.
You can save this to an array or so and fill the Button Text with it.

Or you could bind the text variable to a function with “DoesSaveGameExist (Slot1)” etc and just load the PlayerName for each button text individually. If you don’t know how to work with
savegames, i recommend you to look that up :smiley: Would waste too much time explaining something that has Tutorials up on youtube.