lpjz2 Posted November 19, 2017 Share Posted November 19, 2017 (edited) 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) 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 November 19, 2017 by lpjz2 Quote Link to comment Share on other sites More sharing options...
Explv Posted November 19, 2017 Share Posted November 19, 2017 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) 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 Quote Link to comment Share on other sites More sharing options...
lpjz2 Posted November 19, 2017 Author Share Posted November 19, 2017 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 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! Quote Link to comment Share on other sites More sharing options...
Explv Posted November 19, 2017 Share Posted November 19, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
The Hero of Time Posted November 19, 2017 Share Posted November 19, 2017 (edited) the only way to debug osbot is by using System.out.println Edited November 19, 2017 by The Hero of Time 1 Quote Link to comment Share on other sites More sharing options...
lpjz2 Posted November 19, 2017 Author Share Posted November 19, 2017 35 minutes ago, Explv said: Make sure you refresh the script list in the client after building the .jar so that it picks up your new code 2 minutes ago, The Hero of Time said: the only way to debug osbot is by using System.out.println Thank you both. Your help is much appreciated /closed Quote Link to comment Share on other sites More sharing options...
Apaec Posted November 19, 2017 Share Posted November 19, 2017 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 1 Quote Link to comment Share on other sites More sharing options...
Viston Posted November 19, 2017 Share Posted November 19, 2017 3 hours ago, The Hero of Time said: the only way to debug osbot is by using System.out.println Or log(); Quote Link to comment Share on other sites More sharing options...
The Hero of Time Posted November 19, 2017 Share Posted November 19, 2017 4 hours ago, Viston said: Or log(); does println even work? it's been so long, i know i always used log Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted November 20, 2017 Share Posted November 20, 2017 (edited) 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 November 20, 2017 by The Undefeated 1 Quote Link to comment Share on other sites More sharing options...
lpjz2 Posted November 20, 2017 Author Share Posted November 20, 2017 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! Quote Link to comment Share on other sites More sharing options...
battleguard Posted November 22, 2017 Share Posted November 22, 2017 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 2 Quote Link to comment Share on other sites More sharing options...
lpjz2 Posted November 22, 2017 Author Share Posted November 22, 2017 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 Legend! +1 to this. Quote Link to comment Share on other sites More sharing options...