I was trying my hand at creating a re-usable function and am getting rather annoyed at the error message “Assigning to r value”. What am I doing wrong, please?
self.SafePath(fx, fy) = function:
tarA = Vector(fx, fy)
vecA = Vector.subtract(tarA, self.pos)
# This creates a 90° rotated, 0.5 m long vector realtive to vec.
normV = Vector.multiply(Vector.normalize(Vector.rotate(vecA, 1.5708)), 0.5)
targetL = [tarA, Vector.add(tarA, normV), Vector.subtract(tarA, normV)]
startL = [self.pos, Vector.add(self.pos, normV), Vector.subtract(self.pos, normV)]
isFree = True
for s in startL:
for t in targetL:
isFree = isFree and self.isPathClear(s, t)
return isFree
[And a big thank you to J_F_B_M (i.e. Joachim Brehmer), without whom I would not have gotten even this far.]