mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
refactor(points): support single argument for lib.points.new
This commit is contained in:
@@ -55,18 +55,30 @@ CreateThread(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
new = function(coords, distance, data)
|
new = function(...)
|
||||||
|
local args = {...}
|
||||||
local id = #points + 1
|
local id = #points + 1
|
||||||
|
local self
|
||||||
|
|
||||||
local self = {
|
-- Support sending a single argument containing point data
|
||||||
id = id,
|
if type(args[1]) == 'table' then
|
||||||
coords = coords,
|
self = args[1]
|
||||||
distance = distance,
|
self.id = id
|
||||||
remove = removePoint,
|
self.remove = removePoint
|
||||||
}
|
else
|
||||||
|
-- Backwards compatibility for original implementation (args: coords, distance, data)
|
||||||
|
self = {
|
||||||
|
id = id,
|
||||||
|
coords = args[1],
|
||||||
|
remove = removePoint,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
if data then
|
|
||||||
for k, v in pairs(data) do
|
self.distance = self.distance or args[2]
|
||||||
|
|
||||||
|
if args[3] then
|
||||||
|
for k, v in pairs(args[3]) do
|
||||||
self[k] = v
|
self[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user