GS-NewGRF Communication via JSON

Contents

General

Supported types of communication

Emulatable types of communication

Not supported types of communication

AIs

Overview

GS/AI info query callback

GS trigger callback

GS announcement board

Structure details

GS Details

  local param;
  param.foo = 123;
  local data = GSIndustry.GetNewGRFInfo(industry, "bar", param);
  if (data.rawin("foobar")) {
    data.foobar ...
  }
  local data;
  data.foo = 123;
  GSIndustry.SendNewGRFTrigger(industry, "bar", data);
  local data;
  data.foo = 123;
  GSController.SetNewGRFInfo("bar", data);
  local data;
  data.foo = 123;
  GSController.SetNewGRFInfo("bar", data);

NewGRF Details

Announcement board: Conversion from global JSON to 60+x variable

Action14:

    JSON -> VARI
        <60+x parameter>
             FMT_           FormatId
             PATH           JSON path, e.g 'Foo.Bar[2].Doh'.
             VALU
                 <val>      String enum literal
             DFLT           Default value if unassigned (required!)

New global 60+x variable:

Query: Conversion from Callback result to JSON

Action14:

    JSON -> CBOU
        <callback result>
            TMPL                  JSON template string with <1> <2> parameters
                                  Example: '{ "Supports": ["GSProduction"], "Production": <1>, "Technology": <2> }'
            PARA
                <paramid>
                    TYPE          0 = uint/enum, 1 bool, 2 = sint/enum
                    MASK          \w register (0x00-0x10F) \b first-bit \b num-bit
                    VALU
                        <val>     String enum literal

New callback:

Conversion from input JSON to callback paramters

Action14:

    JSON -> CBIN
        <callback param 1>
            FMT_                  FormatId
            TMPL                  JSON template string with <1> <2> paramters
                                  Example '{ "ProductionLevel": <1>, "InputCargoEfficiency": [ <1>, <2> ] }'
            PARA
                <paramid>
                    MASK          \w register (0x00-0xFF) \b first-bit \b num-bit
                    VALU
                        <val>     String enum literal
                    DFLT          default value if missing

Template matching:

TODO: This is quite complicated, the format for the 60+x variable looks both easier to use and to implement. So, use it for this as well.

New callback: