Logo
  • Features
  • Educators
  • What's New
  • Blog
  • Showcase
  • About us
  • Contact
Try it now!
Archive Code
Archive Code

Archive Code

Why use Archive Code Extension?

When programming with Scratch, sometimes we may come across situations where we want to turn several variables and lists into a a string of characters, like making archive code.

For example, we can use the following script to make a simple archive code:

image

And we can use the following script to get data from the archive code (Using Suger Extension):

image

In more complex cases, where we want to convert lists into a string of characters, the method using separators like the script above becomes more complicated.

In that situation, we can use Archive Code Extension. With Archive Code Extension, we can make and decode archive codes conveniently.

How does the extension work?

The extension use a "container". You can store variables and lists in this "container" and convert them into an archive code, which is actually a JSON string.

Functions and Definition

Basic Blocks

Empty Container.

Clear all data stored in Container.

image

Add … to Container.

Add data to Container and name it.

⚠️
Note: If the name has already exsited, the exsited data will be overwritten.
image
image
image

Container in string format.

Convert the contents in Container into a string. (in JSON format actually)

image

e.g. Use the script below to add several values and list to Container.

image

And use the block below to convert all the data in Container into an archive code.

image

The archive code will be like:

{
	"coins":100,
	"handheld item":"apple",
	"backpack":["oak","stone","berries"]
}

Parse string to Container.

Parse a string of archive code to Container.

e.g. Use the script below to get several data from the archive code.

It will get value 200 named “coins” and a list named “backpack” that contains 2 items.
It will get value 200 named “coins” and a list named “backpack” that contains 2 items.
⚠️
Note: Only archive codes that match the format can be parse correctly.

If failed to parse, the block below will return false. And the original contents in Container will be preserved

image

e.g. Run the script below, the parse failed, and the original contents in Container won’t change.

image

Get contents in Container.

Use the block below to get the corresponding content of the name.

image

Use the following blocks to save content to variable or list.

image
image

Auxiliary Blocks

Get the amount of contents in Container.

image

For example, if there are two variables and a list that contains two items in Container, the block will return 3. (two variables and a list)

Get … of the xth content

image

Get certain information of the xth content

Property
Description
Name
The name of the content
Value
The value of the content
Type
The type of the content (variable or list)
Length of list
The length of the list (return blank character if the content is not a list)

If Container contains…

determine whether Container contains content with certain name.

image

Length of the list

return the length of the list with certain name.

(return blank character if the content is not a list or the list doesn’t exsit)

image

#… of the list

Get the xth content in certain list.

image

#… of the list

Delete content with certain name in Container.

image

Additional Blocks

Encrypt / decrypt … with key …

These blocks are used to encrypt / decrypt something. You can use them to encrypt archive code.

⚠️
Note: Due to an algorithm error, the encryption will be incorrect when encountering some special characters. (For example, the Chinese character “!”)
image
image

What does the “key” do: only both keys in encryption and decryption match, the text can be correctly decrypted.

For example, you can use players’ userID as the key, so that only the correct person can decrypt the text correctly and get the text.

Copy … to clipboard.

Copy something to the clipboard. It can be used to copy the archive code.

image

Get Unicode of… / get character of Unicode …

image
image

Get the code of a character. The code ranges from 0 to 65535. For example, Unicode of character “A” is 65.

Those two blocks can be used to make your own encryption algorithms.

Best Practices

Make An Archive Code

Make and read archive codes with the following scripts:

image
image

Make A Cloud Archive

Use the following scripts to make the cloud archive:

image
image

Use with Simple MMO

As we know, in Simple MMO Extension, every player has only one extra data,which make it hard to store multiple data of the player.

In this case, we can use Archivecode Extension like this:

image
image

What’s more, when using boardcasting in Simple MMO, sometimes we may need to boardcast a message with multiple information.

Then we can use the script like below:

image
image

Other situations where we need to store multiple information in one variable…

For example, supposed that we want to store several tile maps in a list, and we hope that each map only occupies one item in the list.

Then we can convert all information of a map into a string of characters with Archivecode Extension, so that we can save them in a list conveniently.

Roadmap and Logs

Version
Log / What’s New
1.0
Added: The initial version.
Logo

Designed by 2ndR with love

Discord