Jump to content

How can i use ids instead of string names


Recommended Posts

Posted

I am trying to make a simple agility script for Faldor which has two consecutive "Jump Ledges" and the bot currently chooses the previous one as its the closest whern using

 

private String[] names = {"Rough wall", "Tightrope", "Hand holds", "Gap", "Gap", "Tightrope","Tightrope","Gap","Ledge","Ledge","Ledge","Ledge","Edge"};
//    private int[] names = {14898, 14899, 14901, 14903, 14904, 14905,14911,14919,14920,14921,14923,14924,149251};
    Entity previous;

    @Override
    public void onStart() {
        getExperienceTracker().start(Skill.AGILITY);
    }

    @Override
    public int onLoop() throws InterruptedException {
        int starting = getExperienceTracker().getGainedXP(Skill.AGILITY);
        Entity nextObj = getObjects().closest(obj -> Arrays.asList(names).contains(obj.getName()) &&
                Arrays.asList(actions).contains(obj.getActions()[0]) &&
                (getMap().canReach(obj)) &&
                !obj.equals(previous));
        log(nextObj.getId());

 

I am trying to implement the array of ids and have tried

 

Entity nextObj = getObjects().closest(obj -> Arrays.asList(names).contains(obj.getId()) && Arrays.asList(actions).contains(obj.getActions()[0]) && (getMap().canReach(obj)) && !obj.equals(previous)); However it just creates nulls and breaks the script i was wondering how can i overcome this / the best way to achieve this.

Posted (edited)

Ids, work exactly the same as names tbh, but that's most likely not going to solve your issue

Make like an Enum with an RooftopArea + Object name + position + action and use that instead :)
Add some area checks in there to know which roof you are on and which object to interact with so you can control what's going on.

Edited by Khaleesi
Posted
On 8/11/2023 at 8:39 PM, Khaleesi said:

Ids, work exactly the same as names tbh, but that's most likely not going to solve your issue

Make like an Enum with an RooftopArea + Object name + position + action and use that instead :)
Add some area checks in there to know which roof you are on and which object to interact with so you can control what's going on.

Hi Thanks for the reply I actually managed to solve it by doing this getObjects().closest(obj -> Arrays.asList(ids).contains(Integer.toString(obj.getId())) and then making it an array of strings instead I'm not really sure why it wouldn't work with ints but there we go

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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