August's Script Writer application

Rank: Script Writer

Reason & Motivation:
I’ve been having fun learning Java and developing scripts with RSPeer and I’d like to continue that while
improving my coding skills for the future.
Also interest in publishing premium scripts in the future and most importantly get a tag in Discord.

Experience:
Been part of botting scene on and off for a couple of years as an script user.
As for coding experience I hadn’t been coding in Java before doing scripts with RSPeer,
but I have good understanding of Python and C from school so getting a hang on language specific concepts hasn’t been too hard.

Open Source Code:
Beginner clue solver - kills goblins until clue drops and completes it after

I believe you’re viewing wrong person on SDN since I have zero scripts involving soft clay making there.

@August Whoops, my mistake. You’re right.

Hey there. Here’s a few things I noticed:

  • Avoid hardcoding components:
text = Interfaces.getComponent(203,2).getText();
group = Interfaces.getComponent(203,2).getRootIndex();
  • Avoid dangerous while loops:
       while (Dialog.isOpen()) {
            Time.sleep(Random.mid(600,1100));
            if (Dialog.canContinue()) {
                Dialog.processContinue();
            }
            if (!Dialog.canContinue()) {
                resetSteps();
            }
            resetSteps();
        }

and here:

            while(Players.getLocal().distance(answer.getPosition()) > 10) {
                Movement.walkTo(answer.getPosition());
                Time.sleep(Random.nextInt(500,2000));
            }
  • Use enums to make clue modes more clear & efficient. You used enums in a few places that looked good but didn’t in others. Specifically:
    public static void getTextClueType(String clueText){
        if (ANAGRAM_PRED.test(clueText)) {
            Log.info("Text clue: Anagram"); //Clue mode 1
            ClueMode.setClueMode(1);
        }
        if (CRYPTIC_PRED.test(clueText)) {
            Log.info("Text clue: Cryptic"); //Clue mode 2
            ClueMode.setClueMode(2);
        }
        if (CHARLIE_TASK_PRED.test(clueText)) {
            Log.info("Text clue: Charlie task"); //Clue mode 3
            ClueMode.setClueMode(3);
        }
        if (EMOTE_PRED.test(clueText)) {
            Log.info("Text clue: Emote"); // Clue mode 4
            ClueMode.setClueMode(4);
        }

    }
  • Use early returns and try to limit each loop to one action typically. This will avoid unnecessary sleeps and redundant interactions if the execute() method misses interactions. Specifically here:
    @Override
    public int execute() {
        Status.setStatus("Doing an emote clue");
        String clueText = GroupTextHelp.getText();
        if (clueText.contains("Clap") && Inventory.contains("Bronze axe")) {
            Inventory.getFirst("Bronze axe").interact("Wield");
        }
        EmoteEnum answer = EmoteEnum.getEmoteAnswer(clueText);
        Log.info("Doing emote clue");
        if (Players.getLocal().distance(answer.getPosition()) <= 2) {
            Tabs.open(Tab.EMOTES);
            answer.getEmoteComp().interact(answer.name());
            Time.sleep(3000);
            talkToUri();
            Time.sleepUntil(Dialog::isOpen,3000);
        }
        Movement.walkTo(answer.getPosition());

        return 1000;
    }

Some of the code shows that you have a good general understanding of logic and basic Java principals, but there are a few things that can be improved upon that I mentioned above. I would say make those improvements, resubmit your application, and you’ll have a yes from me. Right now it’s going to have to be a no though. Other ranks might have a different opinion. Either way, best of luck!

@ADivorcedFork Thanks for the feedback.
I went in and fixed most of the issues you brought up
Made a new enum, which sets the clue mode

one of the enum entries: EMOTE("Emote",4,"raspberry","Brugsen","Cheer","Clap","Panic","Spin");

ClueTextEnum(String type,int clueMode,String... keyText) {
    this.type = type;
    this.clueMode = clueMode;
    this.keyText = keyText;
}

and the function that sets cluemode:

private static void testClueText(String clueText, ClueTextEnum textEnum) {
    for (int i = 0; i <= textEnum.getKeyText().length - 1 ; i++) {
        if (clueText.contains(textEnum.getKeyText()[i])) {
            Log.info("Text clue: "+textEnum.getType());
            ClueMode.setClueMode(textEnum.getClueMode());
        }
    }
}

and I call the function with 4 different values
testClueText(clueText, EMOTE);

Replaces text and group from your first point by this

GroupTextHelp.setText(Interfaces.getComponent(203,2).getText());
GroupTextHelp.setGroup(Interfaces.getComponent(203,2).getRootIndex());

Thanks again for the feedback and I understand if the decision is based off the first version :smiley: