Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #2

Merged
merged 2 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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!