Module:File link: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
move duplicate size error checks to the setting functions, fix the alignment error message
(fix read-only behaviour and remove the test function)
(move duplicate size error checks to the setting functions, fix the alignment error message)
Line 34:
error('invalid format')
end
end
 
local function sizeError(methodName)
-- Used for formatting duplication errors in size-related methods.
error(string.format(
"duplicate size argument detected in '%s'"
.. " ('upright' cannot be used in conjunction with height or width)",
methodName
), 3)
end
Line 39 ⟶ 48:
checkSelf(self, 'width')
checkType('width', 1, px, 'number')
elseifif data.isUpright and data.uprightFactor then
sizeError('width')
end
data.theWidth = px
end
Line 45 ⟶ 57:
checkSelf(self, 'height')
checkType('height', 1, px, 'number')
if data.isUpright then
sizeError('height')
end
data.theHeight = px
end
Line 51 ⟶ 66:
checkSelf(self, 'upright')
checkType('upright', 1, factor, 'number', true)
if data.theWidth or data.theHeight then
sizeError('upright')
end
data.isUpright = true
data.uprightFactor = factor
Line 98 ⟶ 116:
else
error(string.format(
"bad argument #1 to 'alignment' ('%s' is not a valid alignment)",
s
))
end
Line 155 ⟶ 174:
-- Size
if data.isUpright and (data.theWidth or data.theHeight)uprightFactor then
error("duplicate size value detected in 'render' (height/width cannot be used at the same time as 'upright')")
elseif data.isUpright and data.uprightFactor then
ret[#ret + 1] = 'upright=' .. tostring(data.uprightFactor)
elseif data.isUpright then
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu