Settings extension

Announcing a new extension settings! This extension can be used to store and retrieve persistent data for a game. That means, the data can be read even if you turn off your console or reset the game in the simulator!

Some possible use cases:

  1. Storing the progress of a character in an RPG
  2. Tracking game stats for a player like how many enemies they’ve defeated or how many times they’ve died
  3. Remembering choices that a player makes

To use it,

11 Likes

Hi, really hoping I get an answer here, since I’m literally tearing my hair out over this. So, I’m trying to make a title screen for my game, I’ve barely gotten into the meat of the game. What I want to do, is make it so the first time it’s opened, the start button says “Start”. Then, after the games been reset, after the first start, the start button will say “Load”. Do you know how I would go about doing that? Thank you

-A brand new forum member
P.S
for reference
Screenshot 2024-02-07 8.42.13 PM

3 Likes

I have done this all the time. Here’s what you need to do

1 Like

Just check if one of the settings that is saved “exists” with the “setting with name () exists “ block. For example, let’s say your score increases while you play the game. Just display the other screen if that setting “exists”. You could just make a setting called “game started” or something and make it only when the game is played.

Can you share your code?

Ok, so you can use Mr. @Sarge’s better settings for this.

https://github.com/S0m3randomguy/BetterSettings

then, what you can do is, make the button into a sprite, and at the very beginning, make an if statement with the blocks, like, I dunno…

if (setting with name /* name of setting */ exists) {
    // set my sprite image to the loading image thingy
} else {
   // set my sprite image to the start image thingy
}

And then where the game actually starts…

set setting /* name of setting */ to boolean true

And that should do it! Unless you’re asking for the game to actually LOAD, then that’s more complicated. Definitely possible though.

3 Likes

How long does the data last in storage?
I am asking this because I’m making a game that some of my friends have been playing for over a week, and I would like to add a save feature.
Also, will they have individual saves if I release it to more than one person?

2 Likes

If you are using the settings extension, then the saved data is tied to the browser data of the device they play it on, kinda where stuff like cookies are stored, so their data is their own and they will have their own save. However, if they clear their cookies or the browser looses the data, they will lose the save.

This loss can be prevented if they have a Makecode Arcade/Microsoft account and download a copy of your game for themselves, then I believe the data is saved to the cloud.

Idk how often it saves that data to the cloud, though, as I just tested an old project of mine on my computer and it has the same saved data as how I left it last time I played on my phone, but then I edited the saved data, opened it on my computer, and it’s not saved… so idk, but it should be tied to the project more reliably than using normal browser storage once they have their own copy saved to the cloud.

That would mean that changes you make will not effect their copy, so if you are worried about loosing the data and decide to have everyone copy the project, you might want to think of an easy way to copy the data and insert it into a new copy, so that they can still download new updates and keep their saved data.

1 Like

From what I know, the data is stored until the game changes I guess? Anyways, it does support storing multiple people’s data up until you change the game name.

  1. actually yes they last forever until cleared I think
  2. yup they have custom saves per person
1 Like

Hi,
I tried to add this extension to MakeCode in Minecraft Education but unfortunately after clicking add the tab does not appear to allow you to use the extension.

2 Likes

The extension probably only works in Arcade, utilizing built in JavaScript functions that aren’t in Minecraft, because you can just save information in files on the computer in Minecraft, you don’t have to actually control the flash memory to save stuff, which is what the Arcade version has to do. Idk if there’s some equivalent in Minecraft, some way to save a file of information to the computer.
@makecode is there a way to save files using Makecode for Minecraft?

1 Like

I think this extension was made with the intent of using it with Microsoft MakeCode Arcade. If you want to have a similar extension for MakeCode Minecraft you may have to make it yourself or ask the community if they can make it.

2 Likes

this extension is indeed not compatible with minecraft

3 Likes

I checked and in pure JS there are only two methods of saving the file Blob and File API and unfortunately both are unavailable :confused:

2 Likes

That’s unfortunate. Many modern mods require saving information, like even just for user settings! I know Makecode isn’t exactly used for modding, but this would still be nice! Then again, you could always physically place blocks in the world as a sort of save state, which would be interesting.

Blocks are a great idea to manage states for some settings and I think was be possible to make an extension to do this (choose some large coordinates)

But still this can’t allow us to save some coordinates or string variables.

1 Like