Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Scripting Help


    pharaoh

    Recommended Posts

    Posted

    hi, i am stuck on how to properly check for a Inventory change, i tried to find a few examples on the forums but i couldn't find any updated ones.

    what i am trying to do is collect the number of items made, but there is no dialogue or game message, just the item stack in the inventory increasing. i tried to look at the InventoryMonitor class and utilize it but it was not working. I know there is the InventoryListener i can implement but i am not sure how i would fill it out.

    as well, i am stuck on my GUI not showing once again. i am not sure what i messed up but ive looked through multiple gui examples and mine matches them but it does not show still.

    main class - https://gist.github.com/847fb19ac56c565c3f9a543134dcf4d4

    gui class - https://gist.github.com/1da0df8fd5b9a409e6d10a61eec9a7df

    Posted
    29 minutes ago, pharaoh said:

    what i am trying to do is collect the number of items made, but there is no dialogue or game message, just the item stack in the inventory increasing. i tried to look at the InventoryMonitor class and utilize it but it was not working. I know there is the InventoryListener i can implement but i am not sure how i would fill it out.

     

    InventoryListener is an interface so to use it youd do:

    public class PBlueDye extends TaskScript implements InventoryListener

    then you will override its method onItemChange(Item[] changes), something like this would be for your use case

    onItemChange(Item[] changes) {
      for (Item i : changes) {
      	if (I.getAmount > 0) { // if you are banking or dropping the item the amount will be negative, so you wont want to add to count
          // maybe check i.getName is the item you want to be counting
          count++ // this is a placeholder var for whatever you use to count items made
        }
      }
    }

     

    Posted

     

    56 minutes ago, pharaoh said:

    as well, i am stuck on my GUI not showing once again

    1 thing i noticed

    your constructor calls initComponents()
    initComponents has v in it, thats just for onStart of your script, and i think its would cause a loop because creating a new instance of DyesGUI makes a new instance of DyesGUI forever.

    SwingUtilities.invokeLater(() -> new DyesGUI().setVisible(true));

     

     

    Posted
    15 hours ago, camalCase said:

     

    1 thing i noticed

    your constructor calls initComponents()
    initComponents has v in it, thats just for onStart of your script, and i think its would cause a loop because creating a new instance of DyesGUI makes a new instance of DyesGUI forever.

    SwingUtilities.invokeLater(() -> new DyesGUI().setVisible(true));

     

     

    v = void? i let jformdesigner create the code for me and it looks like how intellij does code creation too for swing. i had added the code you suggested but it still wont load and the console isnt throwing any errors for it that i can see.

    Posted
    17 hours ago, pharaoh said:

    as well, i am stuck on my GUI not showing once again. i am not sure what i messed up but ive looked through multiple gui examples and mine matches them but it does not show still.

    main class - https://gist.github.com/847fb19ac56c565c3f9a543134dcf4d4

    gui class - https://gist.github.com/1da0df8fd5b9a409e6d10a61eec9a7df

    You're recursively creating infinite amounts of GUIs in line 130 of DyesGUI (borderline bricked my system when I ran it, gg). Runs fine for me after removing that

    Posted
    6 hours ago, SubCZ said:

    You're recursively creating infinite amounts of GUIs in line 130 of DyesGUI (borderline bricked my system when I ran it, gg). Runs fine for me after removing that

    Okay so I've removed that line but i still do not see it pop up... i just have it to this now.

    public DyesGUI gui;
    
    @Override
    public void onStart() {
        SwingUtilities.invokeLater(() -> {
         new DyesGUI().setVisible(true);
         log("gui visible");
    
        });
    
        log("started");
    }

     

    it will log start in the console but i dont see a new window from dreambot regarding the gui so im not sure. is it just hidden in a corner on my desktop possibly?

    Posted
    7 hours ago, pharaoh said:

    v = void?

    v was meant to be a down arrow pointing to the swingutilites invoke later it just didnt format so well.

     

    this line is the only one that gives me problems, load images from imgur and null check them

    collectLeafsButton.setIcon(new ImageIcon(Objects.requireNonNull(getClass().getResource("/script/assets/icons/woad_leaf.png"))));
    

     

    Posted
    36 minutes ago, camalCase said:

    v was meant to be a down arrow pointing to the swingutilites invoke later it just didnt format so well.

     

    this line is the only one that gives me problems, load images from imgur and null check them

    collectLeafsButton.setIcon(new ImageIcon(Objects.requireNonNull(getClass().getResource("/script/assets/icons/woad_leaf.png"))));
    

     

    That was it. Commented that line out because that image is missing right now and it popped up. :') Thank yall tons

    Ny5M0JN.png

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.