I have just started messing around with codea and I found a tutorial and did it it had me write out a code but every time i run this code it comes up with an error and says I am attempting to index a nil value
Here is the code
function setup()
x=50
y=50
d=60
dx=2
dy=1
end
function draw()
background(200,200,200,255)
pushStyle().
fill(255,0,0,255)
x=x+dx
y=y+dy
ellipse(x,y,d)
popStyle()
if x<d/2 or x>WIDTH-d/2 then dx=-dx end
if y<d/2 or y>WIDTH-d/2 then dy=-dy end
end
The great thing about the debugging output is that it will point you to the location of the error, for the most part. You were receiving the following error:
error: [string “function setup()…”]:12: attempt to index a nil value
This lets you know that the problem lies within the setup() function and around line 12. The actual problem was on line 11 (technically after line 11 but before line 12 since it was an additional character error), but you can definitely see how close it gets you to the problem.
Hope this helps you locate any future errors you run into.