GridJSON

From Esolang
Jump to navigation Jump to search

GridJSON is an esoteric language based on JSON as scope/function syntax.

Here is the link to the interpreter/environment. The documentation will assume that this interpreter is used.

Error handeling

Some compile errors, like JSON formatting errors, will be listed in "data/games/yourgame.json - error log.txt". If your game does not appear in the list of available games, look here.

Most other errors are in "data/debug.log".

General Syntax

The code is written inside JSON. The comments "//" are only here to demonstrate the behavior, the actual file may not contain any comments!

 {
   "name": "ExampleGame",   //The name of the game, purely visual
   "version": "0.1.0",      //The version of the game, purely visual
   "settings": {            //Settings that might be changed before starting (sliders (NUMBER) and checkboxes (FLAG)). No other types are accepted.
     "options":{
       "exampleOption": {   //internal name
         "type": "NUMBER",  //its a number (a slider in this case)
         "range": "0 16",   //range of the slider
         "name": "Cool Option",   //display name
         "index": 0,        //index (y position in the options menu
         "value": 4         //default value (optional)
       },
       "flagOption": {      //internal name
         "type": "FLAG",    //its a number (a slider in this case)
         "name": "Yes/No",  //display name
         "index": 1,        //index (y position) in the options menu
         "value": true      //default value (optional)
       }
     },
     "presets": [
       {
         "name": "Default",   //display name
         "values": {          //values of the preset. Not all settings have to be applied.
           "exampleOption": 4,
           "flagOption": false
         },
         "index": 3            //index (y position) in the options menu. continue after last option.
       }
     ]
   },
   "code":{
     "context":{                //currently only the chessboard size is defined here
       "board":{                //width and height of the chessboard
         "width": "width",      //values 1 - 128 (included)accepted 
         "height": "exampleOption" //options may also be used for variable size
       }
     },
     "structures":{             //custom structs (like structs in c#/any other language that uses structs)
       "PLAYER":{               //struct called PLAYER
         "score": "NUMBER",     //all variables
         "highScore": "NUMBER"  
       }
     },
     "globals":{                //all global variables
       "players": "LIST OF PLAYER"
     },
     "functions":{
       //see Functions
     }
   }
 }

Naming convention and variables

Naming convention

code part naming convention
variable type / struct MYTYPE
variable name myVariable
function MyFunction
Builtin Constants THECONSTANT
Builtin Commands / keyword THECOMMANDORKEYWORD

Variables

type usage
NUMBER int
FLAG bool
COLOR color enum

Constants

Colors

name value
RED #FF0000
PURPLE #FF00FF
BLUE #0000FF
CYAN #00FFFF
GREEN #00FF00
YELLOW #FFFF00
ORANGE #FF8800
BLACK #000000
WHITE #FFFFFF

Other

Other constants are TRUE and FALSE, used for variables of type FLAG.

Functions

Commands