Binarybunny 0 Share Posted March 7, 2018 So I am trying to fish but it doesnt seem to want to work, never done a fishing script before so not sure how to find a fishing spot if its a entity or a gameobject. This is what I have so far and it finds a spot but it wont start fishing, thats because Im not telling it to but it doesnt even get to the log("IT WORKS RUN TO IT BOY!"); part. It just keeps looping through log("Found a new one!"); What am I doing wrong here and what is the proper way of doing this? log("Looking for the closest fishing spot"); //this will find the closest game object that isn't null (it's fishable) and whose name equals Fishing spot. Call this using nodes or in a method in your loop so that it is updated in real time. GameObject spot = getGameObjects().closest(i -> i != null && i.getID() == 1530); log("Found a fishing spot!"); //log(String.valueOf(spot.getTile())); //prints the not-null fishing spot's tile to the debug console. if (!spot.isOnScreen()) { log("The spot is not in screen!"); GameObject newSpot = getGameObjects().closest(i -> i != null && i.getID() == 1530); log("Found a new one!"); if (newSpot.isOnScreen()){ log("IT WORKS RUN TO IT BOY!"); } } else { //put your fishing method here. log("IT WORKS RUN TO IT BOY!"); } Link to comment Share on other sites More sharing options...
Manly 879 Share Posted March 7, 2018 Its an NPC.- Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted March 7, 2018 IIrc fishing spots are entities (npcs) and not objects my friend. E:/ I'd also recommend filtering based on action(s), not id, as id's change upon update. E.g. getNpcs().closest(n -> n != null && n.getActions().contains("Net") && n.getActions().contains("Bait"); Link to comment Share on other sites More sharing options...
Binarybunny 0 Author Share Posted March 7, 2018 Keeps saying that its not on the screen IIrc fishing spots are entities (npcs) and not objects my friend. E:/ I'd also recommend filtering based on action(s), not id, as id's change upon update. E.g. getNpcs().closest(n -> n != null && n.getActions().contains("Net") && n.getActions().contains("Bait"); Not sure thats the way to use getACtions because it takes a string array Link to comment Share on other sites More sharing options...
Koschei 147 Share Posted March 7, 2018 Keeps saying that its not on the screen Not sure thats the way to use getACtions because it takes a string array You just need to make it become a String. Can do this by using the Arrays.toString(array) method Then that would look like this. NPC npc = getNpcs().closest(n -> n != null && Arrays.toString(n.getActions()).contains("Net") && Arrays.toString(n.getActions()).contains("Bait")); Link to comment Share on other sites More sharing options...
dQw4w9WgXcQ 184 Share Posted March 8, 2018 You just need to make it become a String. Can do this by using the Arrays.toString(array) method Then that would look like this. NPC npc = getNpcs().closest(n -> n != null && Arrays.toString(n.getActions()).contains("Net") && Arrays.toString(n.getActions()).contains("Bait")); n.hasAction(string) Link to comment Share on other sites More sharing options...
Koschei 147 Share Posted March 8, 2018 n.hasAction(string) I was answering his question about it being an array. Either method will I guess. ¯\_(ツ)_/¯ Link to comment Share on other sites More sharing options...
Scorpius 144 Share Posted March 8, 2018 So I am trying to fish but it doesnt seem to want to work, never done a fishing script before so not sure how to find a fishing spot if its a entity or a gameobject. This is what I have so far and it finds a spot but it wont start fishing, thats because Im not telling it to but it doesnt even get to the log("IT WORKS RUN TO IT BOY!"); part. It just keeps looping through log("Found a new one!"); What am I doing wrong here and what is the proper way of doing this? log("Looking for the closest fishing spot"); //this will find the closest game object that isn't null (it's fishable) and whose name equals Fishing spot. Call this using nodes or in a method in your loop so that it is updated in real time. GameObject spot = getGameObjects().closest(i -> i != null && i.getID() == 1530); log("Found a fishing spot!"); //log(String.valueOf(spot.getTile())); //prints the not-null fishing spot's tile to the debug console. if (!spot.isOnScreen()) { log("The spot is not in screen!"); GameObject newSpot = getGameObjects().closest(i -> i != null && i.getID() == 1530); log("Found a new one!"); if (newSpot.isOnScreen()){ log("IT WORKS RUN TO IT BOY!"); } } else { //put your fishing method here. log("IT WORKS RUN TO IT BOY!"); } I believe it's a good practice to search for GameObjects/NPCs/etc. using names not IDs. sometimes the gameobject IDs change which could cause the script to stop working Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted March 8, 2018 n.hasAction(string) Knew it was something of the sort, but didn't recall off the top of my head Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.