Jump to content

New scripter says hello to OSBOT ;)


Appelflapjes

Recommended Posts

Hi welcome and good luck!

Your first script looks promising smile.png

Alright, I briefly checked your script wink.png

First of all when you script it's important to use an IDE such as eclipse or IntelliJ IDEA. Using IntelliJ you can jump to the (decompiled) implementation of an API method, so you can actually see what it does. There's this line in your script: while (bank.isOpen()){ bank.close(); ...  if we check the implementation, bank.close() already checks if the bank is open. I use this very often, perhaps it's useful for you as well to understand what exactly the api methods do.

Arrays.asList(stairs.getDefinition().getActions()).contains("Climb-down") could be simplified into stairs.hasAction("Climb-down")

You could also check out the doorHandler api, it most likely support gates. You specify what position you want to walk to and the doorhandler opens any doors/gates between the player and the target position.

There are a lot of nested if statements tongue.png I remember I did the same thing when I first started scripting. It's very difficult to debug, so you might want to avoid it wink.png

 

Thanks wub.png .

I use Eclipse, so thats okay i assume wink.png.

 

• @ the Close bank if it's still open. Yeah sounds logical actually wink.png. But I'm going to stay at the low level for a while. Going too deep will make me kill myself and quit this wink.png

 

• Yeah I got that from someone... (Thank god for copy-paste). It indeed saw a bit overcomplicated to me, but it does the job. Will change it.

 

• Will look into that the next basic script if it would require it ! Thanks for the tip

 

• Is there a way to make it cleaner? I mean having like 7 If statements to shear a sheep is indeed messy.

 

 

 

Welcome!

Thanks buddy smile.png

party in my pants

invite only sry

 

What beverages are available there ^^?

 

Buying invite 1M OSRS GP.

Link to comment
Share on other sites

You could use a filter, some info: http://osbot.org/forum/topic/71713-objectsgetint-int-and-grounditemsgetint-int-not-working/

What you're doing right now is get the closest sheep and then check if it meets a few requirements.

You could do this using a filter like this (not tested):

 

    public boolean Shear() {

        if (myPlayer().isAnimating())
            return true;

        Area SHEEP_PEN = new Area(3193, 3257, 3211, 3276);
        NPC sheep = getNpcs().closest(
                npc -> npc.getName().equals("Sheep") &&
                        SHEEP_PEN.contains(npc) &&
                        npc.hasAction("Shear"));

        return sheep != null && sheep.interact("Shear");
    }

You basically say give me the closest npc which: has the name "Sheep", is located in the SHEEP_PEN area and has an action "Shear". interact should then turn the camera if needed. 

Link to comment
Share on other sites

You could use a filter, some info: http://osbot.org/forum/topic/71713-objectsgetint-int-and-grounditemsgetint-int-not-working/

What you're doing right now is get the closest sheep and then check if it meets a few requirements.

You could do this using a filter like this (not tested):

 

    public boolean Shear() {

        if (myPlayer().isAnimating())
            return true;

        Area SHEEP_PEN = new Area(3193, 3257, 3211, 3276);
        NPC sheep = getNpcs().closest(
                npc -> npc.getName().equals("Sheep") &&
                        SHEEP_PEN.contains(npc) &&
                        npc.hasAction("Shear"));

        return sheep != null && sheep.interact("Shear");
    }

You basically say give me the closest npc which: has the name "Sheep", is located in the SHEEP_PEN area and has an action "Shear". interact should then turn the camera if needed. 

 

 

Thanks for the tip.

But one quick question, why especially is your way better? (You forgot the WHY part of tips ;) )

It looks neater, but would it be faster or something?

Is it better to return a Boolean instead of repeating a void? Or do you mean I should do something with 'Shear = true' in the rest of the code ;)?

 

Welcome to OSBot! If you need anyone to test out your scripts, I'll be happy to.

-happy bottting& scripting

 

Do you know how to turn code => OSBot Script?

I'll PM you my Skype if I'm realeasing some stuff. (First few scripts will be low level focused, so level 3's all the way!)

Link to comment
Share on other sites

Thanks for the tip.

But one quick question, why especially is your way better? (You forgot the WHY part of tips wink.png )

It looks neater, but would it be faster or something?

Is it better to return a Boolean instead of repeating a void? Or do you mean I should do something with 'Shear = true' in the rest of the code wink.png?

 

 

Do you know how to turn code => OSBot Script?

I'll PM you my Skype if I'm realeasing some stuff. (First few scripts will be low level focused, so level 3's all the way!)

Well if it is any faster the speed improvement is negligible. The main advantage is that it's clean, and you can't really do anything wrong in this method as long as your filter is defined correctly (and of course interact works).

In this case it doesn't really matter if you return a void or boolean, just did that because interact returns a boolean ^^

Link to comment
Share on other sites

Well if it is any faster the speed improvement is negligible. The main advantage is that it's clean, and you can't really do anything wrong in this method as long as your filter is defined correctly (and of course interact works).

In this case it doesn't really matter if you return a void or boolean, just did that because interact returns a boolean ^^

 

It indeed does look neater (but seems more difficult with filters (which i've never used before))!

 

Will try to figure that out ;).

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