diff --git a/narrator/parser.lua b/narrator/parser.lua index 6247983..6245976 100644 --- a/narrator/parser.lua +++ b/narrator/parser.lua @@ -341,7 +341,7 @@ end function Constructor:addConstant(constant, value) local value = lume.deserialize(value) - self.book.constants[constant] = lume.deserialize(value) + self.book.constants[constant] = value end function Constructor:addKnot(knot) diff --git a/narrator/story.lua b/narrator/story.lua index a130844..76ebb84 100644 --- a/narrator/story.lua +++ b/narrator/story.lua @@ -46,9 +46,11 @@ end --- Start a story. -- Generate the first chunk of paragraphs and choices. function Story:begin() - if #self.paragraphs == 0 and #self.choices == 0 and not self.isOver then - self:readPath({ }) + if #self.paragraphs > 0 or #self.choices > 0 then + return end + + self:jumpTo('_') end --- Does the story have paragraphs to output or not. @@ -151,6 +153,8 @@ end function Story:jumpTo(pathString) assert(pathString, 'The pathString can\'t be nil') + self.choices = { } + if pathString == 'END' or pathString == 'DONE' then self.isOver = true return diff --git a/test/units/constants.ink b/test/units/constants.ink index 60e6db4..ceea880 100644 --- a/test/units/constants.ink +++ b/test/units/constants.ink @@ -1,12 +1,17 @@ +CONST STRING_EXAMPLE = "This is the string constant" +CONST BOOLEAN_EXAMLPE_TRUE = true +CONST BOOLEAN_EXAMLPE_FALSE = false + CONST LOBBY = 1 CONST STAIRCASE = 2 CONST HALLWAY = 3 - CONST HELD_BY_AGENT = -1 VAR secret_agent_location = LOBBY VAR suitcase_location = HALLWAY +{ STRING_EXAMPLE }. One is { BOOLEAN_EXAMLPE_TRUE }. Zero is { BOOLEAN_EXAMLPE_FALSE }. + -> report_progress === report_progress === diff --git a/test/units/constants.txt b/test/units/constants.txt index 6d434f6..84277c0 100644 --- a/test/units/constants.txt +++ b/test/units/constants.txt @@ -1,3 +1,4 @@ +This is the string constant. One is 1. Zero is 0. The secret agent moves forward. The secret agent moves forward. The secret agent grabs the suitcase! \ No newline at end of file