set1.0

set variable value

Sets variable to the given value.

Variable can be any of the following:

Example:

ask turtles [
  set color red
  set size 2
  set shape "arrow"
]

You can also give a list of variable names as the first argument for set and they will be assigned the values from a list given as the second argument. This can be particular useful when you want to calculate multiple values in a reporter procedure, as you can easily set multiple variables with the results. A runtime error will occur if the second argument is not a list value or if there are not enough values in the list for all the variables specified.

ask turtles [
  set [color size shape] [red 2 "arrow"]
  show color ; prints 15
  show size ; prints 2
  show shape ; prints "arrow"
]
ask turtles [
  set [color size shape] [red] ; causes a runtime error as we need at least 3 values in the list
]
      

Take me to the full NetLogo Dictionary