Jump to content

Debugging?


lpjz2

Recommended Posts

Hi All,

This is my first post, so first off, nice to meet you all. This seems like a great community and im hoping to contribute by creating some scripts. Im a software developer by profession so fingers crossed i should be able to get the hang of scripting.

My question is how do i make debugging easier. I have 2 main issues

1) image.png.8871af8ac68b711bf8b154aeff4837dd.png

So im using IntelliJ, as you can see above when i make a change to my script and rebuild, IntelliJ cannot replace the .jar file in my scripts directory. Im guessing this is because the script has been loaded OSBot so its technically being used by that process. Every time i make a modification to my script i need to completely close OSBot client, then build. Then start up OSBot and log into my account again. (Just to confirm i have stopped my script). As you can imagine time is very time consuming, and may look a bit dodgy (level 3 account logging in and out non stop...) - Any tips here?

2) Is there any way i can debug from IntelliJ, like insert breakpoints, check variable values, stack trace etc? (this isnt a major, would just be super helpful).

 

Apologies if these are obvious questions, im somewhat experienced in OOP (C#) but i've only just started using Java / IntelliJ today.

EDIT : Questions answered. Thanks guys and gals

 

Edited by lpjz2
Link to comment
Share on other sites

6 minutes ago, lpjz2 said:

Hi All,

This is my first post, so first off, nice to meet you all. This seems like a great community and im hoping to contribute by creating some scripts. Im a software developer by profession so fingers crossed i should be able to get the hang of scripting.

My question is how do i make debugging easier. I have 2 main issues

1) image.png.8871af8ac68b711bf8b154aeff4837dd.png

So im using IntelliJ, as you can see above when i make a change to my script and rebuild, IntelliJ cannot replace the .jar file in my scripts directory. Im guessing this is because the script has been loaded OSBot so its technically being used by that process. Every time i make a modification to my script i need to completely close OSBot client, then build. Then start up OSBot and log into my account again. (Just to confirm i have stopped my script). As you can imagine time is very time consuming, and may look a bit dodgy (level 3 account logging in and out non stop...) - Any tips here?

2) Is there any way i can debug from IntelliJ, like insert breakpoints, check variable values, stack trace etc? (this isnt a major, would just be super helpful).

 

Apologies if these are obvious questions, im somewhat experienced in OOP (C#) but i've only just started using Java / IntelliJ today.

 

 

 

Your first issue isn't an issue, it shows that warning but the jar is still replaced.

As for your second issue, I'm not sure, there's probably a way, but there isn't that much value in debugging an OSBot script in the traditional sense. Best way to debug is just to run the script and see if it works :doge:

Link to comment
Share on other sites

3 minutes ago, Explv said:

 

Your first issue isn't an issue, it shows that warning but the jar is still replaced.

As for your second issue, I'm not sure, there's probably a way, but there isn't that much value in debugging an OSBot script in the traditional sense. Best way to debug is just to run the script and see if it works :doge:

Thanks for your reply. Thats strange the script doesn't seem to update (pick up my changes) every time on the client. It seems to be a bit random. 

And for the second point, i thought as much.

 

Thanks again!

Link to comment
Share on other sites

15 minutes ago, lpjz2 said:

Thanks for your reply. Thats strange the script doesn't seem to update (pick up my changes) every time on the client. It seems to be a bit random. 

And for the second point, i thought as much.

 

Thanks again!

 

Make sure you refresh the script list in the client after building the .jar so that it picks up your new code

  • Like 1
Link to comment
Share on other sites

Glad you got the issues sorted out! (: As for debugging; since it's a live game, mostly what will go wrong will be either at compile time or behavioural. As a result, step/break debugging isn't much help - i'd suggest just doing test runs!

You can use log("Hello"); to drop messages in the OSBot console, where you will also find stack traces should things go wrong.

If you're coming from a C# background then you should have no problems getting to know Java or the API. Best of luck and if you need anything don't hesitate to let me know! (:

-Apa

 

  • Like 1
Link to comment
Share on other sites

9 hours ago, The Hero of Time said:

does println even work? it's been so long, i know i always used log

If you start OSBot using CLI and add a debug parameter, the System.out lines will be written in the terminal / command prompt. This could be useful when adding non-API related stuff to your script and you don't wanna pass around the MethodProvider instance everywhere just to debug using the logger. 

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

1 hour ago, The Undefeated said:

If you start OSBot using CLI and add a debug parameter, the System.out lines will be written in the terminal / command prompt. This could be useful when adding non-API related stuff to your script and you don't wanna pass around the MethodProvider instance everywhere just to debug using the logger. 

Very useful to know. Thanks!

Link to comment
Share on other sites

you can debug osbot by running debugging intellij as an application and setting your main class to org.osbot.Boot. You then need to just use run instead of debug configuration when running it. Once you start your script inside the jar you can then go to run->attach process and you will now see your script running in a process you can attach to. From there your breakpoints should work

 

 

debugger.PNG

  • Like 2
Link to comment
Share on other sites

3 hours ago, battleguard said:

you can debug osbot by running debugging intellij as an application and setting your main class to org.osbot.Boot. You then need to just use run instead of debug configuration when running it. Once you start your script inside the jar you can then go to run->attach process and you will now see your script running in a process you can attach to. From there your breakpoints should work

 

 

debugger.PNG

Legend! +1 to this.

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