DocumentInQuestion.png It has been suggested that this page's contents be merged with the page Encoding and Decoding Cloud Data. You can discuss this on the page's talk page. (June 2021)

Encoding and decoding data is the process of changing it between different formats.

How to Make Encoder/Decoder Scripts

Variables and Lists Needed

  • (i): Short for index. Tracks the letter in a string.
  • (encoded): Stores the encoded variable.
  • (val): Stores the decoded value.
  • (letter): Stores the decoded letter.
  • (cipher::list): Stores encoding/decoding data.

Setup

Storing Cipher in a List

  1. Add 9 blank items to (cipher::list)
  2. Add the characters a-z and 0-9, in that order; each character gets its own item

Encoding Script

define clear encoded data
set [encoded v] to ()
// this erases past encoded data

define write (string) to encode
//this code encodes text add writes it to encoded
set [i v] to (1)
repeat (length of (string))
set [encoded v] to (join (encoded) (item # of (letter (i) of (string)) in [cipher v])
// adds encoded version of letter of data
change [i v] by (1)
end
set [encoded v] to (join (encoded) (00))

Decoding Scripts

define setup decoded of (string)
set [encoded v] to (string)
set [i v] to (1)

define extract next val from encoded
// this undecoded a single item from the encoded value
set [val v] to ()
set [letter v] to (99)
// just resets
repeat until <[1] > (letter)> // runs until either you hit the 00 stopper or when encoded ends
set [letter v] to (join (letter (i) of (encoded))  (letter ((i) + (1)) of (encoded)))
//gets the encoded letter
set [val v] to (join (val) (item (letter) of [cipher v]))
// decodes the letter and writes it to val
change [i v] by (2)
// moves i to look for the next encoded letter

Example

Saving

clear encoded data:: custom
write (x position) to encode:: custom
write (y position) to encode:: custom
write (level) to encode:: custom
write (coins) to encode:: custom
show variable [encoded v]

Loading

ask [enter save code] and wait
setup decoded of (answer):: custom
extract next val from encoded:: custom
set x to (val)
extract next val from encoded:: custom
set y to (val)
extract next val from encoded:: custom
set [level v] to (val)
extract next val from encoded:: custom
set [coins v] to (val)

External Links

Cookies help us deliver our services. By using our services, you agree to our use of cookies.