Jump to content

C0de help


Recommended Posts

Posted (edited)

hi guys !

trying to write my own script , 

could you please show me an example of how to interact with a entity ie oak tree (correctly) 

once i define a entity ie "oak tree" do i have to write full name in other lines? or just "tree"

private State getState() {
        Entity Oak_tree = getObjects().closest("Oak tree");
        if (!inventory.isFull())
            return State.BANK;
        if (Oak_tree != null)
            return State.CHOP;
        return State.WAIT; 

 

a snippet of how to change camera angle would me epic also! 

i have 
                this.client.rotateCameraPitch(50 + random(40));

the rotatecamerapitch part has no reference :\ 

would appreciate any help , thank you ! 

Edited by Prismo
Posted
9 minutes ago, Prismo said:

hi guys !

trying to write my own script , 

could you please show me an example of how to interact with a entity ie oak tree (correctly) 

once i define a entity ie "oak tree" do i have to write full name in other lines? or just "tree"

private State getState() {
        Entity Oak_tree = getObjects().closest("Oak tree");
        if (!inventory.isFull())
            return State.BANK;
        if (Oak_tree != null)
            return State.CHOP;
        return State.WAIT; 

 

a snippet of how to change camera angle would me epic also! 

i have 
                this.client.rotateCameraPitch(50 + random(40));

the rotatecamerapitch part has no reference :\ 

would appreciate any help , thank you ! 

RS2Object oak = getObjects().closest("Oak tree");

^after doing this ur oak tree will be "oak" in the script and use the above line to define it

so example:

 if (oak != null && oak.interact("Chop")) {

^ now it will chop a oak (oak = Oak tree) if u get what i mean ? 

 

also camera change:

getCamera().mouseRotateToYaw((100));

 

hope this helps you out :gnome:

  • Like 1
Posted (edited)
public boolean chopTree(String treeName) { //run this code until it returns a value

        if (!myPlayer().isAnimating()) { //WE ARE NOT CUTTING THEN WE CUT
            status = "Waiting for Tree.";
            RS2Object tree = getObjects().closest(treeName);
            if (tree != null) {
                if (tree.interact("Chop down")) {
                    status = "Cutting Tree.";
                    new ConditionalSleep(3500, 600) {      //sleep until chopping
                        @Override
                        public boolean condition() {
                            return myPlayer().isAnimating(); // We're chopping/Animating.
                        }
                    }.sleep();
                    return true; //we have clicked the tree!
                }
            }
        }

        return false;

    }

Here's my chopping tree code if it's any use.

Edited by HeyImJamie
  • Like 3
Posted
7 minutes ago, Prismo said:

ah yes! it has all become clear now! :D nah thanks heaps guys ! 1+

@HeyImJamie Ty for code mate, i am not quite at that level, with the conditions and all...  ty for post !

Copy it if you need. All you need to do is store a tree name as a String, and then in the loop is call chopTree(STORED_STRING_HERE). Saves you having to re-type it for multiple trees :) 

  • Like 2

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