use @diagnostic comments to reduce warning spam in console
This commit is contained in:
@@ -446,7 +446,7 @@ local tsMeta = {
|
||||
elseif name:find('::') then
|
||||
local ns, rest = name:match('^([^:]+)::(.+)$')
|
||||
if not ns then error('ts index: invalid name \''..name..'\'', 2) end
|
||||
if not rest:find('::') and tsIsFunction(ns, rest) then
|
||||
if not rest:find('::') and tsIsFunction(ns, rest) then -- tsIsFunction is only defined with one argument
|
||||
error('ts index: can\'t call a namespaced function from lua', 2)
|
||||
else
|
||||
return valFromTs(_bllua_ts.getvar(name), name)
|
||||
|
||||
@@ -7,7 +7,11 @@ ts = _bllua_ts
|
||||
|
||||
-- Provide limited OS functions
|
||||
os = os or {}
|
||||
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function os.time() return math.floor(tonumber(_bllua_ts.call('getSimTime'))/1000) end
|
||||
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function os.clock() return tonumber(_bllua_ts.call('getSimTime'))/1000 end
|
||||
|
||||
-- Virtual file class, emulating a file object as returned by io.open
|
||||
@@ -106,9 +110,10 @@ local function io_open_absolute(fn, mode)
|
||||
end
|
||||
|
||||
io = io or {}
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function io.open(fn, mode, errn)
|
||||
errn = errn or 1
|
||||
|
||||
|
||||
-- try to open the file with relative path, otherwise use absolute path
|
||||
local curfn = debug.getfilename(errn + 1) or _bllua_ts.getvar('Con::File')
|
||||
if curfn == '' then curfn = nil end
|
||||
@@ -116,23 +121,29 @@ function io.open(fn, mode, errn)
|
||||
local relfn = curfn and fn:find('^%./') and
|
||||
curfn:gsub('[^/]+$', '')..fn:gsub('^%./', '')
|
||||
if relfn then
|
||||
local fi, err = io_open_absolute(relfn, mode, errn+1)
|
||||
local fi, err = io_open_absolute(relfn, mode, errn+1) -- defined with 2 args? function io_open_absolute(fn, mode)
|
||||
return fi, err, relfn
|
||||
else
|
||||
return nil, 'Invalid path', fn
|
||||
end
|
||||
else
|
||||
local fi, err = io_open_absolute(fn, mode, errn+1)
|
||||
local fi, err = io_open_absolute(fn, mode, errn+1) -- defined with 2 args but passed 3 in.
|
||||
return fi, err, fn
|
||||
end
|
||||
end
|
||||
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function io.lines(fn)
|
||||
local fi, err, fn2 = io.open(fn, nil, 2)
|
||||
if not fi then error('Error opening file \''..fn2..'\': '..err, 2) end
|
||||
return fi:lines()
|
||||
end
|
||||
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
function io.type(f)
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
if type(f)=='table' and f._is_file then
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
return f._is_open and 'file' or 'closed file'
|
||||
else
|
||||
return _bllua_io_type(f)
|
||||
|
||||
Reference in New Issue
Block a user