Discuss Scratch

SuperGamerGG2
Scratcher
88 posts

How to create save codes?

Hello, I'm trying to make a save code mechanism in the “save data” sprite, but I just stuck. Please help me!
https://scratch.mit.edu/projects/969611148/editor/
MineTurte
Scratcher
1000+ posts

How to create save codes?

SuperGamerGG2 wrote:

Hello, I'm trying to make a save code mechanism in the “save data” sprite, but I just stuck. Please help me!
https://scratch.mit.edu/projects/969611148/editor/
Well it depends. If you want it so people can't easily just alter it you'll either have to use some really advanced encoder, or just hide the code by editing the JSON file. If @Malicondi happens to see this post he can probably provide you with a link on how to edit the JSON file, cuz I don't know how lol.

But if you don't mind people being able to change it then:
when I receive [ generate code]
set [ code] to (join [username] (join [|] (join (coins) [|])))

If you need the decoding script too, ask.
Hope I helped btw!
SuperGamerGG2
Scratcher
88 posts

How to create save codes?

MineTurte wrote:

SuperGamerGG2 wrote:

Hello, I'm trying to make a save code mechanism in the “save data” sprite, but I just stuck. Please help me!
https://scratch.mit.edu/projects/969611148/editor/
Well it depends. If you want it so people can't easily just alter it you'll either have to use some really advanced encoder, or just hide the code by editing the JSON file. If @Malicondi happens to see this post he can probably provide you with a link on how to edit the JSON file, cuz I don't know how lol.

But if you don't mind people being able to change it then:
when I receive [ generate code]
set [ code] to (join [username] (join [|] (join (coins) [|])))

If you need the decoding script too, ask.
Hope I helped btw!
yes i need help decoding it. pls
MineTurte
Scratcher
1000+ posts

How to create save codes?

SuperGamerGG2 wrote:

MineTurte wrote:

SuperGamerGG2 wrote:

Hello, I'm trying to make a save code mechanism in the “save data” sprite, but I just stuck. Please help me!
https://scratch.mit.edu/projects/969611148/editor/
Well it depends. If you want it so people can't easily just alter it you'll either have to use some really advanced encoder, or just hide the code by editing the JSON file. If @Malicondi happens to see this post he can probably provide you with a link on how to edit the JSON file, cuz I don't know how lol.

But if you don't mind people being able to change it then:
when I receive [ generate code]
set [ code] to (join [username] (join [|] (join (coins) [|])))

If you need the decoding script too, ask.
Hope I helped btw!
yes i need help decoding it. pls

Here:
when I receive [ encode]
set [ code] to (join (username) (join [|] (join (coins) [|])))

define decode (what to decode)//set to run without screen refresh
set [ letter] to [0]
set [ temporaryCoins] to [] //Make sure this is blank, no space or anything.
set [ fetchedUsername] to [] //Also set to blank.
repeat until <(letter (letter) of ([what to decode])) = [|]>
change [ letter] by (1)
if <not <(letter (letter) of ([what to decode])) = [|]>> then
set [ fetchedUsername] to (join (fetchedUsername) (letter (letter) of ([what to decode])))
end
end
change [ letter] by (1)
repeat until <(letter (letter) of ([what to decode])) = [|]>
change [ letter] by (1)
if <not <(letter (letter) of ([what to decode])) = [|]>> then
set [ temporaryCoins] to (join (temporaryCoins) (letter (letter) of ([what to decode])))
end
end
if <(username) = [fetchedUsername]> then
set [ coins] to []
end

Basically this just goes through every letter starting at 1 and until it hits a | it keeps adding the letter of whats encoded to whatever is first (for this example it's your username). Once it reaches a | it stops adding letters to your username and skips the | then starts to add the letters fetched to the temporaryCoins. Once it reaches another | it stops finally and checks if you username equals the one fetched, if so then it sets your coins to the coins fetched.

Hope this helps! (And works lol. I believe it does but I'm not too sure.)
Malicondi
Scratcher
1000+ posts

How to create save codes?

MineTurte wrote:

Well it depends. If you want it so people can't easily just alter it you'll either have to use some really advanced encoder, or just hide the code by editing the JSON file. If @Malicondi happens to see this post he can probably provide you with a link on how to edit the JSON file, cuz I don't know how lol.
Sorry, I can't give anyone that, it's technically against the Terms of Use :p
SuperGamerGG2
Scratcher
88 posts

How to create save codes?

MineTurte wrote:

SuperGamerGG2 wrote:

MineTurte wrote:

SuperGamerGG2 wrote:

Hello, I'm trying to make a save code mechanism in the “save data” sprite, but I just stuck. Please help me!
https://scratch.mit.edu/projects/969611148/editor/
Well it depends. If you want it so people can't easily just alter it you'll either have to use some really advanced encoder, or just hide the code by editing the JSON file. If @Malicondi happens to see this post he can probably provide you with a link on how to edit the JSON file, cuz I don't know how lol.

But if you don't mind people being able to change it then:
when I receive [ generate code]
set [ code] to (join [username] (join [|] (join (coins) [|])))

If you need the decoding script too, ask.
Hope I helped btw!
yes i need help decoding it. pls

Here:
when I receive [ encode]
set [ code] to (join (username) (join [|] (join (coins) [|])))

define decode (what to decode)//set to run without screen refresh
set [ letter] to [0]
set [ temporaryCoins] to [] //Make sure this is blank, no space or anything.
set [ fetchedUsername] to [] //Also set to blank.
repeat until <(letter (letter) of ([what to decode])) = [|]>
change [ letter] by (1)
if <not <(letter (letter) of ([what to decode])) = [|]>> then
set [ fetchedUsername] to (join (fetchedUsername) (letter (letter) of ([what to decode])))
end
end
change [ letter] by (1)
repeat until <(letter (letter) of ([what to decode])) = [|]>
change [ letter] by (1)
if <not <(letter (letter) of ([what to decode])) = [|]>> then
set [ temporaryCoins] to (join (temporaryCoins) (letter (letter) of ([what to decode])))
end
end
if <(username) = [fetchedUsername]> then
set [ coins] to []
end

Basically this just goes through every letter starting at 1 and until it hits a | it keeps adding the letter of whats encoded to whatever is first (for this example it's your username). Once it reaches a | it stops adding letters to your username and skips the | then starts to add the letters fetched to the temporaryCoins. Once it reaches another | it stops finally and checks if you username equals the one fetched, if so then it sets your coins to the coins fetched.

Hope this helps! (And works lol. I believe it does but I'm not too sure.)
i starting to use griffpatch's tutorial. this is pretty much the same! Thanks anyway!
when problem [solved v]
broadcast [be happy v]
stop [this script v]
SuperGamerGG2
Scratcher
88 posts

How to create save codes?

Malicondi wrote:

MineTurte wrote:

Well it depends. If you want it so people can't easily just alter it you'll either have to use some really advanced encoder, or just hide the code by editing the JSON file. If @Malicondi happens to see this post he can probably provide you with a link on how to edit the JSON file, cuz I don't know how lol.
Sorry, I can't give anyone that, it's technically against the Terms of Use :p
oh.

Powered by DjangoBB