Jump to content

A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec


Apaec

Recommended Posts

2 hours ago, Apaec said:

 

Ah great! So you have some experience with Java through university. That'll definitely help in shallowing the learning curve.

Regarding webwalking, as I said, this system is---by nature---much less reliable than a hard-coded sequence of positions which constitute a path. So, if the route you're walking is regular and known, i'd strongly recommend recording a path (there are tools for this on the SDN, or local section I believe. Or, make your own!). Then, you can use the walkPath method which will be more reliable and resource-efficient.

GL!

Apa

Okay dude, cheers!

What about adding some sort of task feature, so that I can see if a user wants to use banking, then if they do, make the script bank instead of powerfishing? 

Link to comment
Share on other sites

23 hours ago, mitsuki said:

Okay dude, cheers!

What about adding some sort of task feature, so that I can see if a user wants to use banking, then if they do, make the script bank instead of powerfishing? 

You mean a user interface?

That's a little more complicated. For very simple interfaces, you can use JOptionPanes (these are create for basic input!). For more complicated UIs, you'll have to start extending JFrame yourself.

Alternatively, you can create your own rudimentary interface using the paint and mouse listeners

-Apa

Link to comment
Share on other sites

11 hours ago, mitsuki said:

How do I add a sleep?

Do i just use return random(minsleeptime, maxsleeptime);?

 

You could do that, that is referred to as a static sleep. They're not great. It's better to, where possible, use a conditional sleep. These are slightly different - rather than the duration of the sleep being fixed, the script instead sleeps until a condition is met (or a timeout is exceeded).

Here's a link to the relevant (abstract) class: https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html

You'll have to extend your own versions of this class, which people typically do anonymously for convenience.

-Apa

Link to comment
Share on other sites

On 8/29/2020 at 2:59 PM, mitsuki said:

do you mind if i pm you my code for a script? I've spent hours on it, and it was working fine, but now it only seems to get me to the location where i want to fish?

maybe you'll see something in the code where i'm going wrong. Cheers dude

Sure thing. Just sent you a reply.

Apa

Link to comment
Share on other sites

  • 1 month later...

Hey, I'm having an issue where my TeaTheiver script won't show up in the OSBot Script Selector. I have the script saved to C:\\Users\User\OSBot\Scripts, but when I open the Script Selector and hit refresh the TeaTheiver script does not appear. I have succesfully added other scripts from the SDN and those show up just fine in the Script Selector, but my custom script does not. 

I deleted my project and tried creating a new one. I also deleted OSBot and redownloaded it. Neither of these attempts fixed the problem. Could this be because I'm using JavaSE-14 in my Build Path? Do I need to use a different Java version?

Link to comment
Share on other sites

10 hours ago, Weep said:

Hey, I'm having an issue where my TeaTheiver script won't show up in the OSBot Script Selector. I have the script saved to C:\\Users\User\OSBot\Scripts, but when I open the Script Selector and hit refresh the TeaTheiver script does not appear. I have succesfully added other scripts from the SDN and those show up just fine in the Script Selector, but my custom script does not. 

I deleted my project and tried creating a new one. I also deleted OSBot and redownloaded it. Neither of these attempts fixed the problem. Could this be because I'm using JavaSE-14 in my Build Path? Do I need to use a different Java version?

While I am not entirely sure what could be causing this, I think your assumption may be correct. I'm not entirely sure which Java version is currently supported by OSBot, but 14+ may not be supported. I'd recommend building against an older, more established Java version (I know that Java 8 is supported, so perhaps start with that?)

Also, ensure that your ScriptManifest annotation is correctly placed and populated - this is required for the script to show up in your selector.

Best of luck, let me know how you get on!

-Apa

Link to comment
Share on other sites

  • 3 weeks later...
41 minutes ago, Jonas Schoenmakers said:

I'm having a problem with loading the script. I did everything exactly as explained, but the script doesn't appear when i try to load it within osbot, any idea on how to fix this?

Hey,

Please could you send a screenshot of your script? Sometimes issues with the script manifest mean the script may not show.

-Apa

Link to comment
Share on other sites

13 minutes ago, Apaec said:

Hmm, that looks like it is OK. I don't think the issue is with the manifest then.

I'm sure you have, but have you tried restarting OSBot?

-Apa

Yes i have, i also have a jar file from a while ago that gets read, but i don't have the source code anymore, otherwise i could've compared them..

 

I'm receiving this error message multiple times in my logger though

 

[ERROR][10/27 04:28:46 PM]: Failed to load local script : core/Main.class

 

EDIT: https://gyazo.com/5cbee5e372d14b2267605e739ef5f938

Edited by Jonas Schoenmakers
Link to comment
Share on other sites

  • 4 months later...

Just wanted to say thanks so much. I'm doing a CS bachelor and had some introductory Java courses and this was very readable to me, but it was the first time seeing how an imported API would function and thanks to your guide I'm going to try to learn some OSRS scripting just to play with my basic skills a little. Combining a hobby like OSRS and courses for CS is pretty cool; thanks a lot for the effort to make this! 

Edited by yaniij
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.
Note: Your post will require moderator approval before it will be visible.

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