Question

In my HubNet application each client has access to a slider which he or she can use to guess the answer to questions. I use the command

set slider-value 0

in order to reset the slider between questions. However, this only seems to set the global variable associated with the slider to 0, not the slider that the participant manipulates. How do I change the slider itself (from the server)?

It is of course very confusing for the participant as is since if he or she hits the guess button before she has moved the slider her guess will equal the global variable whatever the slider is currently set to.

Was it helpful?

Solution

I think that one reason for the confusion here is that the HubNet system is a "thin" or "dumb" client system.

In particular, the client does not have any awareness of the meaning of its interface elements. So, your idea (of updating the variable on the NetLogo server and expecting that the clients would be notified that the interface element that corresponds to this variable [its meaning] would be updated).

Instead, your NetLogo model needs to manage the meaning and its implications. So, the "slider-value" variable changes. And then the host needs to tell the clients to update their interface elements. You would do this by issuing a hubnet-send command.

For example, suppose the HubNet client was called "joe", the slider in the client interface is called "my-slider", and the relevant variable is, as you say, slider-value You would then write

hubnet-send "joe" "my-slider" slider-value

Normally, in HubNet models, there is a breed of turtles that is associated with clients (say "students" or "clients"), and these clients have a variable that keeps track of the HubNet client's identifier (say this variable is "my-id"). Then, to update ALL of the clients' sliders at once, you would say...

ask clients [
  hubnet-send my-id "my-slider" slider-value
]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top