forked from LIKO-12/LIKO-12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autorun.lua
76 lines (61 loc) · 1.86 KB
/
autorun.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
local Editor = require("editor") --Require the editor
local Terminal = require("terminal")
local RT = require("runtime")
local Active
local EActive = false --Editor Active
local GActive = false --Game Active
local GStarted = false
function _auto_init() --I have to seperate the autorun callbacks from the main ones so games can override the original ones without destroying these.
api.setCursor("normal")
Terminal:_init()
Editor:_init()
RT:_init()
Active = Terminal
if Active._redraw then Active:_redraw() end
end
function _auto_exitgame()
Active = EActive and Editor or Terminal
if Active._redraw then Active:_redraw() end
GActive = false
end
function _auto_switchgame()
GActive, GStarted, Active = true, false, RT
--RT:startGame()
end
function _auto_update(dt)
if (not GStarted) and GActive then GStarted = true RT:startGame() end
if Active._update then Active:_update(dt) end
end
function _auto_mpress(...)
if Active._mpress then Active:_mpress(...) end
end
function _auto_mmove(...)
if Active._mmove then Active:_mmove(...) end
end
function _auto_mrelease(...)
if Active._mrelease then Active:_mrelease(...) end
end
function _auto_tpress(...)
if Active._tpress then Active:_tpress(...) end
end
function _auto_tmove(...)
if Active._tmove then Active:_tmove(...) end
end
function _auto_trelease(...)
if Active._trelease then Active:_trelease(...) end
end
function _auto_kpress(k,sc,ir)
if k == "escape" then
api.setCursor("normal")
if not GActive then EActive = not EActive else GActive = false end
if EActive then Active = Editor else Active = Terminal end
if Active._redraw then Active:_redraw() end
end
if Active._kpress then Active:_kpress(k,sc,ir) end
end
function _auto_krelease(...)
if Active._krelease then Active:_krelease(...) end
end
function _auto_tinput(t)
if Active._tinput then Active:_tinput(t) end
end