pause-play-notify


Information

Created with NetLogo version NetLogo 4.0.4
Running with NetLogoLite.jar version 404.


WHAT IS IT?


-------
A demonstration of using monitors to cause messages to appear in the view based on the state of the simulation, such as waiting to be setup, ready to run, and paused.

Procedures

NetLogo Version: NetLogo 4.0.4

globals
[ setup-complete?
  reset?
  paused?
]

to setup
   ; ...
   ca
   set reset? true
   set paused? false
   set setup-complete? true
end

to go
   every .1
   [ 
   set paused? false
   set reset? false   
   ;...
   ask patches
   [ set pcolor [ 1 + pcolor ] of patch-at
        (1.4 * sin ((pxcor + min-pxcor) / world-width  * 360)) 
        (1.4 * cos ((pycor + min-pycor) / world-height * 360)) ]
   tick
   ]
end


to-report detect-pause
   let messenger patch max-pxcor (max-pycor - 1)
   ifelse paused? != false
   [ ask messenger
     [ ifelse (int (timer)) mod 4 < 3
       [ ifelse reset? = 0
         [ set plabel-color yellow set plabel "Press 'setup' to prepare the sim." ]
         [ ifelse reset? = true
           [ set plabel-color lime set plabel "Ready. Press 'play' to begin."   ]
           [ set plabel-color white  set plabel "Paused. Press 'play' to resume." ] 
         ]
       ]
       [ set plabel "" ] display]
   ] 
   [ ask messenger [ set plabel "" ]
   ]
   let was-paused? paused?
   set paused? true
   report (word "Paused? " was-paused?)   
end
   
   

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download pause-play-notify --