"Save My Game!" 💾 Data Serialization & Escaping in Scratch
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!
🔥 Early Access / Channel membership
/ @griffpatch
👀 Quick and Fun Tutorials
• Quick and Fun Scratch ...
👀 Episodes in the series:
Ep.1 - Craft your dream Scratch Game - • RPG Tutorial | Craft y...
Ep.2 - Infinite Scrolling & Tiles - • 🐱 Infinite Scrolling &...
Ep.3 - I AM SPEED - • ⚠️ LAG FREE Scrolling ...
Ep.4 - Build a LEVEL EDITOR in Scratch - • Code a LEVEL EDITOR in...
Ep.5 - Split Screen & Multi Tile Assets - • EDIT FASTER ⚡ Tile Tra...
Ep.6 - Layers & Onion Skinning - • LAYERS 🧅 "Onion Skinni...
Ep.7 - Collisions Pins - • Collision Pins? 💥📌 Now...
Ep.8 - Player Collisions - • Player Collisions + Wa...
Ep.9 - Animate the World - • How to Animate Game Wo...
Ep.10a - Data Serialization - • "Save My Game!" 💾 Data...
Ep.10b - Modular Scene Saving - • Unlock the Power of Mo...
❤️ 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 Outro
Пікірлер: 1 300
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.
@Millie_oo0
2 ай бұрын
Thats really nice i have to say! Good luck on your programming journey’s future!
@Quest-vg3xn
2 ай бұрын
i totally agree
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!
@gymcu7019
Жыл бұрын
|
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!
@griffpatch
Жыл бұрын
Yes, that was the plan
@Mr_green650
Жыл бұрын
@@griffpatch Maybe you can encrypt the code and decrypt the code to stop the player from cheating in the game
@vii-ka
Жыл бұрын
@@Mr_green650 The problem with that is the player can see inside and encrypt any value they want.
@Mr_green650
Жыл бұрын
That’s true but if we make it really hard to read or edit than it should be possible
@vii-ka
Жыл бұрын
@@Mr_green650 so basically make spaghetti code so bad worse then Papyrus's spaghetti that it scares away the cheaters?
Finally! We can do RPG in scratch!! I can't wait to see the new episode of it!!!
@pcc404
Жыл бұрын
me too!
@DUMB_PERSON_NEAR_ME
Жыл бұрын
I know how to do that
@HTS-wb4gg
Жыл бұрын
@@DUMB_PERSON_NEAR_ME 1 minute ago, I guess people uhh
@syesjohnny4119
Жыл бұрын
@@DUMB_PERSON_NEAR_ME yeah
@bobhim-mq4vt
Жыл бұрын
YA!
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.
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
@iheirhR8237
Жыл бұрын
Isaiah Wakakai goat thus felling that I use a notary to claim don't go that gagger abby wasabi
@myithspa25
9 ай бұрын
@@iheirhR8237what
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!
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!
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 !
@griffpatch
Жыл бұрын
My pleasure
@adamsophian2335
Жыл бұрын
@Creeper Download tutorial as tutorial?
This is really funny, i just thought about this exact matter in order to make my scratch game especially with encryption! Thank you Griffpatch!
@Its.a.me.wavey_
Жыл бұрын
HOL UP THIS VIDEO WAS UPLOADED 14 MIN AGO AND YOU REPLIED 17 HOURS AGO
@Blockitjames
Жыл бұрын
@@Its.a.me.wavey_ he has a membership so he got the video early
@arodandtamarazalioukamir3869
Жыл бұрын
HOW DOS IT SAY THAT U COMMANT 19 HOURS AGO AND THIS VIDEO IS ONLY 1 HOUR AGO?
@pndaMobby
Жыл бұрын
@@arodandtamarazalioukamir3869 membership gets videos early
@gamerseeker2697
Жыл бұрын
You can buy a Griffpatch membership, so you can get videos early!
Honestly man how do you make every Scratch tutorial sound so easy? Keep up the awesome work.
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.
Finally saving my progress I thought it wasn't possible but griffpatch did it congratulations :)
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 :)
@griffpatch
Жыл бұрын
No problem
I needed exactly this to save people scores and levels in my new game! Thanks so much Griffpatch!
@griffpatch
Жыл бұрын
My pleasure
@Femtobot314
Жыл бұрын
HOw did griff reply
@kales901
Жыл бұрын
@@Femtobot314 by pressing the "reply" button
@Picotech1
Жыл бұрын
@@kales901 WoW
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
Yay! I love it when griffpatch uploads. He makes everything simple and enjoyable :)
@Kweable_Gaming
Жыл бұрын
So true
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!
@griffpatch
Жыл бұрын
Good timing!
@iheirhR8237
Жыл бұрын
@@griffpatch Isaiah Wakakai goat thus felling that I use a notary to claim don't go that gagger abby wasabi
I did raycasting and took a break. Now I’m back and I’m ready for more. Good work as always Griffpatch.
Oh man I think we have all been waiting for a cool tutorial like this! 🔥
I like how complex things became simple in your tutorials :)
@griffpatch
Жыл бұрын
I do try :D
@FeniteFr
Жыл бұрын
@@griffpatch And you succed !!
@HurelyDev
Жыл бұрын
@@griffpatch how would you save and load a list
@um_idkw
Жыл бұрын
He could explain how to make an entire computer (cpu, gpu, custom machine language , custom asm, compiled lang, input system, ect) in scratch and it would be simple.
@apbmatticus6121
Жыл бұрын
@@um_idkw so true!
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?
Fixed it! I also want to say thanks for uploading such awesome videos i had always wanted to know how to make good scratch games and then a friend told me about you and your channel, and I'm sure many others feel the same way. Keep up the great work and have an amazing day!
i knowed how you did that game save system, but i never tried to replicate because i thought it would be realy hard to do, watching you to optmize your code and do it as simple as possible while still working fine is just insane, and i love it
I have moved on to Unity but you’re content inspired me to take a step backwards and load up scratch! Great job with you’re videos btw!
@PabTSM-OfficialChannel
Жыл бұрын
griffpatch is content? wow didn’t know
@mikk.t.7824
4 ай бұрын
@@PabTSM-OfficialChannelRude meanie
@PabTSM-OfficialChannel
4 ай бұрын
i was being ironic, @@mikk.t.7824
Another good upload by griffpatch; thank you for saving us!
@griffpatch
Жыл бұрын
No pun intended
Griffpatch, i love your editing in your videos. for example at 4:38 the game screen shifts away smoothly to the right, i love your tutorials they always help me!! Hope you have a good summer.
Thanks for the awesome tutorial, i'm currently using it for my animation program
Yes! I've been experimenting with save codes, but I can't get them to 100% work each time. This will definitely help!
@griffpatch
Жыл бұрын
Great to hear!
Suggestion: If you put this in a game, the player could give a value like 999|999|999 and max out his/her character. Maybe you can make it so it is slightly harder to decode?
@two2fiv67
Жыл бұрын
If you multiply by any number when encoding and divide it by the same number when decoding, it will be much harder to decipher what values are what, alternatively you could turn letters into numbers and numbers into letters (a=1, b=2, etc. or shift every number by a value, 1=4, 2=5, etc.)
@Gravitraxbro
Жыл бұрын
@@two2fiv67 I'm going to do both :)
@two2fiv67
Жыл бұрын
You could use a random number to multiply the values in the save by and put the random number in the save code, then when decoding use the random number, [Ideally first or last in the code] and divide by the number to make it harder.
@lime_is_crime6407
Жыл бұрын
or make it a cloud username detection so that way he or she can't interact with the save code or system.
@FAUXCUSpd
Жыл бұрын
@@two2fiv67 this is a good idea
ive heard of csv's before, but i didnt know that scratch can use them to save data amazing vid as always :)
Holy moly! How on earth do you always manage to make videos on exactly what i was having problems with?!!?? I was wondering how i would save a list with all the tiles for a level. This is ultra-perfect!
@codingclub256
Жыл бұрын
Me Too!!!
When griffpatch uploads new video, we know that it will gonna be great!
@jorgenandersson1964
Жыл бұрын
Agree! =D
@Kweable_Gaming
Жыл бұрын
So True
A very tiny optimisation: The last letter in this text is always ‹|›. This marks the end of the last value. However, ‹› would also work, so you can remove ‹|›. If only there was an (all but last of [text]) block for this!
@ego-lay_atman-bay
Жыл бұрын
You check if the save code is "" before saving the value, and if it's not, add "|" to it, then add the value.
Finally!! I always wanted to know how to do this!! Thanks so much griffpatch!!
thank you so much! this was very helpful and now i can make a game i have been wanting to make for quite a while!
my school blocked scratch because people kept playing games on it
@ChrisYay-oi3of
5 ай бұрын
Luckily my school district teaches little kids scratch so I'm fine
@doggorgg
5 ай бұрын
@@ChrisYay-oi3oflol same
@beta_692
5 ай бұрын
You can try translating the link into english and then clicking on the link it works but stuff gets laggy most times
@crovat5218
5 ай бұрын
@@foxneko4465pretty much, yes
@mattiskardell
4 ай бұрын
@@doggorggi made my school teaches scratch
I've been thinking of how to save my raycaster for weeks, VERY HELPFULL.
love your uploads, keep up the great work! gwiffyyyy!!!!
was going to develop a scratch port of one of my favorite games and realized save codes were gonna be a large issue. turns out this video came out at a convenient time for me, and even better, actually explains it really well! now i just need to figure out how to encrypt and decrypt it
@Dash22212
10 күн бұрын
did you finish it?
This is going to help me so much in future projects. Can't wait for it to be true!
thank you griffpatch! I already know how to do this (sort of) but i had to save variables separately to lists, and the lists where either uncompressed or slightly compressed, but still with at least 8,000 characters! This could save many gigabytes of storage for people who play my games!
I like how this is not only useful in Scratch but for other game engines as well!
Thank you so so much. I am pretty new to scratch and coding, and this helped tons and it made sense! Thanks again!
YES! I have needed this for a while now!
Thank you for the tutorial! I used this code to make a text engine where it prints the next letter in the sequence :D
That was what i always seekd for thank you so much griffpatch!!
fixed it! (kind of suprised but i noticed that pattern) Thanks for all the helpful tutorials!
Omg it has done 3 years since I wanted to find a save code tutorial and btw I fixed it lol. Food job man!
@Willbin23
Жыл бұрын
Good*
I tried to do cloud saving system in my Scratch game, but it didn't work. Now I can make saving system without using cloud variables! Love your content!
This is a perfect tutorial for beginners to learn more about scratch. Griffpatch as always!
yay episode than comes out soon great work as always griffpatch
Thank you SO MUCH! I was just thinking of adding this to my game! :P
You make my day with your uploads
I was making a tringle drawer, and I needed script to read list, which has x1,y1,x2,y2,x3,y3,color. THANK YOU!!!
Thanks for teaching me the "save my game" code, I really appreciate it.
I love your videos!! I've been watching ever since your Scrolling Platformer tutorial you did back in 2018-19!!
@griffpatch
Жыл бұрын
Wow!!! So cool - thanks for watching!!!
@zzcole.
Жыл бұрын
@@griffpatch These are good and high in production value! I also love the sense of humor
Day 4 of asking for moving platforms in the tile scrolling platformer series. I don’t expect to see this or make a video on this but I love your channel so much! You deserve 1 mill!
Thanks for making this video it was looking for one yesterday
Fixed it! this is super good and now we can actually save our games! :DD
Yessssssssss! Finally a tutorial for save you progress!!
i needed this, thank you sooo much
You could not have timed this better, this will be perfect for unpacking 3D models using my own encoding system
Thank you GRIFFPATCH! I can asave my RPG despite a few problems, and it works!
We needed that thanks griffpatch
I just love how Griffpatch always has an upbeat mood in his videos :-)
@PeterbroMC
7 ай бұрын
Bro's an human AI
@varganyamuvek
7 ай бұрын
@@PeterbroMC xD
Wow, just what I needed, thanks griffpatch!
This tutorial worked very well!
Fixed it! that's the type of mistake I make when I have been coding for hours on end. and when I can't fix it I have a mental breakdown only to come back the next day and realize my silly mistake.
Griffpatch i just wanted to say this is kinda creepy but also good at the same time. Not you or your game creepy but I was searching up how to make a save code or save games and couldn't find anything until I saw this. Literally the timing is weird. You could make any video and it was a video I needed. This was very helpful and thank you.
Funny thing I was already doing something similar for my own project since there's no "Split" block in Scratch like there is in JavaScript. This video made this tactic more public. Cool!
Grate video Griff it absolutely help me so much I shall use this is my games thank you
yes!!!!!!!! i have been waiting for this tutorial for so long
@griffpatch
Жыл бұрын
Awesome!
WOOO! A new griffpatch video :) Fixed it! Didn't actually need to pause the video lol. Now applaud me >:)
I made my scratch game with this tutorial thx for it ❤
Wow, this is incredible!
Nice I've been waiting for this Your the best scratcher
Without using any tutorials I created a save code system for a clicker game I made, and I'm gonna be honest, you did it better than me/
It's not the way I create save codes, and text escaping, but it's simple and it works. The ways I do it is probably more complicated, as I loop through it using a repeat until letter > length of text.
Always here for a griffpatch video!
griffpatch it really helped my a lot! thank you so much!
ngl when I first saw this video I thought it wasn't griffpatch bc of the different thumbnail style. Can't wait for The new RPG Episode!😁
I've already made a way to make save codes, but I'm still watching this!
I have been trying to do saving in one of my games thanks!
OMG! IM BEEN WAITING FOR THIS, THANK YOU SO MUCH GRIFFPATCH.
@griffpatch
Жыл бұрын
You bet!
@xRoxxanne
Жыл бұрын
@@griffpatch I can't believe you answered! THIS IS A DREAMMMMM :DDDDDD
@xRoxxanne
Жыл бұрын
Thanks, Griffpatch. Looking forward for the next amazing RPG tutorial episode!
i knew about this already, but nice tutorial edit: yours is slightly better because you have pipes in between, i just coded mine to read for a certain number of characters
When it was Friday I talked to my friend about him playing a scratch game, then I said ‘I really hope you can save games in scratch’ and 2 days later there it was,a video about saving games Thank you,griffpatch😊 (Try to hit 300k subs by the end of 2023)
Thank you griff patch that you made this now I can figure out how to save my game
This is the FIRST TIME since I starter following you that I’m 10+ hours late to one of your videos 😮 (It’s my birthday 🎉)
@griffpatch
Жыл бұрын
Happy birthday!
The saving system I've settled on and standardised across all my projects is one that uses key-value pairs instead. I don't bother with escape characters because my data realistically will always have unused characters (and unicode is an alternative too). So, my saves end up looking like... key1:value1,key2:value2,key3:value3,. For loading I dump everything into a list first. Then to get a certain value, look for the key and the value will be the item immediately after it. I use the (item # of [] in list) block to keep it simple. This system is so flexible because the order of the key-value pairs do not matter. Backwards compatability is easy.
Hay, Griffpatch, you are the only reason I'm allowed to use my account in school, thank you for everything you've taught me since 30th July, last year.
@griffpatch
Жыл бұрын
Awesome!
@codingclub256
Жыл бұрын
youve taught me since i was a kid
52 minutes ago! AHHH! Thank you for making this video, Griffpatch!
I can't wait for the next rpg episode!
Wow! For the save and load system I made. It used commas because it was encoded first. It can save lists and variables!
@griffpatch
Жыл бұрын
That's very good. There are so many ways to go about this.
Amounts of notifications Griffpatch got: *ABSOLUTE INFINITY AND BEYOND*
Fixed it! Just needed to change save index by one!
This guy is god of scratch. He knows everything. He will be able to do 60 players fall guys in 2d. Edit: You should make tutorial how to make level editor and how to save it
my favorite thing to watch all day
FINALLY!!!! JESUS CHRIST IVE BEEN WAITING FOR THIS FOR 2 YEARS NOW
@justinsketchesNG626
Жыл бұрын
You should do an RPG turn-base battle with stats plus exp! Like Earthbound
This is garunteed to be an interesting and useful watch!!! I Appreciate the vids griffpatch :)
@griffpatch
Жыл бұрын
No problem, enjoy