forked from redo/BlockLua
Merge branch 'add-@diagnostic-to-reduce-warning-spam' into auios
This commit is contained in:
@@ -7,7 +7,9 @@ ts = _bllua_ts
|
|||||||
|
|
||||||
-- Provide limited OS functions
|
-- Provide limited OS functions
|
||||||
os = os or {}
|
os = os or {}
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function os.time() return math.floor(tonumber(_bllua_ts.call('getSimTime'))/1000) end
|
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
|
function os.clock() return tonumber(_bllua_ts.call('getSimTime'))/1000 end
|
||||||
|
|
||||||
-- Virtual file class, emulating a file object as returned by io.open
|
-- Virtual file class, emulating a file object as returned by io.open
|
||||||
@@ -106,6 +108,7 @@ local function io_open_absolute(fn, mode)
|
|||||||
end
|
end
|
||||||
|
|
||||||
io = io or {}
|
io = io or {}
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function io.open(fn, mode, errn)
|
function io.open(fn, mode, errn)
|
||||||
errn = errn or 1
|
errn = errn or 1
|
||||||
|
|
||||||
@@ -126,13 +129,17 @@ function io.open(fn, mode, errn)
|
|||||||
return fi, err, fn
|
return fi, err, fn
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function io.lines(fn)
|
function io.lines(fn)
|
||||||
local fi, err, fn2 = io.open(fn, nil, 2)
|
local fi, err, fn2 = io.open(fn, nil, 2)
|
||||||
if not fi then error('Error opening file \''..fn2..'\': '..err, 2) end
|
if not fi then error('Error opening file \''..fn2..'\': '..err, 2) end
|
||||||
return fi:lines()
|
return fi:lines()
|
||||||
end
|
end
|
||||||
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
function io.type(f)
|
function io.type(f)
|
||||||
|
---@diagnostic disable-next-line: undefined-field
|
||||||
if type(f)=='table' and f._is_file then
|
if type(f)=='table' and f._is_file then
|
||||||
|
---@diagnostic disable-next-line: undefined-field
|
||||||
return f._is_open and 'file' or 'closed file'
|
return f._is_open and 'file' or 'closed file'
|
||||||
else
|
else
|
||||||
return _bllua_io_type(f)
|
return _bllua_io_type(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user