Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Static field ...

Featured Replies

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 by dokato

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...?

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 by Czar

  • Author
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)

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 ".:gnome:

Edited by Elixar

  • Author
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 ".:gnome:

Hahah, I understand that lol but i wanted to just know u know.

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

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.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.