-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathhelmod.lua
89 lines (78 loc) · 1.93 KB
/
helmod.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
80
81
82
83
84
85
86
87
88
89
require "core.class"
require "core.defines"
require "core.logging"
require "core.elementGui"
require "player.playerController"
helmod = {}
--===========================
-- trace=4
-- debug=3
-- info=2
-- erro=1
-- nothing=0
Logging:new(0)
Logging.console = true
Logging.force = true
--===========================
function helmod:on_init(event)
self.name = "helmod"
--self.version = "0.1.1"
self.loaded = false;
self.playerController = PlayerController:new()
end
--===========================
function helmod:on_configuration_changed(data)
if not data or not data.mod_changes then
return
end
if data.mod_changes["helmod"] then
if global["HMModel"] ~= nil then
for _,player in pairs(global["HMModel"]) do
player.isActive = false;
end
end
self:on_init()
end
end
--===========================
function helmod:on_load(event)
if self.loaded ~= true then
self:on_init()
end
end
--===========================
function helmod:on_tick(event)
if game.tick ~= 0 and game.tick % 60 == 0 then
for key, player in pairs(game.players) do
self:init_playerController(player)
end
end
if game.tick % 300 == 0 then
Logging:write()
end
end
function helmod:init_playerController(player)
Logging:trace("helmod:init_playerController(player)")
local globalPlayer = self.playerController:getGlobal(player)
if globalPlayer.isActive == nil or globalPlayer.isActive == false then
if player.valid then
Logging:trace("bindController(player)")
self.playerController:bindController(player)
end
globalPlayer.isActive = true;
end
end
--===========================
function helmod:on_gui_click(event)
if self.playerController ~= nil then
local player = game.players[event.player_index]
if self.playerController ~= nil then
self.playerController:on_gui_click(event)
end
end
end
--===========================
function helmod:on_player_created(event)
local player = game.players[event.player_index]
self:init_playerController(player)
end