Mouse Up Example

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.1pre3 • Viewed 131 times • Downloaded 16 times • Run 0 times
Download the 'Mouse Up Example' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


VERSION

$Id: Mouse Up Example.nlogo 40298 2008-07-23 20:15:38Z everreau $

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

turtles-own [ grabber ]

to startup
  setup
  hubnet-set-client-interface "COMPUTER" []
  hubnet-reset
end 

to setup
  clear-all
  ask n-of 15 patches [ sprout 1 [ pd  set grabber "" ] ]
end 

to go
  every 0.1
  [
    listen-clients
    display
  ]
end 

to listen-clients
  while [ hubnet-message-waiting? ]
  [
    hubnet-fetch-message
    if not hubnet-enter-message? and not hubnet-exit-message?
    [ execute-command hubnet-message-tag hubnet-message ]
  ]
end 

to execute-command [tag msg]
  if tag = "View"
  [ grab-turtle hubnet-message-source msg ]
  if tag = "Mouse Up"
  [ drop-turtle hubnet-message-source msg ]
end 

to grab-turtle [name coords]
  let clicked-patch patch first coords last coords
  let my-turtle one-of (turtles-on clicked-patch) with [grabber = ""]
  if my-turtle != nobody
  [
    ask my-turtle [ set grabber name ]
  ]
end 

to drop-turtle [name coords]
  ask turtles with [grabber = name] 
  [ setxy first coords last coords
    set grabber "" ]
end 

There are 2 versions of this model.

Uploaded by When Description Download
Uri Wilensky almost 14 years ago Mouse Up Example Download this version
Uri Wilensky almost 14 years ago Mouse Up Example Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.