Jump to content

[New!] Store class library - Access a store easily


Neodork

Recommended Posts

Hello OSBot scripters,
 
Today I bring to you, a new store class library. I plan to maintain and modify this to work flawlessly. Until the OSBot team is able to add it into their API. I happen to know that there is already an library like this. However that library wasn't maintained or offered support for which I plan to do. Any feedback given will be appreciated and considered.
 
1. Setting up:
    A. You add the class files to your source and compile them with it.
    B. You import the Jar as an external library and include it with your script for usage.
 

 
 
2. Store example:

//Make a store instance
Store store = new Store(this.bot.getAPI());

//Check if store is open
if(store.isOpen()){
//Buy something
}else{
//Open the store
}

3. Item example:




//get item from the store
StoreItem item = store.getStoreItem("Bronze arrow");


//interacting with the item
if(item != null && item.getAmount>0){
    item.interact("Buy 10");
    sleep(1000);
}

 


Link:
Store.java
StoreItem.java

Releases:

Changelogs:

- Changed the return type of close to void
- Fixed buying 2nd row items.

 

@Merccy - Base concept
@bfir3 - Accurate item amount.

Edited by Neodork
  • Like 2
Link to comment
Share on other sites

StoreItem#interact(String action) is bad. 

 

Better

 

StoreItem#buy(int amount). You handle the rest.

 

I didn't check the source so this method may exist but if it doesn't make it.

 

 

I'm guessing StoreItem extends w/e the item class in OSBot is (I don't develop for this client).

 

StoreItem i = Inventory.get(id).

 

StoreItem.sell(int amount) 

Edited by Assume
Link to comment
Share on other sites

StoreItem#interact(String action) is bad. 

 

Better

 

StoreItem#buy(int amount). You handle the rest.

 

I didn't check the source so this method may exist but if it doesn't make it.

 

 

I'm guessing StoreItem extends w/e the item class in OSBot is (I don't develop for this client).

 

StoreItem i = Inventory.get(id).

 

StoreItem.sell(int amount) 

 

Actually storeItem.interact(String action); is the right way to go, because it is not necessarily used for buying, you can also select the value action for example. In this case the interact method can be used to select all options in the store. I would not understand the logic of passing an integer argument as the is no Buy X action in a store. 

I don't intend to use all fields the OSBot so I didn't extend it. Also casting from a super class to a subclass is not possible.

Link to comment
Share on other sites

I might be wrong, but cant you just use Store store = new Store(this);

 

 

Pretty sure using this will just use everything. Meaning, less typing and less confusing.

I could do that, but in that case I would be passing an instance of Script to the Store library. There is no need for us to use the methods inside the Script class all we need is to use the MethodProvider which is the super class of Script. But if you prefer to pass the instance of the class Script to the Store library I won't stop you. You're able to cast from sub to super class so there will be no problem in doing so.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...