Jump to content
×
×
  • Create New...

[Complete] Application for Script writer 1


Recommended Posts

Hello, i would like to publish my Runecrafting script, I have ran it for multiple hours without it crashing.

image.png.85232aaca7622004c6eb37876182cbfb.png

 

Source: https://github.com/Gamburger1/Runecrafting-spinbot

Supports:

- Air runes

- Mud runes

- Lava runes

More runes can be added in the future, but this script was meant for a easy way of reaching the requirements of crafting blood runes at Arceuus.

 

Requirements:

- Have all required items in bank in the same tab for fastest experience.

- Zoom camera all the way out for fastest experience.

Air runes: just have air tiara and pure essence either in bank or equipped/inventory.

Mud runes: Just start the script at castle wars. Balloon transport system unlocked for varrock and castle wars.

Lava runes: Just start the script at castle wars.

 

 

Hopefully this can become somewhat useful to the community.

Link to post
Share on other sites

  • Moderators

This is quite nicely written, there's some things to change or look at below.

Good structure to your files, nice and modular making it simpler and easier for you to maintain and debug in the future.

This script offers the opportunity to show good overall use of the API with a few different aspects covered, moving/walking, objects, inventory, banking, equipment.

In terms of feedback, from what I can tell, you have a fear of using objects. in almost every task you use an objects tile matrix and interact with that which isn't really how it should be done.

If you want to interact with an object at a specific tile, you can pass at(Tile). For example

Objects.stream().at(new Tile(3532, 2452, 0)).name("Door").interact("Open");

 

                                                                                                                                                                          

 

Is there a reason why you don't use the Bank API to interact with the bankers and bank booths?
https://github.com/Gamburger1/Runecrafting-spinbot/blob/3e63bfda77f1a5911c2c34e80bf0a08db33fc9ca/src/Runecrafting/AirRuneTasks/ClickBank.java#L26

return Objects.stream().name("Bank booth").nearest().first().inViewport()
vs
return Bank.inViewport()

 

                                                                                                                                                                          

 

I felt that you have a lot of repeated code and could probably do with generifying it.

For example here;

https://github.com/Gamburger1/Runecrafting-spinbot/blob/3e63bfda77f1a5911c2c34e80bf0a08db33fc9ca/src/Runecrafting/MudRuneTasks/WithdrawEssence.java#L65

I don't see why you need 4 different methods for the different stamina potions, lots of different options but as an idea;

String stam = "";
...
...
...
 if (Movement.energyLevel() < RUN_ENERGY) {
            stam = "";                         
            if(Bank.stream().name("Stamina potion(1)").count()>0) {
                stam = "Stamina potion(1)";
            }
            else if(Bank.stream().name("Stamina potion(2)").count()>0) {
                stam = "Stamina potion(2)";
            }
            else if(Bank.stream().name("Stamina potion(3)").count()>0) {
                stam = "Stamina potion(3)";
            }
            else if(Bank.stream().name("Stamina potion(4)").count()>0) {
                stam = "Stamina potion(4)";
            }
   	    if(!stam.equals("")){
   			drinkStamina(stam);
   	    }
        }
...
...
...
   private void drinkStamina(String stamina){
        System.out.println("Run energy minimum is " + RUN_ENERGY + " Withdrawing stamina potion and drinking it");

        Bank.withdraw(stamina, 1);
        Condition.wait(() -> Inventory.stream().name(stamina).count() == 1, 150, 15);


        Inventory.stream().namne(stamina).first().interact("Drink");
        Condition.wait(() -> Inventory.stream().id(VIAL).count() == 1, 150, 15);

        Bank.deposit(229, 1);
        Condition.wait(() -> Inventory.stream().id(VIAL).count() < 1, 150, 15);
    }

 

Your tasks use a lot of the same stuff, you've got a different clickBank task for each type of rune, a different crafting task for each type of rune when a lot of the actions are the same if not similar.

 

A good start but just some bits to work on. Feel free to @me when you've updated it etc.

