Jump to content
Athylus

Asking for help with my Farming Script

Recommended Posts

Fellow Script Writers,

I have a 'working' farming bot, but it does not necessarily function the way I want it to. There's a problem: I cannot seem to check whether a patch has been treated with ultracompost. What I've tried: config bits, but they only tell us the stages of the weed in the patch or whether a crop has been planted. When treating the patch with compost the id of that patch does not change either.

When right-clicking inspect on a patch, the game will tell us whether it has been treated with compost or not. So how can we get this data? Reliably. Checking the amount of compost in our inventory is not fool proof and can cause the script to get stuck.

Link to comment
Share on other sites

I might be wrong, but since you said you can inspect the patch to check if it's been treated, you should be able to make your script work the way you want.

I haven't looked into the API, but you can possibly grab the text from the chatbox, meaning your script can understant if the patch has been treated or not.

 

Edit: check this 

 public void onMessage(Message message) throws java.lang.InterruptedException {
	if(message.getType() == Message.MessageType.PLAYER) {
			if (message.getMessage().contains("noob") || message.getMessage().contains("nub")) {
				getKeyboard().typeString("im not a noob you are!");
			}
		}
    }

The example above will check if a message from another PLAYER contains the string "noob" or "nub". If it does, it'll reply back "I'm not a noob, you are".

Since the osbot API can check message from other players, it can check other messageTypes, just take a better look in the API

That example should set you up easily

 

 

Edited by Ragboys is back
  • Like 1
Link to comment
Share on other sites

Perhaps a combination of the interact function and message listener.

If you interact with a patch, take note of which patch that was. If you receive a message that says you've used ultra-compost, then make a note that you used said compost with said patch. Then clear the patch reference so that it's not used again by mistake.

  • Like 1
Link to comment
Share on other sites

Doesn't the message listener only work on the class that extends Script tho? So I would have to place that in the main loop, even though my farming patches are handled in separate classes. Kind of like explv's tutorial island script. In the meantime I'll see what if I can work this out.

 

Edit: Just using the message listener in my main class now, it's working like a charm! Now I will just have to pass that info around to my other classes, make some variables and setters... and actually, I need to use configs now as well instead of counting the seeds. And optimize the whole damn thing, my I5 6500 can barely handle two of these scripts! And it's only OSBot that is lagging, not my other open applications. So it must be my script.

 

Thanks for the helps bros!

 

Another thing I want to add is a circular linked list with accounts so that multiple accounts can take turns. You will have to wait after a farming run, so better to let another acc do a run. That would mean a complete overhaul of the script... if anyone is interested in helping me you can shoot a PM.

Edited by Athylus
  • Like 1
Link to comment
Share on other sites

Spoiler
1 hour ago, Athylus said:

Doesn't the message listener only work on the class that extends Script tho? So I would have to place that in the main loop, even though my farming patches are handled in separate classes. Kind of like explv's tutorial island script. In the meantime I'll see what if I can work this out.

 

Edit: Just using the message listener in my main class now, it's working like a charm! Now I will just have to pass that info around to my other classes, make some variables and setters... and actually, I need to use configs now as well instead of counting the seeds. And optimize the whole damn thing, my I5 6500 can barely handle two of these scripts! And it's only OSBot that is lagging, not my other open applications. So it must be my script.

 

Thanks for the helps bros!

 

Another thing I want to add is a circular linked list with accounts so that multiple accounts can take turns. You will have to wait after a farming run, so better to let another acc do a run. That would mean a complete overhaul of the script... if anyone is interested in helping me you can shoot a PM.

Just look in the API to see if message listener is available:

https://imgur.com/a/Zzyv8rX

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