fix error message for boolean argument

This commit is contained in:
Pinya
2018-12-13 19:39:38 +03:00
parent 613f9da089
commit bccd141d83
2 changed files with 22 additions and 22 deletions
+4 -4
View File
@@ -209,9 +209,9 @@ end
function difftime(time2, time1)
if type(time2) ~= "number" then
error(format("bad argument #1 to 'difftime' (number expected, got %s)", time2 and type(time2) or "no value"), 2)
error(format("bad argument #1 to 'difftime' (number expected, got %s)", time2 ~= nil and type(time2) or "no value"), 2)
elseif time1 and type(time1) ~= "number" then
error(format("bad argument #2 to 'difftime' (number expected, got %s)", time1 and type(time1) or "no value"), 2)
error(format("bad argument #2 to 'difftime' (number expected, got %s)", time1 ~= nil and type(time1) or "no value"), 2)
end
return time1 and time2 - time1 or time2
@@ -321,7 +321,7 @@ end
function GetMapNameByID(id)
if not (type(id) == "string" or type(id) == "number") then
error(format("Bad argument #1 to \"GetMapNameByID\" (number expected, got %s)", id and type(id) or "no value"), 2)
error(format("Bad argument #1 to \"GetMapNameByID\" (number expected, got %s)", id ~= nil and type(id) or "no value"), 2)
end
return mapByID[tonumber(id)]
@@ -382,7 +382,7 @@ end
function CreateStatusBarTexturePointer(statusbar)
if type(statusbar) ~= "table" then
error(format("Bad argument #1 to \"CreateStatusBarTexturePointer\" (table expected, got %s)", statusbar and type(statusbar) or "no value"), 2)
error(format("Bad argument #1 to \"CreateStatusBarTexturePointer\" (table expected, got %s)", statusbar ~= nil and type(statusbar) or "no value"), 2)
elseif not (statusbar.GetObjectType and statusbar:GetObjectType() == "StatusBar") then
error("Bad argument #1 to \"CreateStatusBarTexturePointer\" (statusbar object expected)", 2)
end