local ImageHeight = 60
local ImageWidth = 60
local MinRe = -2.0
local MaxRe = 1.0
local MinIm = -1.2
local MaxIm = MinIm+(MaxRe-MinRe)*ImageHeight/ImageWidth
local Re_factor = (MaxRe-MinRe)/(ImageWidth-1)
local Im_factor = (MaxIm-MaxIm)/(ImageHeight-1)
local MaxIterations = 30
local function putpixel(x, y)
print("draw pixel")
end
for y = 0, ImageHeight do
local c_im = MaxIm - y*Im_factor
for x = 0, ImageWidth do
local c_re = MinRe + x*Re_factor
local Z_re = c_re
local Z_im = c_im
local isInside = true
for n = 0, MaxIterations do
local Z_re2 = Z_re*Z_re
local Z_im2 = Z_im*Z_im
print(Z_re2 + Z_im2)
if Z_re2 + Z_im2 > 4 then -- MY ERROR: this must be > 4 to set isInside to false, but it's always false, and it doesn't let putpixel() function to run
isInside = false
break
end
Z_im = 2*Z_re*Z_im + c_im
Z_re = Z_re2 - Z_im2 + c_re
end
if isInside then
putpixel(x, y)
end
end
end
Id add more to it, just using if isInside would have worked a while ago, but now ive found it to be a big issue in all of my scripts that contained that sort of checking.
Check if the value is nil. – Use this with a else statement rather than if isInside as is.
Check if it is true or false. – If it suits.
I assume you’re talking about this if statement?
If you are, the reason it isn’t working is because it’s likely setting it to false here: