[Closed] undefined variable problem
hello everyone,
I have a small problem when i try to run the following piece of code:
for j in 1 to nGen do
(
for i in 1 to nCells do
(
if (cellAuto[j][i] == 1) then
p = plane()
p.length = 1
p.width = 1
p.pos.x = i
p.pos.y = -j
)
)
I get “Unknown property: “length” in Plane”. And when I change it to this :
...
p = plane length:1 width:1
move p [i,-j,0]
...
i get “No ““move”” function for undefined”. Actually, i does work sometimes (?) when I run pieces of my code separately, but it doesn’t work at all when i wrap it in a button. I assume that for some reason it considers p as an undefined variable… but i am not really sure…
thanks
I think the problem is that it should be written like:
for j in 1 to nGen do
(
for i in 1 to nCells do
(
if (cellAuto[j][i] == 1) then
(
p = plane()
p.length = 1
p.width = 1
p.pos.x = i
p.pos.y = -j
)
)
)
Without the set of parenthesis I added, the program will only consider the first like (“p = plane()”) to be part of the THEN statement. Thus in some cases the script is not creating the plane since cellAuto[j][i] is different than 1 but it’s still trying to set the plane’s properties.