1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Working with the actionbar

Discussion in 'Developer Support' started by Geashaw, Jan 16, 2015.

  1. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,429
    Likes Received:
    252
    Currently looking at MaxiAlcher but I can't seem to find out how to interact with a specific actionbar slot.

    I have the following (which does nothing) :
    Code (Text):
    1. ActionBar.getActions("Make Leather").get(0).activate();
    Can you give me a pointer?
     
  2. Philosobyte

    Joined:
    Dec 18, 2014
    Messages:
    398
    Likes Received:
    79
    Spells and items currently have null values for their name, activatable boolean, and ready boolean on the action bar. This is according to the Action Bar tab of the development toolkit. In fact, I don't know how you're not getting a nullpointer. To remedy this, I would do
    Code (Text):
    1.  
    2. SlotAction action = ActionBar.getFirstAction(MAKE_LEATHER_ID);
    3. //after a nullcheck
    4. Keyboard.typeKey(action.getSlot().getKeyBind());
    5.  
    since activate() isn't working. At least, not for Geashaw and me.
     
  3. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,429
    Likes Received:
    252
    Strangely this is not working either, I have the Make Leather spell anywhere on my abilitybar (since getKeyBind() indeed returns the 'key').

    It does somehow not 'typeKey'.
     
  4. Philosobyte

    Joined:
    Dec 18, 2014
    Messages:
    398
    Likes Received:
    79
    Is it the alt + tab issue? Turn on keyboard input, click somewhere in the game window, then press alt. See if it works after that.
    Whenever you want to alt + tab away from the client, make sure keyboard input is turned off. Or else the alt key gets stuck in the client.
     
  5. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,429
    Likes Received:
    252
    I maximized the window and now it seems to click.

    Code (Text):
    1.  
    2. SlotAction action = ActionBar.getFirstAction(MAKE_LEATHER_ID);
    3. SpriteItem hide = Inventory.getItems(GREEN_HIDE).first();
    4.  
    5. if (action != null && action.isActivatable()) {
    6.     if (Keyboard.typeKey(action.getSlot().getKeyBind())) {
    7.       if (hide != null && hide.interact("Cast")) {
    8.      
    9.       }
    10.    }
    11. }
     
  6. Defeat3d

    Defeat3d Primate

    Joined:
    Oct 30, 2014
    Messages:
    3,072
    Likes Received:
    1,894
    Code (Text):
    1.         final SlotAction drink = ActionBar.getFirstAction("Jug of wine");
    Code (Text):
    1.                     drink.activate();
     
  7. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,212
    Likes Received:
    1,042
    For magic spells in RS3, you can use the Powers.Magic enum, and there's a similar Magic enum for OSRS. They both have an activate() method that will attempt to use the actionbar, or if that fails it will use the magic tab.

    Also you can replace "Keyboard.typeKey(action.getSlot().getKeyBind())" with action.activate() :)
     
  8. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,429
    Likes Received:
    252
    Yeah, this should then work right?

    Code (Text):
    1. /**
    2.  * Used to select the Make Leather spell from the ability bar.
    3.  */
    4. public void selectSpell() {
    5.     SlotAction action = ActionBar.getFirstAction(MAKE_LEATHER_ID);
    6.  
    7.     if (action != null && action.isActivatable()) {
    8.         if (Keyboard.typeKey(action.getSlot().getKeyBind())){
    9.             // Sleep until selected.
    10.             System.out.println("Selecting Make Leather.");
    11.             Execution.delayUntil(() -> action.isSelected(), 2000);
    12.         }
    13.     }
    14. }
     
  9. SlashnHax

    Joined:
    Dec 10, 2014
    Messages:
    3,212
    Likes Received:
    1,042
    Yeah it should work, but
    Code (Text):
    1.  
    2. Powers.Magic.Lunar.MAKE_LEATHER.activate();
    3.  
    is another way to activate MAKE_LEATHER and it will use the actionbar or the actual magic spell in the magic tab if it's not in your actionbar
     
    Geashaw likes this.
  10. Infinite Inferno

    Infinite Inferno The Pip Collector

    Joined:
    Sep 14, 2014
    Messages:
    445
    Likes Received:
    122
    You can just do this:
    Code (Text):
    1.  
    2. Final SlotAction makeLeather = ActionBar.getFirstAction("Make Leather");
    3. if(makeLeather != null && !makeLeather.isSelected() && makeLeather.isReady){
    4.     if(makeLeather.activate()){
    5.         Execution.delayUntil(makeLeather::isSelected(),4000);
    6.     }
    7. }
     
  11. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,938
    Likes Received:
    1,266
    Hey @Geashaw you should join the dev chat. Add me on Skype - runemate. (with the period) - and I'll throw you in the chat. :)
     

Share This Page

Loading...