-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
76 lines (57 loc) · 1.76 KB
/
main.lua
File metadata and controls
76 lines (57 loc) · 1.76 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
PLUGIN = nil
Timer = {}
function Initialize(Plugin)
Plugin:SetName("EarthTweaks")
Plugin:SetVersion(1)
PLUGIN = Plugin
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
-- Timer Setup
Timer = {}
Timer.__index = Timer
local timers = {}
local timerID = 0
function Timer:New(sec, func)
func = func or function() LOGERROR("A timer with no function has been provided!") return end;
sec = sec or 30
local self = setmetatable({Function = func, SetTime = sec*60, CurrentTime = 0}, Timer)
table.insert(timers, self)
return self
end
function Timer:ChangeDelay(sec)
self.SetTime = sec*60
end
function Timer:Run()
if type(self.Function) == "function" then
self.Function()
end
end
-- Ticker
local function onTick()
for _, v in pairs(timers) do
if v.CurrentTime % v.SetTime == 0 and v.CurrentTime % 20 == 0 then
Timer.Run(v)
v.CurrentTime = 0
end
v.CurrentTime = v.CurrentTime + 1
end
end
---- Functions
local function catatumbo()
local x = math.random(-8593, -8583/CONFIG.MAPDIV)
local y = 62
local z = math.random(-1115, -1105/CONFIG.MAPDIV)
cRoot:Get():GetWorld(CONFIG.WORLD_NAME):CastThunderbolt(Vector3i(x, y, z))
end
---- Timers
local catatumbo_t = Timer:New(3, catatumbo)
-- Randomizes Catatumbo lighting strike time
Timer:New(60, function()
catatumbo_t:ChangeDelay(math.random(3,10))
end)
---- Hooks
cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, onTick)
return true
end
function OnDisable()
LOG(PLUGIN:GetName() .. " is shutting down...")
end