Reputation: 1
I have to make a button that colors in the patches in the bottom half of the grid randomly with darker shades of a given color based off of a slider, and the top of half of the grid randomly with lighter shades of a given color based off of the slider. When I wrote my code it says that I can't use my command because it is in patch-context because by command is in turtle-only context. I am confused because I am not using turtles, I am only using patches. Inside of my button I wrote "colorRandomShade2" which is the name of my command. The button is also in patch context and its display name is "colorRandomShade2".
Code:
to colorRandomShade2
if ycor > 0 [ set pcolor ( main_color + random 5 ) ]
if ycor < 0 [ set pcolor ( main_color + random 9 ) ]
end
Upvotes: 0
Views: 73
Reputation: 17678
Patch coordinates are pxcor
and pycor
, but you have used xcor
and ycor
, which are the variable names for coordinates of a turtle. So you are pressing the button to call the code and the first thing that NetLogo sees is a request to look at the ycor
or y-coordinate of a turtle.
Upvotes: 1