ThomasC
ThomasC

Reputation: 881

How to set a turtle's colour to match another turtle?

This one is pretty simple but I keep running into problems around how colours are stored. Both of the following produce an error saying colour should be three numbers for RGB.

let temp [color] of topTurtle ask turtles [set color temp]

or

ask turtles [set color [color of topturtle]]

What's the correct way to do this please?

Upvotes: 0

Views: 41

Answers (1)

LeirsW
LeirsW

Reputation: 2305

Your second option should be ask turtles [set color [color] of topturtle], you put the brackets wrong.

Other than that error, both options work just fine for me. If I enter the following lines in the command center, they work just fine.

crt 5 [setxy random-xcor random-ycor]
let temp [color] of turtle 0 ask turtles [set color temp]

The same goes for

crt 5 [setxy random-xcor random-ycor]
ask turtles [set color [color] of turtle 0]

Upvotes: 1

Related Questions