Jump to content
CyberFish

My logic looks correct but it doesn't work propperly.

Recommended Posts

Ok for my first script i wanted to attempt a simple lumbridge fishing bot that would net shrimps and anchovies. At the start of the code i thought i better off define where my player is, because if he isn't at the swamp then hes not going to be able to interact with the Fishing spots. I identified two areas one was Lumbridge Castle and the other was the fishing spot and used this code as testing.

public int onLoop() {
 
                if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                        log("Not At Swamp");
                        {
                                if (!LumbridgeCastle.Area.contains(myPosition())) {
                                        log("Not At Castle");
                                        //TELEPORT HOME
                                        localWalker.walkPath(LumbridgeSwamp.Path_1);
                                }
                                 else if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                                        log("Im at the Swamp");
                                        //begin fishing code here
                                }
                        }
                }
                return random(200, 800); // The amount of time in milliseconds before
                                                                        // the loop starts over
        }

Please can someone explain to me how areas are used, and also why he walks the path and then when he has arrived he keeps walking there when i would tell it to start fishing.

 

Thanks

CybeFish

Link to comment
Share on other sites

                                 else if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                                        log("Im at the Swamp");
                                        //begin fishing code here
                                }

this part is redundant, since not being in that area is a condition for entering the outer if-statement in the first place. Did you perhaps misplace that exclamation mark?

 

Also you have an empty block (no conditions, pointless?).. as shown here:

public int onLoop() {
 
                if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                        log("Not At Swamp");
                        { <--- start empty block
                                if (!LumbridgeCastle.Area.contains(myPosition())) {
                                        log("Not At Castle");
                                        //TELEPORT HOME
                                        localWalker.walkPath(LumbridgeSwamp.Path_1);
                                }
                                 else if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                                        log("Im at the Swamp");
                                        //begin fishing code here
                                }
                        } <--- end empty block
                }
                return random(200, 800); // The amount of time in milliseconds before
                                                                        // the loop starts over
        }
Edited by FrostBug
Link to comment
Share on other sites

Ok for my first script i wanted to attempt a simple lumbridge fishing bot that would net shrimps and anchovies. At the start of the code i thought i better off define where my player is, because if he isn't at the swamp then hes not going to be able to interact with the Fishing spots. I identified two areas one was Lumbridge Castle and the other was the fishing spot and used this code as testing.

public int onLoop() {
 
                if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                        log("Not At Swamp");
                        {
                                if (!LumbridgeCastle.Area.contains(myPosition())) {
                                        log("Not At Castle");
                                        //TELEPORT HOME
                                        localWalker.walkPath(LumbridgeSwamp.Path_1);
                                }
                                 else if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                                        log("Im at the Swamp");
                                        //begin fishing code here
                                }
                        }
                }
                return random(200, 800); // The amount of time in milliseconds before
                                                                        // the loop starts over
        }

Please can someone explain to me how areas are used, and also why he walks the path and then when he has arrived he keeps walking there when i would tell it to start fishing.

 

Thanks

CybeFish

 

So first of all you duplicated the two red lines. I believe you didnt mean to put ! on the second one. 

Second of all you added in random { } the cyan ones. 

 

Areas are exactly what you expect. You have an area of positions, and you check if your position of one of those positions in the area. Your logic is flawed. Try to fix your code and then follow through it in your head thinking what will happen, vs what you wanted to happen. 

                                 else if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                                        log("Im at the Swamp");
                                        //begin fishing code here
                                }

this part is redundant, since not being in that area is a condition for entering the outer if-statement

 

Also you have an empty block (no conditions, pointless?).. as shown here:

public int onLoop() {
 
                if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                        log("Not At Swamp");
                        { <--- start empty block
                                if (!LumbridgeCastle.Area.contains(myPosition())) {
                                        log("Not At Castle");
                                        //TELEPORT HOME
                                        localWalker.walkPath(LumbridgeSwamp.Path_1);
                                }
                                 else if (!LumbridgeSwamp.Area_1.contains(myPosition())) {
                                        log("Im at the Swamp");
                                        //begin fishing code here
                                }
                        } <--- end empty block
                }
                return random(200, 800); // The amount of time in milliseconds before
                                                                        // the loop starts over
        }

 

Edit: loool you beat me to it. I basically said the same exact things. xD

Edited by Mysteryy
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.

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