Skip to content

Commit

Permalink
Merge pull request #2 from astrochili/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
astrochili authored Feb 3, 2021
2 parents 458387a + a4dde19 commit 1e47cc9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion narrator/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions narrator/story.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion test/units/constants.ink
Original file line number Diff line number Diff line change
@@ -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 ===
Expand Down
1 change: 1 addition & 0 deletions test/units/constants.txt
Original file line number Diff line number Diff line change
@@ -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!

0 comments on commit 1e47cc9

Please sign in to comment.