Link to post
Share on other sites

  • Dan changed the title to [On Hold] Application for Script writer 1

Hello I updated the github with the changes you asked for.

First off, I do have some problems when interacting with objects, because the script will not interact with certain object for me (dont know if anyone else has this problem). In this example as you can see the ruins object has always been problematic for me, it will randomly stop clicking the object as it wont be visible to the script. I have tested with "System.out.println" and for some reason the ruins object is not visible for me. I tested this again today because this was a problem I had with v1 and the problem still persists, I therefore decided to keep the interaction as is or else i wont be able to use my own script xD. And for the bank interaction, I noticed when I used "bank.open()" on the bank chest it would miss every other try so I decided to leave that aswell as it worked alot better for me.

For the repeated code, I generified as much as I was able to, for example Mudrunestask only has 3 tasks now and lavarunestasks doesent exist. As you can see i wasnt able to generify the ruins task, and the balloon tasks on mud runes. I also mostly left the air rune tasks alone as it would be abit tedious as I want to add the rest of the f2p runes. 

Thank you for the feedback and suggestions to improve my code, I am learning alot from this.

 

Link to post
Share on other sites

  • Moderators

While I can understand the frustrations of some objects not working, using a workaround rather than trying to solve the problem doesn’t help anyone. I know I gave you the example script for my barbarian fishing which used the npc tile matrix to interact with, but that was written back when we had no active devs fixing these issues.

Now we do. While having a script that works is great but if there’s something that isn’t working as intended you should be trying to fix it or get it fixed rather than working around the issue.

@_RickDo you have issues when loading the mysterious ruins? I vaguely remember there being something that you changed recently so wasn’t sure if that’s now all good. 
 

Also, @Kebab King can you check the model of the basket? If the model isn’t correct or is absent then that will need looking at but otherwise you should be using the Object stream to interact with objects and not their tiles.

I know there’s been a bit of a bugged update yesterday so testing things now probably won’t be a good idea.

Glad to see the Bank api being used and some generifying taking place however.

Link to post
Share on other sites

@dan the Basket only had a model when I stood right next to it, I interacted directly with it and it worked for about 1 or 2 runs and then stopped working like it usually does. I also changed back to interacting with ruins and that worked for about 10 runs without a problem. I think we should wait for the update like you said, I will test it then and let you know, could be that the issues came back after the client broke as I never tried it after V2 released.

image.png.e5460a8baebece0fd39c304bc1a1c162.png

 

Link to post
Share on other sites

  • Moderators

It'll only show the model when you're right next to it otherwise rendering every single model will take too much resource on the client so the model is fine.

The update should hopefully be out soon but you should probably try and debug the issue. You don't have any printouts in the script so if anyone provides you with a logcat if it were public, you'd have nothing to see where stuff went wrong.

A simple check of the return from the interact() would be better than waiting unecessarily. Interact() returns a boolean as to whether it was successfully interacted with or not, if it's true, enter conditional wait, otherwise, let the poll() loop the task again for another attempt.

Something else you might want to try is waiting till you're no longer in motion before trying to interact as you can probably imagine, a static object is much easier to interact with than a moving one.

https://github.com/Gamburger1/Runecrafting-spinbot/blob/f6adcad7426a7173822d45a7b239eb13ba63d02b/src/Runecrafting/MudRuneTasks/ClickBalloon.java#L32

I also just realised that in this task, you don't actually have any checks to see which action you should be carrying out. Line 31 will wait 4.5 seconds before continuing if the interaction failed, but I mentioned how to resolve this above. However you don't actually check if the widget on line 32 is even visible before trying to click it, if it's not then you're waiting another 4.5 seconds so if you miss the first interaction, you're waiting 9 seconds each loop.

While you've split your tasks down to a very granular level, multiple actions per task should still have if checks to ensure you're ready to complete the next action in the task. 

Link to post
Share on other sites

Hello again boss, I listened to your feedback and managed to fix all the issues you were concerned about. 

First off I added print outs to all the functions/actions, some of them are in the functions if u cant find them.

