diff --git a/INDEV/Battle Royale.lua b/INDEV/Battle Royale.lua index d34e6215..1619a06a 100644 --- a/INDEV/Battle Royale.lua +++ b/INDEV/Battle Royale.lua @@ -110,7 +110,7 @@ function BattleRoyale:loadDependencies() end) if (not success) then - cprint('[TRUCE] FILE DEPENDENCY NOT FOUND: ' .. path .. file .. '.lua', 12) + cprint('[BATTLE ROYALE] FILE DEPENDENCY NOT FOUND: ' .. path .. file .. '.lua', 12) goto next end @@ -129,11 +129,15 @@ function BattleRoyale:loadDependencies() setmetatable(s, { __index = f }) s = f + _G[file] = path:find('events/') and function(...) + return f[file](self, ...) + end or nil + :: next :: end end - self:onStart() -- in case the plugin loads mid-game + self:on_start() -- in case the plugin loads mid-game end api_version = '1.12.0.0' @@ -142,62 +146,10 @@ function OnScriptLoad() BattleRoyale:loadDependencies() end -function OnStart() - BattleRoyale:onStart() -end - -function OnEnd() - BattleRoyale:onEnd() -end - -function OnJoin(...) - BattleRoyale:onJoin(...) -end - -function OnQuit(...) - BattleRoyale:onQuit(...) -end - -function OnPreSpawn(...) - BattleRoyale:onPreSpawn(...) -end - -function OnSpawn(...) - BattleRoyale:onSpawn(...) -end - -function OnTick() - BattleRoyale:onTick() -end - -function OnDeath(...) - BattleRoyale:onDeath(...) -end - -function OnPickup(...) - return BattleRoyale:onPickup(...) -end - -function OnDrop(...) - return BattleRoyale:onDrop(...) -end - -function OnCommand(...) - return BattleRoyale:onCommand(...) -end - -function OnObjectSpawn(...) - return BattleRoyale:onObjectSpawn(...) -end - -function OnDamage(...) - return BattleRoyale:onDamage(...) +function OnScriptUnload() + -- N/A end function OnError() print(debug.traceback()) -end - -function OnScriptUnload() - -- N/A end \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_command.lua b/INDEV/Battle Royale/events/on_command.lua index 737f391a..458d365c 100644 --- a/INDEV/Battle Royale/events/on_command.lua +++ b/INDEV/Battle Royale/events/on_command.lua @@ -13,7 +13,7 @@ end -- @param id (player id) -- @param command (command string) -- @return false (to prevent sapp from spamming 'unknown command' error.) -function event:onCommand(id, command) +function event:on_command(id, command) local args = stringSplit(command) local cmd = self.cmds[args[1]] @@ -31,6 +31,6 @@ function event:onCommand(id, command) return true end -register_callback(cb['EVENT_COMMAND'], 'OnCommand') +register_callback(cb['EVENT_COMMAND'], 'on_command') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_damage.lua b/INDEV/Battle Royale/events/on_damage.lua index 90ad33c4..fe9e5df1 100644 --- a/INDEV/Battle Royale/events/on_damage.lua +++ b/INDEV/Battle Royale/events/on_damage.lua @@ -1,7 +1,7 @@ local event = {} -- Prevent spectators from damaging (or being damaged) by other players: -function event:onDamage(victim, killer, meta_id, damage) +function event:on_damage(victim, killer, meta_id, damage) local v = tonumber(victim) local k = tonumber(killer) @@ -44,6 +44,6 @@ function event:onDamage(victim, killer, meta_id, damage) return true, damage end -register_callback(cb['EVENT_DAMAGE_APPLICATION'], 'OnDamage') +register_callback(cb['EVENT_DAMAGE_APPLICATION'], 'on_damage') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_death.lua b/INDEV/Battle Royale/events/on_death.lua index 3c15d980..fe46c065 100644 --- a/INDEV/Battle Royale/events/on_death.lua +++ b/INDEV/Battle Royale/events/on_death.lua @@ -19,7 +19,7 @@ local function endGame(self) return false end -function event:onDeath(victim) +function event:on_death(victim) if (not self.game or not self.game.started) then return @@ -60,6 +60,6 @@ function event:onDeath(victim) victim:newMessage('You have ' .. victim.lives .. ' ' .. life .. ' remaining', 5) end -register_callback(cb['EVENT_DIE'], 'OnDeath') +register_callback(cb['EVENT_DIE'], 'on_death') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_drop.lua b/INDEV/Battle Royale/events/on_drop.lua index a0974cf0..7cf01f8c 100644 --- a/INDEV/Battle Royale/events/on_drop.lua +++ b/INDEV/Battle Royale/events/on_drop.lua @@ -1,9 +1,9 @@ local event = {} -function event:onDrop(id) +function event:on_drop(id) end -register_callback(cb['EVENT_WEAPON_DROP'], 'OnDrop') +register_callback(cb['EVENT_WEAPON_DROP'], 'on_drop') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_end.lua b/INDEV/Battle Royale/events/on_end.lua index b05445a8..0934bd8e 100644 --- a/INDEV/Battle Royale/events/on_end.lua +++ b/INDEV/Battle Royale/events/on_end.lua @@ -1,10 +1,10 @@ local event = {} -function event:onEnd() +function event:on_end() self.game = nil self.safe_zone = nil end -register_callback(cb['EVENT_GAME_END'], 'OnEnd') +register_callback(cb['EVENT_GAME_END'], 'on_end') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_join.lua b/INDEV/Battle Royale/events/on_join.lua index 743e1dc1..51e72a67 100644 --- a/INDEV/Battle Royale/events/on_join.lua +++ b/INDEV/Battle Royale/events/on_join.lua @@ -14,7 +14,7 @@ function event:newPlayer(o) return o end -function event:onJoin(id) +function event:on_join(id) self.players[id] = self:newPlayer({ id = id, @@ -24,6 +24,6 @@ function event:onJoin(id) self:phaseCheck(false, id) end -register_callback(cb['EVENT_JOIN'], 'OnJoin') +register_callback(cb['EVENT_JOIN'], 'on_join') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_object_spawn.lua b/INDEV/Battle Royale/events/on_object_spawn.lua index 4bb7f72e..5e97719e 100644 --- a/INDEV/Battle Royale/events/on_object_spawn.lua +++ b/INDEV/Battle Royale/events/on_object_spawn.lua @@ -1,6 +1,6 @@ local event = {} -function event:onObjectSpawn(player, map_id, parent_id, object_id, sapp_spawning) +function event:on_object_spawn(player, map_id, parent_id, object_id, sapp_spawning) if (not sapp_spawning) then -- not currently used @@ -92,6 +92,6 @@ function event:trackNuke() end end -register_callback(cb['EVENT_OBJECT_SPAWN'], 'OnObjectSpawn') +register_callback(cb['EVENT_OBJECT_SPAWN'], 'on_object_spawn') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_pickup.lua b/INDEV/Battle Royale/events/on_pickup.lua index 38082625..b6b252d3 100644 --- a/INDEV/Battle Royale/events/on_pickup.lua +++ b/INDEV/Battle Royale/events/on_pickup.lua @@ -1,9 +1,9 @@ local event = {} -function event:onPickup(id) +function event:on_pickup(id) end -register_callback(cb['EVENT_WEAPON_PICKUP'], 'OnPickup') +register_callback(cb['EVENT_WEAPON_PICKUP'], 'on_pickup') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_pre_spawn.lua b/INDEV/Battle Royale/events/on_pre_spawn.lua index d101de0d..559638aa 100644 --- a/INDEV/Battle Royale/events/on_pre_spawn.lua +++ b/INDEV/Battle Royale/events/on_pre_spawn.lua @@ -1,6 +1,6 @@ local event = {} -function event:onPreSpawn(id) +function event:on_pre_spawn(id) local player = self.players[id] if (not player) then @@ -13,6 +13,6 @@ function event:onPreSpawn(id) self.players[id]:teleport(true, true) end -register_callback(cb['EVENT_PRESPAWN'], 'OnPreSpawn') +register_callback(cb['EVENT_PRESPAWN'], 'on_pre_spawn') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_quit.lua b/INDEV/Battle Royale/events/on_quit.lua index 22f9bb0a..fd5a15f4 100644 --- a/INDEV/Battle Royale/events/on_quit.lua +++ b/INDEV/Battle Royale/events/on_quit.lua @@ -1,12 +1,12 @@ local event = {} -function event:onQuit(id) +function event:on_quit(id) self:phaseCheck(true, id) self.players[id] = nil end -register_callback(cb['EVENT_LEAVE'], 'OnQuit') +register_callback(cb['EVENT_LEAVE'], 'on_quit') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_spawn.lua b/INDEV/Battle Royale/events/on_spawn.lua index 3556349c..d611dd2b 100644 --- a/INDEV/Battle Royale/events/on_spawn.lua +++ b/INDEV/Battle Royale/events/on_spawn.lua @@ -1,6 +1,6 @@ local event = {} -function event:onSpawn(id) +function event:on_spawn(id) local player = self.players[id] if (not player) then @@ -54,6 +54,6 @@ function event:onSpawn(id) end end -register_callback(cb['EVENT_SPAWN'], 'OnSpawn') +register_callback(cb['EVENT_SPAWN'], 'on_spawn') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_start.lua b/INDEV/Battle Royale/events/on_start.lua index 77f7509d..96d156f0 100644 --- a/INDEV/Battle Royale/events/on_start.lua +++ b/INDEV/Battle Royale/events/on_start.lua @@ -1,11 +1,11 @@ local event = {} -function event:onStart() +function event:on_start() if (get_var(0, '$gt') ~= 'n/a') then self:initialize() end end -register_callback(cb['EVENT_GAME_START'], 'OnStart') +register_callback(cb['EVENT_GAME_START'], 'on_start') return event \ No newline at end of file diff --git a/INDEV/Battle Royale/events/on_tick.lua b/INDEV/Battle Royale/events/on_tick.lua index 58edb7cf..f0042179 100644 --- a/INDEV/Battle Royale/events/on_tick.lua +++ b/INDEV/Battle Royale/events/on_tick.lua @@ -24,7 +24,7 @@ local function UpdateVectors(object, x, y, z) write_float(object + 0x94, 0) -- roll end -function event:onTick() +function event:on_tick() self:preGameTimer() -- pre-game timer self:landing() -- sky spawning / god mode timer @@ -66,6 +66,6 @@ function event:onTick() --end end -register_callback(cb['EVENT_TICK'], 'OnTick') +register_callback(cb['EVENT_TICK'], 'on_tick') return event \ No newline at end of file