Files
ogre-prototype/lua-scripts/data.lua

134 lines
3.7 KiB
Lua

function foo()
tree()
.node("p1", Quaternion(), Vector3(0, 0, -200))
.entity("b1", "residental-house1.glb")
.endnode()
.node("p2", Quaternion(), Vector3(0, 0, -150))
.entity("residental-house1.glb")
.endnode()
.node("p3", Quaternion(), Vector3(0, 0, -100))
.entity("residental-house1.glb")
.endnode()
.node("p4", Quaternion(), Vector3(0, 0, -50))
.entity("residental-house1.glb")
.endnode()
.node("p5", Quaternion(), Vector3(0, 0, 50))
.entity("residental-house1.glb")
.endnode()
.node("p6", Quaternion(), Vector3(0, 0, 100))
.entity("residental-house1.glb")
.endnode()
.node("p7", Quaternion(), Vector3(0, 0, 150))
.entity("residental-house2.glb")
.endnode()
.node("p8", Quaternion(), Vector3(0, 0, 200))
.entity("residental-house3.glb")
.endnode()
for x = -1000, 1000, 50 do
for z = -1000, 1000, 50 do
if not ((x >-100 and x < 100) and (z > -100 and z < 100)) then
tree()
.node("p00" .. tostring(x * 1000 + z), Quaternion(), Vector3(x, 0, z))
.entity("residental-house2.glb")
.endnode()
end
end
end
v = Vector3(0, 1, 2)
end
--[[
narration = {
position = 1,
narration_start = {
"The party was hot, girls were sexy the wine, beer and whisky were in \
enormous numbers. It was anniversary since you set sail with your friends. \
The sea was calm and everything promised you another great night.",
"The whole year with your friends on your ship over vast seas of the world in decay was almost over.\
It was so good year full of adventure, romance, indecency and luxury.",
"Your trusted friends decided that you have too much, they have too much of you and you owe them a lot.",
"They found you drunk in your room and moved to the deck and used ropes to \
restrain you and attach a bucket of stones or something else heavy to your body.",
"After a few hours passed two strong people pulled you to the side and \
dropped you into the sea. Last thing you heard before you hit the water was happy laugher..."
},
progress = function(this)
if #this.narration_start < this.position then
return ""
end
local ret = this.narration_start[this.position]
this.position = this.position + 1
return ret
end,
}
]]--
local narrator = require('narrator.narrator')
-- Parse a book from the Ink file.
local book = narrator.parse_file('stories.game')
-- Init a story from the book
local story = narrator.init_story(book)
-- Begin the story
story:begin()
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
function _narration()
local ret = ""
local choices = {}
if story:can_continue() then
local paragraphs = story:continue()
for _, paragraph in ipairs(paragraphs) do
local text = paragraph.text
if paragraph.tags then
text = text .. ' #' .. table.concat(paragraph.tags, ' #')
end
ret = ret .. text
end
if story:can_choose() then
local ch = story:get_choices()
for i, choice in ipairs(ch) do
table.insert(choices, choice.text)
print(i, dump(choice))
end
end
end
if (#choices > 0) then
print("choices!!!")
narrate(ret, choices)
else
narrate(ret)
end
end
setup_handler(function(event)
print(event)
if event == "startup" then
main_menu()
elseif event == "narration_progress" then
_narration()
elseif event == "narration_answered" then
local answer = narration_get_answer()
story:choose(answer)
_narration()
elseif event == "new_game" then
local ret = ""
story = narrator.init_story(book)
story:begin()
_narration()
end
end)