239 | | Say we want to define a function "scan-area" that takes two arguments (a quagent key and a radius) and returns a hash map of the positions of the items. |
| 239 | Notice that the room has a few items scattered around it, let's define a function "scan-area" that takes two arguments (a quagent key and a radius) and returns a hash map of the positions of the items. The simplest implementation is to just use the basic radar op from protocol zero with a vector for an initial value and "conj" for the combination function. (Note the use of "pp" to pretty-print the previous result.) |
| 240 | |
| 241 | {{{ |
| 242 | client.core=> (send-and-get :Bob :radar :now [8000] [] conj) |
| 243 | [("0" "player" "768.875366" "90.065201" "0.000000") ... (output-truncated) |
| 244 | client.core=> (pp) |
| 245 | [("0" "player" "768.875366" "90.065201" "0.000000") |
| 246 | ("2" "player" "32.000000" "-90.000000" "0.000000") |
| 247 | ("72" "info_player_deathmatch" "32.000244" "-90.000000" "0.223811") |
| 248 | ("74" "quagent_item_treasure" "572.168640" "20.462269" "0.901278") |
| 249 | ("75" "quagent_item_gold" "375.085327" "56.309933" "1.374918") |
| 250 | ("76" "quagent_item_gold" "1019.278626" "42.455196" "0.505915") |
| 251 | ("77" "quagent_item_treasure" "697.711304" "63.434952" "0.739097") |
| 252 | ("78" "quagent_item_gold" "905.141357" "8.130102" "0.569713") |
| 253 | ("79" "info_player_deathmatch" "0.125000" "0.000000" "90.000000")] |
| 254 | nil |
| 255 | }}} |
| 256 | |
| 257 | |
| 258 | |