Jump to content

Tile format: Difference between revisions

Add per-cell protection
Fix heading level
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Page in progress}}
A tile is comprised of several data structures that provide several key information about the tile. The most important bit of information is the content, which stores the tile's textual information.
A tile is comprised of several data structures that provide several key information about the tile. The most important bit of information is the content, which stores the tile's textual information.


Line 56: Line 54:
The base64 table as used by the format is as follows: <code>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/</code>
The base64 table as used by the format is as follows: <code>ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/</code>


In order to decode the base64 string, the "@" character must first be stripped. Then, all characters must be iterated through. The base64 character must be converted to its index within the base64 table. Each base64 character holds information for three cells. To retrieve the information for the next three characters, the respective formulas are used: <code>idx >> 4 & 3</code>; <code>idx >> 2 & 3</code>; <code>idx & 3</code>. To allow for the proper encoding of protection information in base64, the writability values are shifted up by one and null is assigned 0. When decoding, the numbers are shifted down by one and what was originally zero is assigned null. To re-encode the string, the "@" character must first be added to indicate the base64 type. Then, the following formula is used for the next three characters: <code>c1 << 4 | c2 << 2 | c3</code>. If no characters are left, the value 0 is substituted. The final step is to convert the character into a base64 character and then append it to the string.
In order to decode the base64 string, the "@" character must first be stripped. Then, all characters must be iterated through. The base64 character must be converted to its index within the base64 table. Each base64 character holds information for three cells. To retrieve the information for the next three characters, the respective formulas are used: <code>idx >> 4 & 3</code>; <code>idx >> 2 & 3</code>; <code>idx & 3</code>. To allow for the proper encoding of protection information in base64, the writability values are shifted up by one and null is assigned 0. When decoding, the numbers are shifted down by one and what was originally zero is assigned null. To re-encode the string, the "@" character must first be added to indicate the base64 type. Then, the following formula is used for the next three characters: <code>c1 << 4 | c2 << 2 | c3</code>. If no characters are left, the value 0 is substituted. The final step is to convert the value into a base64 character and then append it to the string.
 
Here is an example of a network tile object containing a per-cell protection string:<syntaxhighlight lang="json">
{
    "content": "<omitted>",
    "properties": {
        "char": "@VVVWqlVVVqpVVVaqVVVWqlVVVqqqqqqqqqqqqqqqqqo"
    }
}
</syntaxhighlight>
 
=== Example values ===
 
==== Base64 ====
Starting char: <code>@</code>
 
Possible values per cell: 4
 
Full string: <code>@VVVWqlVVVqpVVVaqVVVWqlVVVqqqqqqqqqqqqqqqqqo</code>
 
==== Comma-separated integers ====
Starting char: <code>#</code>
 
Possible values per cell: Indeterminate
 
Full string: <code>#1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2</code>
 
==== Hexadecimal ====
Starting char: <code>x</code>
 
Possible values per cell: 256
 
Full string: <code>x0101010101010101010101020202020201010101010101010101010202020202010101010101010101010102020202020101010101010101010101020202020201010101010101010101010202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202</code>


== Per-Cell Links ==
== Per-Cell Links ==
All link data is stored within the "cell_props" object in "properties". Since a cell can store only one link no matter the type (URL link or coordinate link), each link is addressed by its Y and X cell coordinates. The "cell_props" object stores all the rows of a tile as Y coordinates. Each row is an object which then contains all the X coordinates for that row. The X coordinates are yet another object which stores the property for that specific cell. Since only links are supported within cell_props at the time of writing, the only property that can be inside this object is "link". The link property can only store information for either a URL link or a coordinate link, as shown below<syntaxhighlight lang="text">
link =>
    type: "url"
    url: <string>
link =>
    type: "coord"
    link_tileX: <number>
    link_tileY: <number>
</syntaxhighlight>Here is an example of a "cell_props" object containing a URL link to the YouTube homepage at the top middle of a tile, and a coordinate link to (0, 100) at the top right<syntaxhighlight lang="json">
{
    "0": {
        "8": {
            "link": {
                "type": "url",
                "url": "https://www.youtube.com/"
            }
        },
        "15": {
            "link": {
                "type": "coord",
                "link_tileX": 0,
                "link_tileY": 100
            }
        }
    }
}
</syntaxhighlight>
[[Category:Documentation]]