I also added the check of the return on most of my interact() functions in the script, ty for the tip.

I completely redid the click balloon/walk to balloon tasks and made them into one task, these were untouched since v1 and it was honestly my bad for completely ignoring them.

Also I made both mud rune and lava rune completely generified as I found a hotfix for the ruins issue, when I did not declare the object beforehand it would work, is the mysterious ruins not a gameObject?

I also removed the matrix from basket, this was still a bit inconsistent for me but I will leave it and see if other people have the same issue.

I left Air runes tasks mostly untouched, as I still think it will be more tedious to add the other rune's in the future if I generify it together with the others.

Also added current RC level to GUI, so people don't have to pause and check stats.

Assigned the talisman, tiara and rune on start to a global variables instead of doing it every time time in the withdraw task, don't know if this is a better option.

image.png.5bc895da4a0030d2ca19d851104dcb7e.png

If there's anything else that need's to get fixed, let me know and ill give it a crack.

 

 

Edited by Kebab King
Link to post
Share on other sites

  • Moderators
8 hours ago, Kebab King said:

Hello again boss, I listened to your feedback and managed to fix all the issues you were concerned about. 

First off I added print outs to all the functions/actions, some of them are in the functions if u cant find them.

I know it's tricky to get logs etc atm but one day you'll be thankful, nice work on that.

 

8 hours ago, Kebab King said:

I also added the check of the return on most of my interact() functions in the script, ty for the tip.

👍

8 hours ago, Kebab King said:

Also I made both mud rune and lava rune completely generified as I found a hotfix for the ruins issue, when I did not declare the object beforehand it would work, is the mysterious ruins not a gameObject?

So a few things to mention here, you can tell it's a game object because you're refering to it in the game object stream using Objects.stream().name("Mysterious ruins").nearest().first().
However, I never saw your code prior to using the tilematrix so I can't comment too much but declaring a game object is also known as caching. Caching something stores the data at it's current state. If the object isn't loaded/valid etc then you're caching a GameObject.Nil and therefore it has no information to pass to your object.interact("Enter") as it's not loaded the object to interact with. Just food for thought but I'd suggest caching an object if you have multiple calls to do with it, for example, 

                 if(Objects.stream().name("Mysterious ruins").nearest().first()!=GameObject.getNil()){
                    if (Objects.stream().name("Mysterious ruins").nearest().first().inViewport()){
                        Objects.stream().name("Mysterious ruins").nearest().first().interact("Enter");
                    } else {
                        if(Objects.stream().name("Mysterious ruins").nearest().first().tile().distanceTo(Players.local())>10){
                            Movement.step(Objects.stream().name("Mysterious ruins").nearest().first());
                        } else {
                            Camera.turnTo(Objects.stream().name("Mysterious ruins").nearest().first());
                        }
                    }
                }

//*******VS
GameObject ruins = Objects.stream().name("Mysterious ruins").nearest().first();
                if(ruins!=GameObject.getNil()){
                    if (ruins.inViewport()){
                        ruins.interact("Enter");
                    } else {
                        if(ruins.tile().distanceTo(Players.local())>10){
                            Movement.step(ruins);
                        } else {
                            Camera.turnTo(ruins);
                        }
                    }
                }

As you can see, the first example accesses the object stream 6 times, each time is a fresh call filtering out all other objects every time. If each object call is 100ms (example numbers) then to complete this it'll take 600ms alone just to access the objects data.

The second example accesses the stream once and stores the data. However it's checking if it's Nil before continuing, if it's nil, it's not found the object and will then proceed to loop the tasks and  come back to it, hopefully then, you're in range of the object in order to cache it and therefore accessing the stream once @100ms and then accessing the data from memory near instantly.

With that being said, you've shown a real improvement over the last few days and weeks in your learning journey and I'm happy to congratulate you on joining the team.

@const_ do your thing!

  • Thanks 1
Link to post
Share on other sites

  • Dan changed the title to [Complete] Application for Script writer 1
 Share