Discuss Scratch
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
Game: APES#editor
I am having tremendous trouble saving my map so I can move from one map and the other will not be affected. Currently the “save” code is in a few custom blocks. If someone could take a look, test it out, and maybe tell me why it's not working I would be VERY thankful.
It may be a bit difficult to decipher:
i (variable) is simply a tracker to tell the program which letter of the save to go to.
test (list) was my attempt to solve the problem - for some reason the variable on it's own only stores 133 characters. I need it to store 1496. “test” was an attempt to store the variable to a list as it went so it would not be cut off.
If you have any other questions about the code let me know. Thank you so much!
EDIT: The save code is currently in the sprite World
I am having tremendous trouble saving my map so I can move from one map and the other will not be affected. Currently the “save” code is in a few custom blocks. If someone could take a look, test it out, and maybe tell me why it's not working I would be VERY thankful.
It may be a bit difficult to decipher:
i (variable) is simply a tracker to tell the program which letter of the save to go to.
test (list) was my attempt to solve the problem - for some reason the variable on it's own only stores 133 characters. I need it to store 1496. “test” was an attempt to store the variable to a list as it went so it would not be cut off.
If you have any other questions about the code let me know. Thank you so much!
EDIT: The save code is currently in the sprite World
Last edited by HeroicToaster (Dec. 4, 2017 23:22:11)
- 25PickfordC
- Scratcher
1 post
Saving Game Help
I will try!
All you got to do is give me the link.
All you got to do is give me the link.
Last edited by 25PickfordC (Dec. 4, 2017 23:28:18)
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
I will try!
All you got to do is give me the link.
https://scratch.mit.edu/projects/186763111/#editor
The link is also in my original question. THANK YOU
- axus-
- Scratcher
64 posts
Saving Game Help
Please only bump a topic 24 hours after the last post. Thank you. Bump
paddle robs banks in his spare time uh.. d-donations yeahWhat the heck is DDCC18? https://scratch.mit.edu/discuss/topic/300290/
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
Please only bump a topic 24 hours after the last post. Thank you. Bump
Thank you for the tip! Do you have any ideas on how I could fix my project?
- deck26
- Scratcher
1000+ posts
Saving Game Help
Part of your problem might be that you only change x when you find a match. I'd have thought you'd want to check each of the colours and then change x regardless of whether or not you find a match.
Does that fix it?
Does that fix it?
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
Part of your problem might be that you only change x when you find a match. I'd have thought you'd want to check each of the colours and then change x regardless of whether or not you find a match.
Does that fix it?
The program actually needs to find a match for the save system to work, otherwise there would be random black spots on the map. I believe that the problem is that my variable does not store enough characters to save the entire world code.
- deck26
- Scratcher
1000+ posts
Saving Game Help
But if it doesn't find a match for any reason x is stuck with the same value for that repeat loop which can't be right. You need to absolutely sure you find a match and have a fallback value if you don't.Part of your problem might be that you only change x when you find a match. I'd have thought you'd want to check each of the colours and then change x regardless of whether or not you find a match.
Does that fix it?
The program actually needs to find a match for the save system to work, otherwise there would be random black spots on the map. I believe that the problem is that my variable does not store enough characters to save the entire world code.
I did try changing it so the change x was done after all the checks in the upper loop and got a lot more values in the list.
What I did was split your Save script after the call to Save.Test. As you have it manually running Save then gives 133 values in Saves but if you make my change you get 1524 values - presumably making the same change in the lower loop would give more.
I haven't tried to follow your code but this does sound relevant.
Last edited by deck26 (Dec. 5, 2017 11:23:30)
- deck26
- Scratcher
1000+ posts
Saving Game Help
Plus, the way you do it - what happens if it finds the first colour, change x by 10, find the next colour etc all in one pass of the loop? Each if should surely be an if/else.
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
But if it doesn't find a match for any reason x is stuck with the same value for that repeat loop which can't be right. You need to absolutely sure you find a match and have a fallback value if you don't.Part of your problem might be that you only change x when you find a match. I'd have thought you'd want to check each of the colours and then change x regardless of whether or not you find a match.
Does that fix it?
The program actually needs to find a match for the save system to work, otherwise there would be random black spots on the map. I believe that the problem is that my variable does not store enough characters to save the entire world code.
I did try changing it so the change x was done after all the checks in the upper loop and got a lot more values in the list.
What I did was split your Save script after the call to Save.Test. As you have it manually running Save then gives 133 values in Saves but if you make my change you get 1524 values - presumably making the same change in the lower loop would give more.
I haven't tried to follow your code but this does sound relevant.
Ok. I see what you're getting at. But is there anyway for me to store all the code in a single variable? It seems that the character limit is too small for that to work. Should I try to store it in a list instead?
- deck26
- Scratcher
1000+ posts
Saving Game Help
Using join you can get up to 10240 characters in a variable which seems enough from your opening post.
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
Using join you can get up to 10240 characters in a variable which seems enough from your opening post.
As you can see from my code, I have attempted to do exactly that, and yet it seems to stop much sooner and goes into a repeat when you run the “Recall.Save” block. It works for as long as the variable seems to go on.
- deck26
- Scratcher
1000+ posts
Saving Game Help
Tell me which bit fails to append characters and I'll have a look.
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
In the custom block “Save”, the code:
Seems only to append around 150 characters to the variable Save.Data rather than the necessary amount of 1496. The variable just doesn't seem to be storing all the character I need it to.
This is despite the fact that I have a repeat block:
set [Save.Data] to (join (Save.Data) (item (i) of [Saves] :: list))
Seems only to append around 150 characters to the variable Save.Data rather than the necessary amount of 1496. The variable just doesn't seem to be storing all the character I need it to.
This is despite the fact that I have a repeat block:
repeat (length of [Saves] :: list)
end
Last edited by HeroicToaster (Dec. 5, 2017 13:30:47)
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
In the custom block “Save”, the code:set [Save.Data] to (join (Save.Data) (item (i) of [Saves] :: list))
Seems only to append around 150 characters to the variable Save.Data rather than the necessary amount of 1496. The variable just doesn't seem to be storing all the character I need it to.
This is despite the fact that I have a repeat block:repeat (length of [Saves] :: list)
end
I'm sorry the problem now appears to be in the block Save.Test.
The block only ends up adding 133 values to the list Saves.
I can not figure out what is wrong with that code.
EDIT: after further testing it now adds only 89 values.
Last edited by HeroicToaster (Dec. 5, 2017 13:41:48)
- deck26
- Scratcher
1000+ posts
Saving Game Help
That code works fine when I manually add data to Saves to get it to a decent length - it's still only getting to 133 items in the list when I run your project normally. So I created a loop to add 10,000 values and manually ran your code to build Save.Data and it worked fine.
Suggest you need to check the length of the list before you start adding to Save.Data and check the length of that variable afterwards as it should work without problem.
Suggest you need to check the length of the list before you start adding to Save.Data and check the length of that variable afterwards as it should work without problem.
- HeroicToaster
- Scratcher
99 posts
Saving Game Help
That code works fine when I manually add data to Saves to get it to a decent length - it's still only getting to 133 items in the list when I run your project normally. So I created a loop to add 10,000 values and manually ran your code to build Save.Data and it worked fine.
Suggest you need to check the length of the list before you start adding to Save.Data and check the length of that variable afterwards as it should work without problem.
I'm not sure I understand. Could you possibly share the code?
- deck26
- Scratcher
1000+ posts
Saving Game Help
133 values is what I got as mentioned earlier with the change x blocks the way you had them.
The way you've set up the if/else doesn't make any difference to anything. 1=1 in all cases so the old code gets run and the else is ignored.
What I meant was
The way you've set up the if/else doesn't make any difference to anything. 1=1 in all cases so the old code gets run and the else is ignored.
What I meant was
if <touching color [#2e74b0] ?> thenbut I still think changing x in each ‘if’ is a mistake. You should be doing
else
if <touching color [#2e74b0] ?> then
else
if <touching color [#2e74b0] ?> then
else
if <touching color [#2e74b0] ?> then
else
change x by [10]
end
end
end
end
if <touching color [#2e74b0] ?> then
else
if <touching color [#2e74b0] ?> then
else
if <touching color [#2e74b0] ?> then
else
if <touching color [#2e74b0] ?> then
end
end
end
end
change x by [10]
- The_Best_Programmer
- Scratcher
23 posts
Saving Game Help
How do you do it in the first place? Trying to make a project where it saves your design and you can put in your code again so you can load your design.
Plz help
Plz help
say [Please help me] for (2) secs
TBP