1
0
mirror of https://github.com/LDDestroier/CC/ synced 2025-11-14 14:17:13 +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,26 +928,38 @@ local main = function()
local setInstanceSpecificFunctions = function(x, y) local setInstanceSpecificFunctions = function(x, y)
os.startTimer = function(duration) os.startTimer = function(duration)
local t if type(duration) == "number" then
while true do local t
t = math.random(1, 2^30) while true do
if not instances[y][x].timer[t] then t = math.random(1, 2^30)
instances[y][x].timer[t] = math.floor(duration * 20) / 20 if not instances[y][x].timer[t] then
return t instances[y][x].timer[t] = math.floor(duration * 20) / 20
return t
end
end end
else
error("bad argument #1 (number expected, got " .. type(duration) .. ")")
end end
end end
os.cancelTimer = function(id) os.cancelTimer = function(id)
instances[y][x].timer[id] = nil if type(id) == "number" then
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 instances[y][x].paused then if type(evt) == "string" then
instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...} if instances[y][x].paused then
instances[y][x].extraEvents[#instances[y][x].extraEvents + 1] = {evt, ...}
else
oldOSreplace.queueEvent(evt, ...)
end
else else
oldOSreplace.queueEvent(evt, ...) error("bad argument #1 (number expected, got " .. type(evt) .. ")")
end end
end end
end end