CyberFish Posted March 26, 2015 Share Posted March 26, 2015 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 Quote Link to comment Share on other sites More sharing options...
FrostBug Posted March 26, 2015 Share Posted March 26, 2015 (edited) 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 March 26, 2015 by FrostBug Quote Link to comment Share on other sites More sharing options...
Mysteryy Posted March 26, 2015 Share Posted March 26, 2015 (edited) 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 March 26, 2015 by Mysteryy Quote Link to comment Share on other sites More sharing options...
CyberFish Posted March 26, 2015 Author Share Posted March 26, 2015 Thanks guys ill work on it some more now Quote Link to comment Share on other sites More sharing options...