dokato Posted May 28, 2019 Share Posted May 28, 2019 (edited) Hi, I'got a question about static fields in my Main script. Does it become like a singleton for all my bot instances? Like if I start up multiple bot clients, will the value of a static field be always the same for all of these bot clients, even if the value gets modified at runtime? Or not? I could test it myself ofc. but I don't have VIP atm and cannot run multiple bots... I thought that a static field is same for the entire JVM, thats why I'm asking. Thanks in advance. Edited May 28, 2019 by dokato Quote Link to comment Share on other sites More sharing options...
Czar Posted May 28, 2019 Share Posted May 28, 2019 Statics will be shared clientside with bot tabs, so all tabs are within the same scope, iirc. 1 Quote Link to comment Share on other sites More sharing options...
Elixar Posted May 29, 2019 Share Posted May 29, 2019 4 hours ago, Czar said: Statics will be shared clientside with bot tabs, so all tabs are within the same scope, iirc. Does that mean If I use static booleans in my GUI and someone opens 10 of the same script on 1 client, All 10 will be affected? Is this why we use Getters and Setters? Whats the point of even having static fields then...? 2 Quote Link to comment Share on other sites More sharing options...
Czar Posted May 29, 2019 Share Posted May 29, 2019 (edited) Yep, getters and setters are for instances Statics are good for their own reasons, e.g. global variables such as constants, e.g. declaring an entire class called ItemIDLibrary.java and filling it up with item id variables: public static final int ABYSSAL_WHIP = 4151; public static final int ARMADYL_GODSWORD = 11694; whereas non-static helps with object oriented design, helps with memory usage, variables can be re-assigned and more productive code can be designed. They are both used in conjunction, not so much exclusively Edited May 29, 2019 by Czar 2 1 Quote Link to comment Share on other sites More sharing options...
dokato Posted May 29, 2019 Author Share Posted May 29, 2019 14 hours ago, Czar said: Statics will be shared clientside with bot tabs, so all tabs are within the same scope, iirc. Ok and what if i open up multiple bot windows? (Instead of just one window with multiple tabs) Quote Link to comment Share on other sites More sharing options...
Elixar Posted May 30, 2019 Share Posted May 30, 2019 (edited) 17 hours ago, dokato said: Ok and what if i open up multiple bot windows? (Instead of just one window with multiple tabs) I think the point is, If you only use statics for what they are intended for, Whilst using proper Object Orientated Design principles, then you wont have to worry about these issues of " what if I use multiple Bot windows instead ". Edited May 30, 2019 by Elixar 1 Quote Link to comment Share on other sites More sharing options...
dokato Posted May 30, 2019 Author Share Posted May 30, 2019 5 hours ago, Elixar said: I think the point is, If you only use statics for what they are intended for, Whilst using proper Object Orientated Design principles, then you wont have to worry about these issues of " what if I use multiple Bot windows instead ". Hahah, I understand that lol but i wanted to just know u know. Quote Link to comment Share on other sites More sharing options...
Tom Posted June 4, 2019 Share Posted June 4, 2019 On 5/29/2019 at 10:01 PM, dokato said: Ok and what if i open up multiple bot windows? (Instead of just one window with multiple tabs) In case you wanted an actual answer to this, it won't affect multiple bot windows as they run on their own JVM 2 Quote Link to comment Share on other sites More sharing options...
liverare Posted June 5, 2019 Share Posted June 5, 2019 11 hours ago, Tom said: In case you wanted an actual answer to this, it won't affect multiple bot windows as they run on their own JVM I recall one of the changes from OSBot v1 to v2 was that bots could no longer read/write to the same static variables, so that's likely it. 2 Quote Link to comment Share on other sites More sharing options...