2018-04-06 21:58:50 +02:00
|
|
|
local Event = require "utils.event"
|
|
|
|
|
2018-06-02 18:16:04 +02:00
|
|
|
local Module = {}
|
2017-06-13 13:16:07 +02:00
|
|
|
|
2018-06-02 18:16:04 +02:00
|
|
|
Module.distance = function(pos1, pos2)
|
2017-06-13 13:16:07 +02:00
|
|
|
local dx = pos2.x - pos1.x
|
|
|
|
local dy = pos2.y - pos1.y
|
2018-06-02 18:16:04 +02:00
|
|
|
return math.sqrt(dx * dx + dy * dy)
|
2017-06-13 13:16:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- rounds number (num) to certain number of decimal places (idp)
|
2018-06-02 18:16:04 +02:00
|
|
|
math.round = function(num, idp)
|
2017-06-13 13:16:07 +02:00
|
|
|
local mult = 10 ^ (idp or 0)
|
|
|
|
return math.floor(num * mult + 0.5) / mult
|
|
|
|
end
|
|
|
|
|
2018-06-02 18:16:04 +02:00
|
|
|
Module.print_except = function(msg, player)
|
2017-11-09 21:28:56 +02:00
|
|
|
for _,p in pairs(game.players) do
|
|
|
|
if p.connected and p ~= player then
|
|
|
|
p.print(msg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-02 18:16:04 +02:00
|
|
|
Module.print_admins = function(msg)
|
2017-11-09 21:28:56 +02:00
|
|
|
for _,p in pairs(game.players) do
|
|
|
|
if p.connected and p.admin then
|
|
|
|
p.print(msg)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-06-02 17:17:54 +02:00
|
|
|
|
2018-06-02 18:16:04 +02:00
|
|
|
Module.get_actor = function()
|
2018-06-02 17:17:54 +02:00
|
|
|
if game.player then return game.player.name end
|
|
|
|
return "<server>"
|
|
|
|
end
|