Vogelbekdier
-
Posts
10 -
Joined
-
Last visited
Posts posted by Vogelbekdier
-
-
Quote12 minutes ago, camalCase said:
what happens inside those methods? and where is this code block positioned? sounds like wheat is never gets assigned again after its initialized but i cant tell not enough code
// i think using guard clauses help your code look nicer and be clearer :3 like this if (wheat == null) { walkToWheat(); return 2400; // or whatever } pickWheat(); return 2400; // or whatever
Quoteprivate void pickWheat() { GameObject wheat = GameObjects.closest((gameObject) -> { return gameObject != null && gameObject.getName().equals("Wheat") && gameObject.canReach() && gameObject.hasAction(new String[]{"Pick"}); }); if (!Inventory.contains("Grain")) { wheat.interactForceLeft("Pick"); Sleep.sleepUntil(() -> Inventory.contains("Grain"), longSleep); } else if (Inventory.contains("Grain")) { gotGrain = true; } }
This doesn't work because when I start the script when Grain == null it always stays null. So it just walks over to the area and gives error "Grain == null" and freezes only when I restart the script grain becomes != null and it will pick one wheat. If I drop it manually again it will just stand there trying to pick another one but never actually does.
-
I'm trying to null check a GameObject and interact if it's != null or else walk over.
Initial null check comes back false and I walk over to the area, but even when I'm standing in a field of wheat it keeps still returning wheat == null. Only when I restart the script it will turn to true.
Help please.
QuoteGameObject wheat = GameObjects.closest("Wheat");
if (wheat == null) {
walkToWheat();
} else if (wheat != null) {
pickWheat();\
}
-
Sometimes get's stuck trying to enter the door into Wintertodt, It will keep trying to adjust the camera to the door trying to get it on the screen but it is standing to far away to be able to enter it as a result it just sits there turning the camera over and over.
Object null check not updating
in Support
Posted