add compator sleeplessinteract v2 (this is very nice)
Well done demi
This commit is contained in:
1 parent
cad3604e4d
commit
87ce06a61f
1 file changed
+116
-19
@@ -2,17 +2,21 @@ local resourceName = "sleepless_interact"
|
|||||||
local configValue = BridgeClientConfig.TargetSystem
|
local configValue = BridgeClientConfig.TargetSystem
|
||||||
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
|
if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end
|
||||||
|
|
||||||
--if GetResourceState('sleepless_interact') ~= 'started' then return end
|
|
||||||
-- This is only partially supported
|
|
||||||
|
|
||||||
local sleepless = exports.sleepless_interact
|
local targetDebug = false
|
||||||
|
local function detectDebugEnabled()
|
||||||
|
if BridgeClientConfig.DebugLevel == 2 then
|
||||||
|
targetDebug = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
detectDebugEnabled()
|
||||||
|
|
||||||
|
local sleepless_interact = exports.sleepless_interact
|
||||||
|
local targetZones = {}
|
||||||
|
|
||||||
Target = Target or {}
|
Target = Target or {}
|
||||||
|
|
||||||
Target.DisableTargeting = function(bool)
|
|
||||||
-- nothing to see here
|
|
||||||
end
|
|
||||||
|
|
||||||
Target.FixOptions = function(options)
|
Target.FixOptions = function(options)
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
local action = v.onSelect or v.action
|
local action = v.onSelect or v.action
|
||||||
@@ -27,18 +31,111 @@ Target.FixOptions = function(options)
|
|||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.AddLocalEntity = function(entity, _options)
|
---comment
|
||||||
local options = Target.FixOptions(_options)
|
---@param options table
|
||||||
sleepless:addLocalEntity({
|
---@return nil
|
||||||
id = entity,
|
Target.AddGlobalPlayer = function(options)
|
||||||
entity = entity,
|
options = Target.FixOptions(options)
|
||||||
options = options,
|
sleepless_interact:addGlobalPlayer(options)
|
||||||
renderDistance = 10.0,
|
|
||||||
activeDistance = 2.0,
|
|
||||||
cooldown = 1500
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.RemoveLocalEntity = function(entity)
|
Target.DisableTargeting = function(bool)
|
||||||
sleepless:removeLocalEntity(entity)
|
--sleepless_interact:disableTargeting(bool)
|
||||||
|
sleepless_interact:disableInteract(bool)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param options table
|
||||||
|
---@return nil
|
||||||
|
Target.AddGlobalVehicle = function(options)
|
||||||
|
options = Target.FixOptions(options)
|
||||||
|
sleepless_interact:addGlobalVehicle(options)
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param options table
|
||||||
|
---@return nil
|
||||||
|
Target.RemoveGlobalVehicle = function(options)
|
||||||
|
local assembledLables = {}
|
||||||
|
for k, v in pairs(options) do
|
||||||
|
table.insert(assembledLables, v.name)
|
||||||
|
end
|
||||||
|
sleepless_interact:removeGlobalVehicle(assembledLables)
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param entities table
|
||||||
|
---@param options table
|
||||||
|
---@return nil
|
||||||
|
Target.AddLocalEntity = function(entities, options)
|
||||||
|
options = Target.FixOptions(options)
|
||||||
|
sleepless_interact:addLocalEntity(entities, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param models table
|
||||||
|
---@param options table
|
||||||
|
---@return nil
|
||||||
|
Target.AddModel = function(models, options)
|
||||||
|
options = Target.FixOptions(options)
|
||||||
|
sleepless_interact:addModel(models, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param name string
|
||||||
|
---@param coords table
|
||||||
|
---@param size table
|
||||||
|
---@param heading number
|
||||||
|
---@param options table
|
||||||
|
---@return number
|
||||||
|
Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||||
|
options = Target.FixOptions(options)
|
||||||
|
local target = sleepless_interact:addCoords({
|
||||||
|
coords = coords,
|
||||||
|
options = options,
|
||||||
|
})
|
||||||
|
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
|
||||||
|
return target
|
||||||
|
end
|
||||||
|
|
||||||
|
Target.RemoveGlobalPlayer = function()
|
||||||
|
sleepless_interact:removeGlobalPlayer()
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param entity number
|
||||||
|
---@return nil
|
||||||
|
Target.RemoveLocalEntity = function(entity)
|
||||||
|
sleepless_interact:removeLocalEntity(entity)
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param model string
|
||||||
|
---@return nil
|
||||||
|
Target.RemoveModel = function(model)
|
||||||
|
sleepless_interact:removeModel(model)
|
||||||
|
end
|
||||||
|
|
||||||
|
---comment
|
||||||
|
---@param name string
|
||||||
|
---@return nil
|
||||||
|
Target.RemoveZone = function(name)
|
||||||
|
for _, data in pairs(targetZones) do
|
||||||
|
if data.name == name then
|
||||||
|
sleepless_interact:removeCoords(data.id)
|
||||||
|
table.remove(targetZones, _)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
AddEventHandler('onResourceStop', function(resource)
|
||||||
|
if resource == GetCurrentResourceName() then
|
||||||
|
for _, target in pairs(targetZones) do
|
||||||
|
if target.creator == resource then
|
||||||
|
sleepless_interact:removeZone(target.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
targetZones = {}
|
||||||
|
end
|
||||||
|
end)
|
||||||
Reference in new issue
Block a user