Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/compat/convert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function convert.qb(o, maxDistance)
TriggerEvent(d.event, d)
end
else
error('No trigger setup')
error('This option has no action or event.')
end
end

Expand Down
2 changes: 1 addition & 1 deletion client/interact/loop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ local function take(c)
shownSig = sig

if config.Debug then
lib.print.info(('focus %s (%d options)'):format(c.key, #c.options))
lib.print.info(('Showing %s (%d options).'):format(c.key, #c.options))
end
end

Expand Down
37 changes: 33 additions & 4 deletions client/interact/points.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ local DEF = config.Interact
---@return InteractOption[]
local function cleanOptions(list)
local out = {}
local invalid = 0

if type(list) ~= 'table' then
return out
Expand All @@ -69,12 +70,14 @@ local function cleanOptions(list)
end

for _, o in ipairs(list) do
if type(o) == 'table' and type(o.label) == 'string' then
if type(o) == 'table' and type(o.label) == 'string' and o.label ~= '' then
out[#out + 1] = o
else
invalid = invalid + 1
end
end

return out
return out, invalid
end

---@param v any
Expand Down Expand Up @@ -104,10 +107,17 @@ local function make(kind, data, resource)
lastId = lastId + 1
data = type(data) == 'table' and data or {}

local options, invalid = cleanOptions(data.options or data)

if invalid > 0 then
lib.print.warn(('Resource "%s": skipped %d option(s) with no valid label. Each option needs a text label.')
:format(resource, invalid))
end

local p = {
id = lastId,
kind = kind,
options = cleanOptions(data.options or data),
options = options,
distance = tonumber(data.distance) or DEF.Distance,
interactDistance = tonumber(data.interactDistance) or DEF.InteractDistance,
lineOfSight = data.lineOfSight == nil and DEF.LineOfSight or data.lineOfSight == true,
Expand All @@ -129,6 +139,12 @@ end
---@param p InteractPoint
---@return integer id
local function put(p)
if #p.options == 0 then
lib.print.warn(('Resource "%s": skipped a point with no valid options.')
:format(p.resource))
return nil
end

all[p.id] = p
points.version = points.version + 1
return p.id
Expand Down Expand Up @@ -285,7 +301,20 @@ function points.update(id, data)
if not p or type(data) ~= 'table' then return false end

if data.options then
p.options = cleanOptions(data.options)
local options, invalid = cleanOptions(data.options)

if invalid > 0 then
lib.print.warn(('Resource "%s": skipped %d option(s) with no valid label while updating point %d.')
:format(p.resource, invalid, id))
end

if #options == 0 then
lib.print.warn(('Resource "%s": point %d needs at least one valid option. Update skipped.')
:format(p.resource, id))
return false
end

p.options = options
end

if data.distance then
Expand Down
2 changes: 1 addition & 1 deletion client/interact/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function run.option(c, o)
end)

if not ok then
lib.print.error(('option "%s" of a %s point failed: %s'):format(o.label, c.point.resource, tostring(err)))
lib.print.error(('Option "%s" from resource "%s" failed: %s'):format(o.label, c.point.resource, tostring(err)))
end
end

Expand Down
6 changes: 3 additions & 3 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ do
---@type table qb-target's / qtarget's API (client.compat.qb_target).
local qb = require 'client.compat.qb_target'
local layers = { ox_target = ox, qtarget = qb, ['qb-target'] = qb }
local warning = 'Replace.%s is on and something called %s is started: '
.. 'if the real %s is still installed, remove it from your server.cfg'
local warning = 'Can’t replace %s while resource "%s" is running. '
.. 'Stop the real %s resource or remove it from server.cfg.'

for name, on in pairs(config.Replace) do
local layer = layers[name]
Expand All @@ -45,7 +45,7 @@ do
end

layer.provide(name)
lib.print.info(('answering %s exports'):format(name))
lib.print.info(('Using %s compatibility exports.'):format(name))
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions locales/da.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"hold": "Hold",
"keymap": {
"interact": "Brug",
"next": "Næste valg",
"prev": "Forrige valg",
"interact_pad": "Brug (controller)",
"next_pad": "Næste valg (controller)",
"prev_pad": "Forrige valg (controller)"
}
}
11 changes: 11 additions & 0 deletions locales/sv.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"hold": "Håll",
"keymap": {
"interact": "Använd",
"next": "Nästa val",
"prev": "Föregående val",
"interact_pad": "Använd (handkontroll)",
"next_pad": "Nästa val (handkontroll)",
"prev_pad": "Föregående val (handkontroll)"
}
}
Loading