Vendor libs/hump, sfxrlua, json4lua, narrator as real files

These were committed as empty submodule gitlinks with no .gitmodules,
so the folders were never populated and the game could not load
(require of libs/hump/timer, libs/sfxrlua/sfxr, narrator.narrator).
Checked out each at its pinned commit and vendored the files, matching
the existing bundled-libs convention. Removed the junk libs/libs/ tree.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Your Name 2026-08-11 11:37:09 -04:00
parent e73f63b5d4
commit 03532d29e4
219 changed files with 20254 additions and 252 deletions

View file

@ -0,0 +1,42 @@
local narrator, describe, it, assert = ...
local content = [[
~ beep()
{ sum(1, 2) }
{ did_solve_puzzle("labirint") }
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
local is_beeped = false
local puzzles = { }
story:bind('beep', function()
is_beeped = true
end)
story:bind('sum', function(x, y)
return x + y
end)
story:bind('did_solve_puzzle', function(puzzle)
puzzles[puzzle] = true
end)
story:begin()
it('Was a beep?', function()
assert.is_true(is_beeped)
end)
it('Sum is equal to 3.', function()
local paragraphs = story:continue()
assert.equal(#paragraphs, 1)
assert.equal('3', paragraphs[1].text)
end)
it('Labirint is sovled.', function()
local puzzle_is_solved = puzzles['labirint']
assert.is_true(puzzle_is_solved)
end)

View file

@ -0,0 +1,30 @@
local narrator, describe, it, assert = ...
local content = [[
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
story:begin()
it('Get one paragraph.', function()
local paragraph = story:continue(1)
assert.equal(paragraph.text, 'Line 1')
end)
it('Get two paragraphs.', function()
local paragraphs = story:continue(2)
assert.equal(#paragraphs, 2)
end)
it('Get remain paragraphs.', function()
local paragraphs = story:continue()
assert.equal(#paragraphs, 3)
end)

View file

@ -0,0 +1,39 @@
local narrator, describe, it, assert = ...
local content = [[
A root line
=== knot
A knot line
= stitch
A stitch line
=== somewhere
- (label) A label line
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
story:begin()
local paragraphs = story:continue()
it('Jump to label.', function()
story:jump_to('somewhere.label')
local paragraphs = story:continue()
assert.equal(#paragraphs, 1)
assert.equal(paragraphs[1].text, 'A label line')
end)
it('Jump to stitch.', function()
story:jump_to('knot.stitch')
local paragraphs = story:continue()
assert.equal(#paragraphs, 1)
assert.equal(paragraphs[1].text, 'A stitch line')
end)
it('Jump to knot.', function()
story:jump_to('knot')
local paragraphs = story:continue()
assert.equal(#paragraphs, 1)
assert.equal(paragraphs[1].text, 'A knot line')
end)

View file

@ -0,0 +1,21 @@
local narrator, describe, it, assert = ...
local content = [[
VAR mood = "sadly"
~ mood = "sunny"
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
local mood
story:observe('mood', function(value)
mood = value
end)
story:begin()
it('Sunny mood.', function()
assert.equal(mood, 'sunny')
end)

View file

@ -0,0 +1,59 @@
local narrator, describe, it, assert = ...
local content = [[
VAR x = 1
* (choice) [Hello]
- (hello) Hello world!
-> knot
=== knot
= stitch
~ x = 2
~ temp y = 3
A line 1
A line 2
A line 3
* Just a road to hell -> END
* The best road to hell -> END
]]
local book = narrator.parse_content(content)
local saved_state
it('Saving', function()
local story = narrator.init_story(book)
story:begin()
story:continue()
story:choose(1)
story:continue(2)
saved_state = story:save_state()
local expected_path = { knot = 'knot', stitch = 'stitch' }
assert.are.same(saved_state.path, expected_path)
assert.equal(saved_state.variables['x'], 2)
assert.equal(saved_state.temp['y'], 3)
assert.equal(saved_state.visits._._.hello, 1)
assert.equal(#saved_state.output, 2)
assert.equal(#saved_state.paragraphs, 2)
assert.equal(#saved_state.choices, 2)
end)
it('Loading.', function()
local story = narrator.init_story(book)
story:begin()
story:load_state(saved_state)
local expected_path = { knot = 'knot', stitch = 'stitch' }
assert.are.same(story.current_path, expected_path)
assert.equal(story.variables['x'], 2)
assert.equal(story.temp['y'], 3)
assert.equal(story:get_visits('hello'), 1)
assert.equal(#story.output, 2)
local paragraphs = story:continue()
local choices = story:get_choices()
assert.equal(#paragraphs, 2)
assert.equal(#choices, 2)
end)

View file

@ -0,0 +1,30 @@
local narrator, describe, it, assert = ...
local content = [[
VAR x = 1
* [Change x to 1]
* [Change x to 2]
* [Change x to 3]
x = { x }
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
story:begin()
it('The x is equal to 1.', function()
local x = story.variables['x']
assert.equal(x, 1)
end)
it('The x is changed to 3.', function()
local answer = 3
story.variables['x'] = answer
story:choose(answer)
local paragraphs = story:continue()
assert.equal(#paragraphs, 1)
assert.equal(paragraphs[1].text, 'x = 3')
end)

View file

@ -0,0 +1,51 @@
local narrator, describe, it, assert = ...
local content = [[
# global tag 1
# global tag 2 # global tag 3
Root line -> knot
=== knot ===
# knot tag
A knot line 1 # line 1 tag
A knot line 2 # line 2 tag
= stitch
# stitch tag
A stitch line # line 3 tag
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
story:begin()
local paragraphs = story:continue()
it('Global tags.', function()
local expected = { 'global tag 1', 'global tag 2', 'global tag 3' }
assert.are.same(expected, story.global_tags)
local global_tags = story:get_tags()
assert.are.same(expected, global_tags)
end)
it('Knot tags.', function()
local expected = { 'knot tag' }
local knot_tags = story:get_tags('knot')
assert.are.same(expected, knot_tags)
end)
it('Stitch tags.', function()
local expected = { 'stitch tag' }
local stitch_tags = story:get_tags('knot.stitch')
assert.are.same(expected, stitch_tags)
end)
it('Paragraph tags.', function()
assert.equal(#paragraphs, 2)
local expected = { 'global tag 1', 'global tag 2', 'global tag 3', 'knot tag', 'line 1 tag' }
assert.are.same(expected, paragraphs[1].tags)
local expected = { 'line 2 tag' }
assert.are.same(expected, paragraphs[2].tags)
end)

View file

@ -0,0 +1,65 @@
local narrator, describe, it, assert = ...
local content = [[
A root text
+ Go to knot -> knot
=== knot
+ Go to stitch -> stitch
= stitch
+ Go to label -> label
- (label) Some text
+ (choice) Go to root -> _._
]]
local book = narrator.parse_content(content)
local story = narrator.init_story(book)
story:begin()
local function visits()
local visits = {
root = story:get_visits(''),
knot = story:get_visits('knot'),
stitch = story:get_visits('knot.stitch'),
label = story:get_visits('knot.stitch.label'),
choice = story:get_visits('knot.stitch.choice')
}
return visits
end
local places = { 'root', 'knot', 'stitch', 'label' }
for cycle = 1, 3 do
describe('Visits with cycle ' .. cycle .. '.', function()
story:continue()
for place_index = 1, #places do
local place = places[place_index]
it('Visit the ' .. place .. '.', function()
story:continue()
local place = place
local divert = story.choices[1].divert
local expected_root = cycle
local expected_knot = place_index > 1 and cycle or cycle - 1
local expected_stitch = place_index > 2 and cycle or cycle - 1
local expected_label = place_index > 3 and cycle or cycle - 1
local expected_choice = place_index > 4 and cycle or cycle - 1
local visits = visits()
assert.equal(visits.root, expected_root)
assert.equal(visits.knot, expected_knot)
assert.equal(visits.stitch, expected_stitch)
assert.equal(visits.label, expected_label)
assert.equal(visits.choice, expected_choice)
story:choose(1)
end)
end
end)
end