mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-11-29 07:46:52 +01:00
Full Distribution
This commit is contained in:
43
data/global.lua
Normal file
43
data/global.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
dofile('data/lib/lib.lua')
|
||||
|
||||
function getDistanceBetween(firstPosition, secondPosition)
|
||||
local xDif = math.abs(firstPosition.x - secondPosition.x)
|
||||
local yDif = math.abs(firstPosition.y - secondPosition.y)
|
||||
local posDif = math.max(xDif, yDif)
|
||||
if firstPosition.z ~= secondPosition.z then
|
||||
posDif = posDif + 15
|
||||
end
|
||||
return posDif
|
||||
end
|
||||
|
||||
function getFormattedWorldTime()
|
||||
local worldTime = getWorldTime()
|
||||
local hours = math.floor(worldTime / 60)
|
||||
|
||||
local minutes = worldTime % 60
|
||||
if minutes < 10 then
|
||||
minutes = '0' .. minutes
|
||||
end
|
||||
return hours .. ':' .. minutes
|
||||
end
|
||||
|
||||
string.split = function(str, sep)
|
||||
local res = {}
|
||||
for v in str:gmatch("([^" .. sep .. "]+)") do
|
||||
res[#res + 1] = v
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
string.trim = function(str)
|
||||
return str:match'^()%s*$' and '' or str:match'^%s*(.*%S)'
|
||||
end
|
||||
|
||||
table.contains = function(array, value)
|
||||
for _, targetColumn in pairs(array) do
|
||||
if targetColumn == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
Reference in New Issue
Block a user