NetLogo 7.0.0-beta2:

set1.0

set variable value

Sets variable to the given value.

Variable can be any of the following:

  • A global variable declared using "globals"
  • The global variable associated with a slider, switch, chooser, or input box.
  • A variable belonging to this agent
  • If this agent is a turtle, a variable belonging to the patch under the turtle.
  • A local variable created by the let command.
  • An input to the current procedure.

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