How to create save/load systems with list data in Scratch
💾 Need help with data persistence or save systems in your projects? 🚀 Get Help Now
SaveSystem_Expert
Posted on July 24, 2025 • Advanced
💾 Need help with save/load system for lists!
Hey everyone! I’m working on a complex RPG project that needs to save and load multiple types of data:
- 📊 Player inventory (lists of items)
- 🎯 Quest progress and completion status
- 🏆 Achievement unlocks and statistics
- 🗺️ Map exploration data
- ⚙️ Game settings and preferences
I found a basic save/load tutorial, but it only handles simple variables. How can I modify it to save and restore entire lists? I need a system that can handle complex data structures reliably! 🤔
DataStorage_Pro
Replied 8 hours later • ⭐ Best Answer
Perfect question @SaveSystem_Expert! Saving lists requires encoding them into a single string format. Let me show you the complete system:
🔧 Understanding List Encoding
The key is converting your list data into a string format that can be saved, then decoding it back when loading:
💾 Complete Save System
Here’s a robust system that can save multiple lists and variables:
// Master save function define save game data set [save code v] to [] // Save player stats set [save code v] to (join (save code) (join [STATS:] (join (player level) (join [,] (join (player health) (join [,] (player experience))))))) set [save code v] to (join (save code) [|]) // Save inventory list set [save code v] to (join (save code) [INVENTORY:]) encode list [inventory v] with separator [,] set [save code v] to (join (save code) (encoded result)) set [save code v] to (join (save code) [|]) // Save quest progress set [save code v] to (join (save code) [QUESTS:]) encode list [quest progress v] with separator [,] set [save code v] to (join (save code) (encoded result)) set [save code v] to (join (save code) [|]) // Display save code to user say (save code) for (10) seconds ask [Copy this save code and keep it safe!] and wait
// List encoding function define encode list (list name) with separator (separator) set [encoded result v] to [] set [list index v] to [1] repeat (length of (list name)) if <(list index) = [1]> then set [encoded result v] to (item (list index) of (list name)) else set [encoded result v] to (join (encoded result) (join (separator) (item (list index) of (list name)))) end change [list index v] by (1) end
📖 Complete Load System
The corresponding load system that decodes everything back:
// Master load function define load game data ask [Enter your save code:] and wait set [save code v] to (answer) set [decode position v] to [1] // Parse each section repeat until <(decode position) > (length of (save code))> extract next section if <(section type) = [STATS]> then decode stats data end if <(section type) = [INVENTORY]> then decode list data to [inventory v] end if <(section type) = [QUESTS]> then decode list data to [quest progress v] end end say [Game loaded successfully!] for (3) seconds
// Section extraction function define extract next section set [section data v] to [] set [section type v] to [] set [reading type v] to [true] repeat until <<(letter (decode position) of (save code)) = [|]> or <(decode position) > (length of (save code))>> set [current char v] to (letter (decode position) of (save code)) if <(reading type) = [true]> then if <(current char) = [:]> then set [reading type v] to [false] else set [section type v] to (join (section type) (current char)) end else set [section data v] to (join (section data) (current char)) end change [decode position v] by (1) end change [decode position v] by (1) // Skip the | separator
// List decoding function define decode list data to (target list) delete all of (target list) set [current item v] to [] set [char index v] to [1] repeat (length of (section data)) set [char v] to (letter (char index) of (section data)) if <(char) = [,]> then if <not <(current item) = []>> then add (current item) to (target list) end set [current item v] to [] else set [current item v] to (join (current item) (char)) end change [char index v] by (1) end // Add the last item if <not <(current item) = []>> then add (current item) to (target list) end
⚡ Advanced Features
Add these enhancements for a professional save system:
1. Save Validation
// Validate save code before loading define validate save code (code) set [valid v] to [true] // Check for required sections if <not <(code) contains [STATS:]>> then set [valid v] to [false] end if <not <(code) contains [INVENTORY:]>> then set [valid v] to [false] end if <(valid) = [false]> then say [Invalid save code!] for (3) seconds stop [this script v] end
2. Multiple Save Slots
// Save to specific slot define save to slot (slot number) set [current save slot v] to (slot number) save game data set [save slot data v] to (join (join [SLOT] (slot number)) (join [:] (save code))) // Add to master save list if <(length of [save slots v]) < (slot number)> then add (save slot data) to [save slots v] else replace item (slot number) of [save slots v] with (save slot data) end
3. Auto-Save Feature
// Auto-save every 2 minutes when flag clicked forever wait (120) seconds // 2 minutes if <(game active) = [true]> then save to slot [auto] say [Auto-saved!] for (1) seconds end end
This system can handle any amount of data and is completely reliable! 💾
SaveSystem_Expert
Replied 4 hours later
@DataStorage_Pro This is absolutely incredible! 🤩
The encoding/decoding system is exactly what I needed. I love how it handles multiple data types and the validation system prevents corrupted saves. The auto-save feature is a brilliant addition too!
Implemented this in my RPG and it works flawlessly. Players can now save their entire game state with a simple code. Thank you so much! 🙏
CloudSave_Ninja
Replied 6 hours later
Excellent system! For those wanting even more advanced features, here’s how to add compression to reduce save code length:
// Simple compression for repeated data define compress data (input) set [compressed v] to [] set [last char v] to [] set [count v] to [0] repeat (length of (input)) set [current char v] to (letter (position) of (input)) if <(current char) = (last char)> then change [count v] by (1) else if <(count) > [1]> then set [compressed v] to (join (compressed) (join (count) (last char))) else if <not <(last char) = []>> then set [compressed v] to (join (compressed) (last char)) end end set [last char v] to (current char) set [count v] to [1] end end
This can reduce save code size by 30-50% for games with repetitive data! 📦
RPGDeveloper_Sam
Replied 8 hours later
For RPG developers, here are some specific data types you might want to save:
🎮 RPG Save Data Categories:
- Character Stats: Level, HP, MP, attributes
- Equipment: Equipped items, inventory contents
- Progress: Story flags, completed quests
- World State: Discovered locations, NPC interactions
- Settings: Difficulty, audio levels, controls
// Example RPG save structure define save rpg data set [save code v] to [RPG_SAVE_V1.0|] // Character data set [save code v] to (join (save code) (join [CHAR:] (join (player name) (join [,] (join (player level) (join [,] (join (player hp) (join [,] (player mp))))))))) set [save code v] to (join (save code) [|]) // Equipment slots set [save code v] to (join (save code) [EQUIP:]) encode list [equipped items v] with separator [,] set [save code v] to (join (save code) (encoded result)) set [save code v] to (join (save code) [|]) // Story progress set [save code v] to (join (save code) [STORY:]) encode list [story flags v] with separator [,] set [save code v] to (join (save code) (encoded result))
This structure makes it easy to expand your save system as your game grows! 🏰
Vibelf_Community
Pinned Message • Moderator
💾 Master Data Management and Save Systems!
Fantastic discussion about save/load systems and data persistence! For those wanting to create even more sophisticated data management solutions, our community can help you with:
- 🗄️ Advanced database design and optimization
- 🔐 Data encryption and security systems
- ☁️ Cloud save integration techniques
- 📊 Analytics and player behavior tracking
📚 Related Topics
- How to create user profiles and accounts?
- Building leaderboards and statistics
- Advanced data validation techniques
Ready to build robust data management systems? Get expert guidance from our programming tutors in the Vibelf app!