Hey Sven, If you just want to store extra data for a patch, but you don't need that data available in Netlogo code as a normal patches-own variable, it isn't too hard. As Seth said in his answer, you just need to make a map from patches to your new data to store in your extension. Off the top of my head, the Physics extension does something like this to store physics data for patches and turtles: https://github.com/Loafie/netlogo_phys_extension/blob/master/src/PhysExtension.scala#L29
I should point out you can still give access to the data in NetLogo code, just not as `[my-var] of patch 0 0` but using a custom reporter defined by your extension, like `my-ext:my-var-of patch 0 0`. If you do want to let NetLogo code access your custom patch data like a totally normal patches-own variable, then that would still be a pretty involved process, which Seth laid out the very basic steps of. Another option that might work would be to have a way to let the users register a patch variable as the one for the extension to store data in, `my-ext:set-patch-var "my-var"`. This would let the variable be referenced as normal in code, and you're extension could use the user-provided value for whatever its doing. One downside here is I think "my-var" would have to just be a string, meaning it won't be compile-time checked for correctness. I hope that helps. -Jeremy From: <[email protected]> on behalf of Sven Anderson <[email protected]> Date: Monday, July 6, 2020 at 12:00 PM To: netlogo-devel <[email protected]> Subject: [netlogo-devel] Re: set a custom turtle variable In an extension I'm wanting to extend the patch variable so that each patch will have additional data stored with it. This is like patches-own [myvariablename], but built into the extension. Below I found this response, which makes it look fairly difficult. However, the reply is from 2012, and I'm wondering whether this is still handled the same way, or has it become an easier change? Thanks! -sven On Wednesday, May 30, 2012 at 5:42:31 AM UTC-4, digitaldust wrote: Hello List, how can I specify a turtle variable like turtle-own [myvariablename]? I see that turtle.setTurtleVariable(1, "red") sets the color of the turtle... is there any table with all variables numbers? How can I add a new variable then? thanks for your advices, Simone -- Dr. Simone Gabbriellini DigitalBrains srl Amministratore Head R&D mobile: +39 3403975626 mail: [email protected]<javascript:> -- You received this message because you are subscribed to the Google Groups "netlogo-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/d5df52d3-d460-4b7d-94e3-06ab5cf8107ao%40googlegroups.com<https://urldefense.com/v3/__https:/groups.google.com/d/msgid/netlogo-devel/d5df52d3-d460-4b7d-94e3-06ab5cf8107ao*40googlegroups.com?utm_medium=email&utm_source=footer__;JQ!!Dq0X2DkFhyF93HkjWTBQKhk!DNUgjyQMNgofvL8V2m4aMfON4JSmsNQSKttXBTIHPnZW_Ia5PSdqQ91lhU0uyR2_i_HbZVKyiQ$>. -- You received this message because you are subscribed to the Google Groups "netlogo-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/DDD477B3-2544-4DE8-8005-525329A5B015%40northwestern.edu.
