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.

Scripting Help

Featured Replies

which is syntactically correct

 

 if(!getInventory().isFull()){

 

or

 

 

 if(!client.getInventory().isFull()){

Edited by javant

They're both just references to the instantiation of the Inventory class in MethodProvider. Although there's no reason in doing client.getInventory() (Client isn't even a subclass of MethodProvider so I'm not sure how you'd get this.client.inventory anyways), that'd be like  doing this.bank.getInventory(). 

 

There's no reason to access a subclass of MethodProvider through another subclass.

With Script being a subclass of MethodProvider, you have direct access to all of its reference variables and methods.

 

 

Edited by Allen

we dont use client.inventory any more use this:

if(!inventory.isFull())
{
   // do this
}

 

we dont use client.inventory any more use this:

if(!inventory.isFull())
{
   // do this
}

 

you should use inventory's getter

getInventory()

why when we had that before and everyone complained about it. so it was shortened to inventory dot do what you want. Whats the point in going the long way round. Use inventory dot. its got all you need within it. Served my needs since osb2 started perfectly.

why when we had that before and everyone complained about it. so it was shortened to inventory dot do what you want. Whats the point in going the long way round. Use inventory dot. its got all you need within it. Served my needs since osb2 started perfectly.

 

Well it's better to practice encapsulation, because (Not my words):

 

Encapsulation can be described as a protective barrier that prevents the code and data being randomly accessed by other code defined outside the class. Access to the data and code is tightly controlled by an interface.

The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code.

Benefits of Encapsulation:
  • The fields of a class can be made read-only or write-only.

  • A class can have total control over what is stored in its fields.

  • The users of a class do not know how the class stores its data. A class can change the data type of a field and users of the class do not need to change any of their code.

Hope this helps elaborate a little bit more.

mind bogglingly boring. Never caused problems with my scripts. But a'lass i love your code definition snippets NotoriousPP <3

why when we had that before and everyone complained about it. so it was shortened to inventory dot do what you want. Whats the point in going the long way round. Use inventory dot. its got all you need within it. Served my needs since osb2 started perfectly.

 

Inventory is a class variable, getInventory() is a method that retrieves the variable in question.

Both actually refer to the same value.

 

getInventory() might perform some safety checks on the value in question, I don't think it does (but it might in the future).

 

If there's a getter method available for a variable it's common and safe practice to use that method instead of calling the variable directly.

 

Don't use inventory, use getInventory().

Inventory is a class variable, getInventory() is a method that retrieves the variable in question.

Both actually refer to the same value.

getInventory() might perform some safety checks on the value in question, I don't think it does (but it might in the future).

If there's a getter method available for a variable it's common and safe practice to use that method instead of calling the variable directly.

Don't use inventory, use getInventory().

Thats the problem of a non open source api.

Edited by Soldtodie

In a typical world, only the getter would be public (getInventory()). No idea why it was designed like this, I'd have to look and speculate why.

Guest
This topic is now closed to further replies.

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.