This repository has been archived by the owner on May 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.lua
79 lines (60 loc) · 2.14 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--[[
The main file required by LÖVE. We do not use this for anything in
LNVL except debugging, since we ship out LNVL as a library for
other programs to use and not really an executable on its own.
It reads an optional script filename from the command-line and
loads that. If none is given then it loads a simple example.
The enter and backspace keys move back and forth through the text.
----]]
local LNVL = require("LNVL")
LNVL.Initialize()
LNVL.Debug.Log.trace("LNVL Version " .. tostring(LNVL.Version))
-- These globals exists to help test Context objects.
local keyword = [["Foo"]]
local password = [["LobbyWasHere"]]
function love.load(arguments)
love.window.setMode(LNVL.Settings.Screen.Width, LNVL.Settings.Screen.Height)
love.graphics.setBackgroundColor(LNVL.Color.Black)
local dumpOnly = false
for index,value in ipairs(arguments) do
if value == "--dump-only" then
dumpOnly = true
table.remove(arguments, index)
end
end
local extraData = LNVL.Context:new()
extraData:add("password", password)
-- This is for examples/20-StringInterpolation.lua
extraData:add("ClosingRemark", "Have a wonderful day!")
if #arguments > 1 then
LNVL.LoadScript(arguments[2], extraData)
else
LNVL.LoadScript("examples/02-TwoCharacters.lua", extraData)
end
-- If we ran the test for temporary characters then we make sure
-- the character defined in that script was destroyed at its
-- conclusion.
if arguments[2] == "examples/23-TemporaryCharacters.lua" then
assert(LNVL.ScriptEnvironment["Lobby"] == nil)
end
if LNVL.Settings.DebugModeEnabled == true then
LNVL.Debug.DumpScriptEnvironment()
end
LNVL.Debug.Log.trace("New password: " .. LNVL.ScriptEnvironment["password"])
if dumpOnly == true then
love.event.quit()
end
end
function love.keypressed(key)
if key == "return" then
LNVL.Advance()
elseif key == "backspace" then
LNVL.CurrentScene:moveBack()
end
end
function love.draw()
LNVL.CurrentScene:draw()
end
function love.update(dt)
LNVL.Graphics.DrawAndUpdate(dt)
end