This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-20 09:34:13

PhreakyPhantom
Scratcher
Registered: 2010-10-25
Posts: 11

How can you make a save function?

I'm trying to make a game called Monster Mayhem where you capture monsters and travel to different locations - Sort of like Collab Monsters by Archmage - I'm really trying hard to make the game. But there is one problem. I want the game to save when you click a save button. I know it has  to do with a script with a list but can aybody help me on this? I'm just an advanced programmer...

Offline

 

#2 2011-04-20 11:53:29

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: How can you make a save function?

How much does it need to save? Just the score, or the coordinates of each sprite?


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#3 2011-04-20 13:55:29

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: How can you make a save function?

If you want it to save within the game (so if you close the project without saving the save will still be lost), you should have a script starting with "When save clicked". You then use the "delete [all] of list [save data]" block to clear any previous data stored there. After that, use the "add [thing] to list [save data]" block to add lines of code. so you can do things like

when save clicked:
add [(score)] to [save data]
add [(lives)] to [save data]
add [([x-position] of [player])] to [save data]
dad [([y-position of [player])] to [save data]

and so on. When the game loads a similar script can then be used:

when I recieve [load game]:
set [score] to [(item(1)of[save data])]
set [lives] to [(item(2)of[save data])]
set x position to ((item(3)of[save data]) )
set y position to ((item(4)of[save data]) )

smile

Last edited by sparks (2011-04-20 13:55:51)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#4 2011-04-20 15:06:46

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How can you make a save function?

sparks wrote:

If you want it to save within the game (so if you close the project without saving the save will still be lost), you should have a script starting with "When save clicked". You then use the "delete [all] of list [save data]" block to clear any previous data stored there. After that, use the "add [thing] to list [save data]" block to add lines of code. so you can do things like

when save clicked:
add [(score)] to [save data]
add [(lives)] to [save data]
add [([x-position] of [player])] to [save data]
dad [([y-position of [player])] to [save data]

and so on. When the game loads a similar script can then be used:

when I recieve [load game]:
set [score] to [(item(1)of[save data])]
set [lives] to [(item(2)of[save data])]
set x position to ((item(3)of[save data]) )
set y position to ((item(4)of[save data]) )

smile

lol  tongue

Offline

 

#5 2011-05-06 03:14:52

arceus4100
Scratcher
Registered: 2011-04-24
Posts: 2

Re: How can you make a save function?

That's what I was trying to find out.<point towards( <move(  )steps><move(  )steps><move(  )steps><move(  )steps><move(  )steps><move(  )steps>

Offline

 

#6 2011-05-06 06:03:57

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: How can you make a save function?

scimonster wrote:

sparks wrote:

If you want it to save within the game (so if you close the project without saving the save will still be lost), you should have a script starting with "When save clicked". You then use the "delete [all] of list [save data]" block to clear any previous data stored there. After that, use the "add [thing] to list [save data]" block to add lines of code. so you can do things like

when save clicked:
add [(score)] to [save data]
add [(lives)] to [save data]
add [([x-position] of [player])] to [save data]
dad [([y-position of [player])] to [save data]

and so on. When the game loads a similar script can then be used:

when I recieve [load game]:
set [score] to [(item(1)of[save data])]
set [lives] to [(item(2)of[save data])]
set x position to ((item(3)of[save data]) )
set y position to ((item(4)of[save data]) )

smile

lol  tongue

Sci I'm all for you pointing out spelling mistakes in official posts, that's good, and even if you're also commenting on the above post in a way that helpfully adds to it. This however is just plain annoying because you're not contributing to the conversation on the thread and don't really make the advice I give sound as sound as it otherwise might have, which just makes everyone look stupid. Please try to keep posts like this at least contributory.  smile

@arceus4100, does that mean your problem is solved?


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#7 2011-05-06 06:05:24

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How can you make a save function?

sparks wrote:

scimonster wrote:

sparks wrote:

If you want it to save within the game (so if you close the project without saving the save will still be lost), you should have a script starting with "When save clicked". You then use the "delete [all] of list [save data]" block to clear any previous data stored there. After that, use the "add [thing] to list [save data]" block to add lines of code. so you can do things like

when save clicked:
add [(score)] to [save data]
add [(lives)] to [save data]
add [([x-position] of [player])] to [save data]
dad [([y-position of [player])] to [save data]

and so on. When the game loads a similar script can then be used:

when I recieve [load game]:
set [score] to [(item(1)of[save data])]
set [lives] to [(item(2)of[save data])]
set x position to ((item(3)of[save data]) )
set y position to ((item(4)of[save data]) )

smile

lol  tongue

Sci I'm all for you pointing out spelling mistakes in official posts, that's good, and even if you're also commenting on the above post in a way that helpfully adds to it. This however is just plain annoying because you're not contributing to the conversation on the thread and don't really make the advice I give sound as sound as it otherwise might have, which just makes everyone look stupid. Please try to keep posts like this at least contributory.  smile

@arceus4100, does that mean your problem is solved?

OK, I'm sorry.  neutral
I'll keep my posts out of misc worthwhile.  tongue

Last edited by scimonster (2011-05-13 00:19:48)

Offline

 

#8 2011-05-06 13:45:37

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: How can you make a save function?

Yeah, most languages, have hundreds of little features and functions. Scratch has less than 100 but it has all the most important features. One feature that was left out was creating save data (scratch v2 may provide this though). So even in my game Collab Monsters, the save button doesn't save, it just prepares the project to be saved when downloaded.

Your options are:

-make a password system to unlock specific parts of the game
-Make it so that saving works when downloaded and a save button readies the project for saving


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#9 2011-05-09 17:05:58

PhreakyPhantom
Scratcher
Registered: 2010-10-25
Posts: 11

Re: How can you make a save function?

Lulz... I just invented a way, thnx anyways xD

Offline

 

#10 2011-05-09 17:36:16

eclown
Scratcher
Registered: 2009-07-23
Posts: 19

Re: How can you make a save function?

Lulz... I just invented a way, thnx anyways xD

How?
hmm


http://img856.imageshack.us/img856/8247/cooltext554162460.png
♫ 92% of teens have moved on to rap. 8% still listen to real music. If you are part of the 0% who listen to good music, no matter what, copy and paste this into your signature. ♫♪

Offline

 

#11 2011-05-10 15:57:28

PhreakyPhantom
Scratcher
Registered: 2010-10-25
Posts: 11

Re: How can you make a save function?

I never paid attention to the forums so I just downloaded some other projects, stealing their copy device xD

Offline

 

#12 2011-05-11 13:10:50

CloneCommando1
Scratcher
Registered: 2010-12-02
Posts: 500+

Re: How can you make a save function?

I don't think its possible, or well, at least not easily.  tongue


RANDOM THOUGHT: If the tomato is a fruit, doesn't that make ketchup a smoothie?

Offline

 

#13 2011-05-14 17:34:35

elimantor
Scratcher
Registered: 2011-04-03
Posts: 76

Re: How can you make a save function?

hello elim here me saying its extremely possible to make a save script but it involves a save code like it asks what the load code type it in and if its the level code it changes the level!


scratch 2.0 forever!  big_smile

Offline

 

Board footer