1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-11-22 10:04:53 +00:00

Added OS argument type checking

This commit is contained in:
LDDestroier
2019-06-21 14:59:58 -04:00
committed by GitHub
parent 068093201a
commit c02fb4a8c6

View File

@@ -928,6 +928,7 @@ local main = function()
local setInstanceSpecificFunctions = function(x, y) local setInstanceSpecificFunctions = function(x, y)
os.startTimer = function(duration) os.startTimer = function(duration)
if type(duration) == "number" then
local t local t
while true do while true do
t = math.random(1, 2^30) t = math.random(1, 2^30)
@@ -936,19 +937,30 @@ local main = function()
return t return t
end end
end end
else
error("bad argument #1 (number expected, got " .. type(duration) .. ")")
end
end end
os.cancelTimer = function(id) os.cancelTimer = function(id)
if type(id) == "number" then
instances[y][x].timer[id] = nil instances[y][x].timer[id] = nil
else
error("bad argument #1 (number expected, got " .. type(id) .. ")")
end
end end
os.clock = function() os.clock = function()
return oldOSreplace.clock() + instances[y][x].clockMod return oldOSreplace.clock() + instances[y][x].clockMod
end end
os.queueEvent = function(evt, ...) os.queueEvent = function(evt, ...)
if type(evt) == "string" then
if instances[y][x].paused then if instances[y][x].paused then
instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...} instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...}
else else
oldOSreplace.queueEvent(evt, ...) oldOSreplace.queueEvent(evt, ...)
end end
else
error("bad argument #1 (number expected, got " .. type(evt) .. ")")
end
end end
end end