y-lohse / inkjs

A javascript port of inkle's ink scripting language.
http://www.inklestudios.com/ink/
MIT License
507 stars 104 forks source link

Constants are not considered by the Compiler #1081

Closed BlackRam-oss closed 2 months ago

BlackRam-oss commented 2 months ago

Describe the bug

Constants are not considered by the Compiler. the constant values ​​are not inserted into the compiler's Json

To Reproduce

const story = new Compiler(test).Compile();
let json = story.ToJson();
let obj: InkStoryType
try {
        obj = JSON.parse(json);
} catch (e) {
        console.error("[Pixi’VN Ink] Error parsing ink file")
        return
}

Expected behavior

Il valore della costante doveva essere inserito nel json

Ink files

CONST HASTINGS = "Hastings"
CONST POIROT = "Poirot"
CONST JAPP = "Japp"

VAR current_chief_suspect = HASTINGS

=== review_evidence ===
    { found_japps_bloodied_glove:
        ~ current_chief_suspect = POIROT
    }
    Current Suspect: {current_chief_suspect}
->DONE

=== found_japps_bloodied_glove
found_japps_bloodied_glove
->DONE

json:

{
inkVersion: 21,
listDefs: {},
root: [
  [
    [
      "done",
      {
        "#n": "g-0",
      },
    ],
    null,
  ],
  "done",
  {
    review_evidence: [
      "ev",
      {
        "CNT?": "found_japps_bloodied_glove",
      },
      "/ev",
      [
        {
          "->": ".^.b",
          c: true,
        },
        {
          b: [
            "\n",
            "ev",
            "str",
            "^Poirot",
            "/str",
            "/ev",
            {
              "VAR=": "current_chief_suspect",
              re: true,
            },
            {
              "->": ".^.^.^.4",
            },
            null,
          ],
        },
      ],
      "nop",
      "\n",
      "^Current Suspect: ",
      "ev",
      {
        "VAR?": "current_chief_suspect",
      },
      "out",
      "/ev",
      "\n",
      "done",
      null,
    ],
    found_japps_bloodied_glove: [
      "^found_japps_bloodied_glove",
      "\n",
      "done",
      {
        "#f": 1,
      },
    ],
    "global decl": [
      "ev",
      "str",
      "^Hastings",
      "/str",
      {
        "VAR=": "current_chief_suspect",
      },
      "/ev",
      "end",
      null,
    ],
  },
]
}

Environment