-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.lua
More file actions
60 lines (52 loc) · 1.62 KB
/
lib.lua
File metadata and controls
60 lines (52 loc) · 1.62 KB
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
local lib = {}
Registry.registerGlobal("SKME", lib)
SKME = lib
function lib.stub(text, quiet)
local info = debug.getinfo(2)
return function ()
if not quiet then
Assets.stopAndPlaySound("awkward")
end
Kristal.Console:log("STUB: "..text .. " ("..(info.short_src..":"..info.currentline)..")")
end
end
function lib:init()
for class, meta in pairs(libRequire("skme", "builtinmetas")) do
Utils.hook(class, "EDITOR_METADATA", meta, true)
end
end
function lib:onKeyPressed(key)
if Input.ctrl() and key == "e" then
self:openEditor()
end
end
function lib:openEditor()
if Kristal.getState() == Game then
if Game.state == "OVERWORLD" and Game.world.state == "GAMEPLAY" and Game.world.map.data.format == "skme" then
return Kristal.pushState(Editor)
end
return false, "Must be in the overworld, during normal gameplay, on an SKME map."
end
end
function lib:unload()
if Kristal.getState() == Editor then
Kristal.popState()
-- Try to pop the state anyway.
elseif pcall(Kristal.popState) then
-- If succeded, we're probably now in Game. Not good!
Kristal.setState("Empty")
end
end
function lib:onMousePressed(x, y, button, istouch, presses)
local state = Kristal.getState()
if state.onMousePressed then
state:onMousePressed(x, y, button, istouch, presses)
end
end
function lib:onMouseReleased(x, y, button, istouch, presses)
local state = Kristal.getState()
if state.onMouseReleased then
state:onMouseReleased(x, y, button, istouch, presses)
end
end
return lib