diff --git a/package.json b/package.json index e2b82690..49f53a25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "inkjs", - "version": "2.2.2", + "version": "2.2.3", "description": "A javascript port of inkle's ink scripting language (http://www.inklestudios.com/ink/)", "main": "dist/ink-full.js", "types": "ink.d.ts", diff --git a/src/engine/Story.ts b/src/engine/Story.ts index 50429b8f..ea74618d 100644 --- a/src/engine/Story.ts +++ b/src/engine/Story.ts @@ -1230,7 +1230,7 @@ export class Story extends InkObject { this.state.PopFromOutputStream(outputCountConsumed); // Build string out of the content we collected let sb = new StringBuilder(); - for (let strVal of contentStackForTag) { + for (let strVal of contentStackForTag.reverse()) { sb.Append(strVal.toString()); } let choiceTag = new Tag( diff --git a/src/tests/inkfiles/original/choices/dynamic_tags_in_choice.ink b/src/tests/inkfiles/original/choices/dynamic_tags_in_choice.ink new file mode 100644 index 00000000..740ff4b5 --- /dev/null +++ b/src/tests/inkfiles/original/choices/dynamic_tags_in_choice.ink @@ -0,0 +1,4 @@ +VAR var1 = "aaa" +VAR var2 = "bbb" + ++[choice #tag {var1}{var2}] \ No newline at end of file diff --git a/src/tests/specs/ink/Choices.spec.ts b/src/tests/specs/ink/Choices.spec.ts index cf4c31d0..41c5fd0f 100644 --- a/src/tests/specs/ink/Choices.spec.ts +++ b/src/tests/specs/ink/Choices.spec.ts @@ -278,4 +278,15 @@ describe("Choices", () => { expect(context.story.Continue()).toBe("one three"); expect(context.story.currentTags).toEqual(["one", "three"]); }); + + //TestDynanicTagsInChoice + it("tests tags in choice", () => { + compileStory("dynamic_tags_in_choice", true); + context.story.Continue(); + + expect(context.story.currentTags.length).toBe(0); + expect(context.story.currentChoices.length).toBe(1); + expect(context.story.currentChoices[0].text).toEqual("choice"); + expect(context.story.currentChoices[0].tags).toEqual(["tag aaabbb"]); + }); });