Jump to content

Listener


Joseph

Recommended Posts

I would like to add in a inventory Listener

 

 

If you know how to multithread you can easily make a listener in a new class that implements Runnable. You can basically make this new thread constantly watch your inventory slots and check if anything changes, or whatever you are trying to make it do. Just make a new class that implements Runnable, make that class do whatever you want, then in Script thread, Thread thread = new Thread(ClassName) then start the thread. I haven't used that in a while, but its something like that. Just look up the basics of multi threading and you can easily find how to make it. ^_^

Link to comment
Share on other sites

Whatever you do, at least add a small sleep in between inventory updates. You don't want to kill your CPU because you want to be notified the exact millisecond your inventory changes. Waiting for even just a second will consume such little resources it won't even make a noticeable impact on the CPU usage of your script.

Link to comment
Share on other sites

Whatever you do, at least add a small sleep in between inventory updates. You don't want to kill your CPU because you want to be notified the exact millisecond your inventory changes. Waiting for even just a second will consume such little resources it won't even make a noticeable impact on the CPU usage of your script.

How big of a sleep you think it's good, 200 mil second

Link to comment
Share on other sites

when you have a change of items in the inventory.

 

tbh im still a little confused on how to set it up. Ive tried so many different things

 

If you are going to compare inventories for equality, couldn't you just use these lines (at appropriate places of course,not stacked like this tongue.png)?

 

Item[] compareThis = getInventory().getItems();

 

Item[] withThis = getInventory().getItems();

 

boolean equaliThis = compareThis  != null && withThis != null && Arrays.equals(compareThis withThis);

Edited by Botrepreneur
Link to comment
Share on other sites

when you have a change of items in the inventory.

 

tbh im still a little confused on how to set it up. Ive tried so many different things

Depends what you're attempting to monitor and how you want to receive notifications about changes. This should help you get started (or provide an answer for you): http://osbot.org/forum/topic/51856-inventory-monitor-keep-live-track-of-your-items/

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