Hello, I am having a problem while setting a variable in one part of code and then reusing it in another part of code:
let's say I have a simple square footprint shape and I use following rule on it:
attr counter = 0
Lot -->
set(counter,counter+1)
set(counter,counter+1)
print (counter)
and it works pefectly fine and print returns:
2
when I try to use it from two different parts of code e.g. Lot and Cube
attr counter = 0
Lot -->
set(counter,counter+1)
print("output from Lot: "+counter)
extrude(3) Cube(counter)
Cube(cnt) -->
set(counter,cnt+1)
print("output from Cube: "+counter)
it also works fine (because I passed the variable from one rule to another in as an argument ) and the otuput is:
output from Lot: 1
output from Cube: 2
but when I extend the previous rule so that:
attr counter = 0
Lot -->
set(counter,counter+1)
print("output from Lot: "+counter)
extrude(3) Cube(counter)
Cube(cnt) -->
set(counter,cnt+1)
print("output from Cube: "+counter)
comp(f){side:Sides(counter)}
Sides(cnt) -->
set(counter,cnt+1)
print("output from Sides: "+counter)
I get the output:
output from Lot: 1
output from Cube: 2
output from Sides: 3
output from Sides: 3
output from Sides: 3
output from Sides: 3
and I'm expecting output:
output from Lot: 1
output from Cube: 2
output from Sides: 3
output from Sides: 4
output from Sides: 5
output from Sides: 6
because I expect that Sides(cnt) part of a code runs 4 times (for each face of the box) thus each iteration will increment counter by 1
another weird thing is that the mentioned attribude value doesn't change in Inspector:

any ideas?
thanks,
Marek