Jump to content

How can i use ids instead of string names


chardragon

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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