So I was doing work in lua to make an object that essentially controlled and moved subobjects, and I was wondering if to reduce lines of code, I could increment multiple values in one statement. This is the entire function:
function ElephantEarC:SetOffset(x, y)
local oiX, oiY -- Offset increase X/Y
for i, stem in pairs(self.stems) do
oiX, oiY = stem.low:GetOffset()
oiX, oiY += x, y
end
end
I was wondering if this line was valid:
oiX, oiY += x, y
A bit of information about this code
- self.stems is an array of the subobjects.
- GetOffset() returns two values– x and y.
- Each ‘stem’ has three subobjects that are grouped together– low, high and leaf (I just haven’t written them in yet).
If anything else is vague, or this question’s already been answered and I couldn’t find it, please tell me…
I do not think the syntax on the line with
+=is valid. This will perform the additions on a single line correctly, though: