"Save My Game!" 💾 Data Serialization & Escaping in Scratch

327,231
0
Published 2023-02-25
Learn how to safely convert (serialize) your variables into a basic save code in this Scratch coding tutorial. We'll learn about simple CSV's (comma separated value), and implement a robust character escaping system to avoid conflicts and guarantee what goes in, is what comes out! We'll create two custom blocks, "Write Value", and "Read Value".

This episode will be followed up by a second episode that will also be part of the RPG series, and we'll expand on save codes showing how to make them modular, and backwards compatible.

My tutorials are for all budding game & software developers using Code Blocks. Scratch On guys!

🚀 Boost Your Creativity with Griffpatch
The Griffpatch Academy will take you from "Gamer to Game Creator"
Learn more at 👉 griffpatch.academy/ 👈

😺 Scratch was developed by the Lifelong Kindergarten Group at the MIT Media Lab. See scratch.mit.edu/

👀 Quick and Fun Tutorials
   • Quick and Fun Scratch Tutorials  

👀 Episodes in the series:
Ep.1 - Craft your dream Scratch Game -    • RPG Tutorial | Craft your dream Scrat...  
Ep.2 - Infinite Scrolling & Tiles -    • 🐱 Infinite Scrolling & Tiles - Scratc...  
Ep.3 - I AM SPEED -    • ⚠️ LAG FREE Scrolling in Scratch 🐱 RP...  
Ep.4 - Build a LEVEL EDITOR in Scratch -    • Code a LEVEL EDITOR in Scratch | RPG ...  
Ep.5 - Split Screen & Multi Tile Assets -    • EDIT FASTER ⚡ Tile Tracing | Scratch ...  
Ep.6 - Layers & Onion Skinning -    • LAYERS 🧅 "Onion Skinning" in Scratch ...  
Ep.7 - Collisions Pins -    • Collision Pins? 💥📌 Now that's clever!...  
Ep.8 - Player Collisions -    • Player Collisions + Wacky hitboxes! 🐱...  
Ep.9 - Animate the World -    • How to Animate Game Worlds in Scratch...  
Ep.10a - Data Serialization -    • "Save My Game!" 💾 Data Serializatio…
Ep.10b - Modular Scene Saving -    • Unlock the Power of Modular Scene Sav...  

❤️ Scratch Addons - scratchaddons.com/

-------------Video Chapters-------------
0:00 Intro
1:10 Comma Separated Values & Delimiters – CSV & DSV
2:22 Basic Write Value Custom Block
3:55 Basic Read Value Custom Block
6:30 Index out of bounds error and Optimisations
8:16 Write with Escaping
11:20 Read with Escaping
12:28 One last issue!
13:51 Summary
15:49

All Comments (21)
  • @ChraphtMyne
    I hope this comment can get to you. I played your paper Minecraft when I had no money to buy the official Minecraft, which was from 2015(11 yo) to 2021(17 yo). It was a good portion of my childhood, which also got me interested in scratch(2017, 13yo), which later made me interested in programming languages(2018, 14 yo). Now I'm 20 yo, trying to make a game like Terraria on Unity game engine. I was stuck at world generation and and world saving, AND I RECALLED YOUR GAME. At first I thought I would have to break down your scratch game on my own. Then I saw your videos towards paper Minecraft. With this video and your Procedural World Generation video, you actually helped me a lot on my unity project. Education sessions with such advanced techniques you taught us in your videos are usually paid courses on the internet, but you just...what the heck man, you mean so much to me. You are the one who inspired me towards programming, and now you are helping me again, I don't know how to thank you.
  • @gman8398
    I honestly think that the best part about griffpatches tutorials is the fact that he is so skilled at the language that every tutorial he makes the more advanced scratch games can be for everyone else, keep up the good work man!
  • @Blockitjames
    nice to see you are using methods from text programming languages such as escape characters into scratch! It also helps people know alot about text programming when they end up getting into it! Great work Griffpatch as always!
  • @NotDIY
    although im not new to scratch, griff is making me learn things I struggled with in the past, just in a simpler manner, Thanks Griff!
  • @oxintoma32dev
    10:51 Fixed! we just forgot to add a "change variable (save idx) by 1" in the repeat loop. thats why it just adds only the first letter of each value in the save code also thank you so much,that helped alot! :D
  • @N_jsd
    I’m glad you’re finally making a tutorial on how to do this so it’s more accessible! I did this a while back with your encoding and decoding system from the cloud tutorials, and have the game read the numbers to give you your values back. Though I didn’t use any delimiters so it could get a bit confusing with all of the values in my game.
  • This is actually pretty easy, thank you griffpatch!! I am currently catching up with your awesome raycaster, added to it a world generation thanks to your maze generation with some tweaks, this here will make a great addition!
  • @YessoN-YT
    Before this video I had made a fairly similar system on turbowarp (with the "files" extension) but with lots of lists and which didn't work sometimes... And here I see a video that can help me! Thank you griffpatch :)
  • @startFX
    YES FINALLY, I've been trying to make one for ages, especially for my custom scene editor for the firework particle project, and you there a tutoprial ! Thank you so much griffpatch !
  • @BobChess
    Finally! We can do RPG in scratch!! I can't wait to see the new episode of it!!!
  • I needed exactly this to save people scores and levels in my new game! Thanks so much Griffpatch!
  • This sort of data management has always been what I'm best at programming! This video has given my new perspective on my approach, too, which is appreciated! Great video, as per usual.
  • @tommax1626
    This is really funny, i just thought about this exact matter in order to make my scratch game especially with encryption! Thank you Griffpatch!
  • Yay! I love it when griffpatch uploads. He makes everything simple and enjoyable :)
  • Honestly man how do you make every Scratch tutorial sound so easy? Keep up the awesome work.
  • @supranova1
    Been wondering how to do this for a while, amazing work as always. I was just thinking about data saving when I saw this video posted just 1 hour ago!
  • @aringelblade
    Finally saving my progress I thought it wasn't possible but griffpatch did it congratulations :)
  • This reminds me of string variables I learned about in computer class. Epic 😎 Also that contains block trick is amazing! I wonder what else it can be used for?
  • I cannot tell you how much you make my life easier with what you make, whenever I try to code smt new I always see if you already have a tutorial on it or not, and you always do :D
  • Oh man I think we have all been waiting for a cool tutorial like this! 🔥