HTM 32 Posted July 9, 2020 Long story short im working on a bot that contains multiple scripts. Because of this i am making paint for each bot, in this case fishing. im currently ironing everything out, that includes the paint. since there will be different paint for 7 different skills i have decided to make a method for the g.drawstrings for each paint. my problem occurs when the paint isnt being drawn. the variable turns true but it isnt recognized and paint. any help would be appreciated ______________________this snippet is from my main class______________________ @Override public void onPaint(Graphics g) { if (GuiHelper.getisFishing()) { FishingHelper.FishingPaint(); } } ____________________this is the method i am calling on for the paint________________________________________ public static void FishingPaint() { if (context.image != null) { g.drawImage(context.image, 0, 340, null); } { if (!context.hide) { g.drawImage(context.closeIcon, 500, 350, null); } if (context.hide) { g.drawImage(context.closeIcon, 500, 350, null); }} if (!context.hide) { g.drawImage(context.background, 20, 340, null); g.setColor(Color.white); g.drawImage(context.closeIcon, 500, 350, null); g.drawString("" + context.getSkillTracker().getGainedExperiencePerHour(Skill.FISHING), 385, 445); g.drawString("" + context.getSkillTracker().getGainedExperience(Skill.FISHING), 462, 432); g.drawString("" + formatTime(context.getSkillTracker().getTimeToLevel(Skill.FISHING)), 340, 393); g.drawString("" + GuiHelper.timeRan.formatTime(), 350, 465); g.drawString(BotState.getStartLevel() + " / " + BotState.getCurrentLevel() + " ( +" + BotState.getLevelsGained() + " )", 438, 390); g.drawString("" + (BotState.getCounter()), 409, 415); } if (context.hide) { g.drawImage(context.closeIcon, 500, 350, null); } } _________________________below is the action that sets the variable true when called on_____________________________________ public static boolean isFishing = false; isFishing = fishingCheckBox.isSelected(); if (fishingCheckBox.isSelected()) { GuiHelper.setisFishing(true); log("fishing set true"); GuiHelper.createFishingGUI(client, context); }
Neffarion 486 Posted July 9, 2020 12 hours ago, hoke2012 said: Long story short im working on a bot that contains multiple scripts. Because of this i am making paint for each bot, in this case fishing. im currently ironing everything out, that includes the paint. since there will be different paint for 7 different skills i have decided to make a method for the g.drawstrings for each paint. my problem occurs when the paint isnt being drawn. the variable turns true but it isnt recognized and paint. any help would be appreciated ______________________this snippet is from my main class______________________ @Override public void onPaint(Graphics g) { if (GuiHelper.getisFishing()) { FishingHelper.FishingPaint(); } } ____________________this is the method i am calling on for the paint________________________________________ public static void FishingPaint() { if (context.image != null) { g.drawImage(context.image, 0, 340, null); } { if (!context.hide) { g.drawImage(context.closeIcon, 500, 350, null); } if (context.hide) { g.drawImage(context.closeIcon, 500, 350, null); }} if (!context.hide) { g.drawImage(context.background, 20, 340, null); g.setColor(Color.white); g.drawImage(context.closeIcon, 500, 350, null); g.drawString("" + context.getSkillTracker().getGainedExperiencePerHour(Skill.FISHING), 385, 445); g.drawString("" + context.getSkillTracker().getGainedExperience(Skill.FISHING), 462, 432); g.drawString("" + formatTime(context.getSkillTracker().getTimeToLevel(Skill.FISHING)), 340, 393); g.drawString("" + GuiHelper.timeRan.formatTime(), 350, 465); g.drawString(BotState.getStartLevel() + " / " + BotState.getCurrentLevel() + " ( +" + BotState.getLevelsGained() + " )", 438, 390); g.drawString("" + (BotState.getCounter()), 409, 415); } if (context.hide) { g.drawImage(context.closeIcon, 500, 350, null); } } _________________________below is the action that sets the variable true when called on_____________________________________ public static boolean isFishing = false; isFishing = fishingCheckBox.isSelected(); if (fishingCheckBox.isSelected()) { GuiHelper.setisFishing(true); log("fishing set true"); GuiHelper.createFishingGUI(client, context); } Where even are you getting "g" in FishingPaint?
HTM 32 Author Posted July 9, 2020 it's delcared at the top of the FishingHelper class. private static Graphics g;
Neffarion 486 Posted July 9, 2020 2 hours ago, hoke2012 said: it's delcared at the top of the FishingHelper class. private static Graphics g; Firstly you shouldn't be doing it that way. You should be passing the g from onPaint through the method FishingPaint Also, even if your implementation is like that, you are not even setting that global static g to anything on your OnPaint Please learn java before writing scripts, it will make it much easier for you
kamilo 7 Posted July 10, 2020 how is this suppose to work? so it should display the paint of hte script its running pretty much right? and the other script paint's should disappear if not active
HTM 32 Author Posted July 10, 2020 6 hours ago, Neffarion said: Firstly you shouldn't be doing it that way. You should be passing the g from onPaint through the method FishingPaint Also, even if your implementation is like that, you are not even setting that global static g to anything on your OnPaint Please learn java before writing scripts, it will make it much easier for you Thanks for your input but i already figured it out by passing it through the method. Originally i couldnt pass it through the method like youre saying because it interferred with one of my other classes. just so you know, my script works and has worked, the difference is i am writing java like it should be written by partioning into different classes and not just writing it in script from top to bottom. Global static g isnt even needed. Again thanks for your input although it wasnt useful. Again, script is working so obviously i know enough java to write a bot
kamilo 7 Posted July 13, 2020 On 7/10/2020 at 2:27 AM, hoke2012 said: Thanks for your input but i already figured it out by passing it through the method. Originally i couldnt pass it through the method like youre saying because it interferred with one of my other classes. just so you know, my script works and has worked, the difference is i am writing java like it should be written by partioning into different classes and not just writing it in script from top to bottom. Global static g isnt even needed. Again thanks for your input although it wasnt useful. Again, script is working so obviously i know enough java to write a bot can you explain how you got different paints to work? did u have different paint snippets in different task nodes or something
HTM 32 Author Posted July 29, 2020 On 7/13/2020 at 1:22 PM, kamilo said: can you explain how you got different paints to work? did u have different paint snippets in different task nodes or something sorry for the late response, i've been busy travelling for work and the had a family vacation. i have multiple classes simply put. to explain: in my main "onStart" i reference a class called GuiHelper: public void onStart() { List<Skill> selection = GuiHelper.SkillSelector(getClient().getInstance().getCanvas(), this); this starts my gui which i have labelled "SkillSelector()" depending which box is check in skill selector it will trigger the gui for the specific skill. i did run into the problem of selecting multiple skills and launching multiple gui's but this is cancelled by a return. button.addActionListener(e -> { isFishing = fishingCheckBox.isSelected(); if (fishingCheckBox.isSelected()) { setisFishing(true); log("fishing set true"); GuiHelper.createFishingGUI(client, context); } now the script will reference back to these options in main under my paint. so my main onPaint is something like: @Override public void onPaint(Graphics g) { super.onPaint(g); log("painting1"); if (GuiHelper.getisFishing()) { fishingHelper.FishingPaint(g); } i have an if statement for all possible selections made under GuiHelper and if it is true it will start the paint for that. in this instance if "getisFishing" is true then FishingPaint below will start. the problem i encountered was starting multiple paints at once by selecting multiple check boxes in the guihelper. i cancelled this with a simple return statement which will stop the script: public static void FishingPaint(Graphics g) { if (image != null) { g.drawImage(image, 0, 340, null); } { if (!Main.hide) { g.drawImage(background, 20, 340, null); g.drawImage(closeIcon, 500, 350, null); g.setColor(Color.white); g.drawString("" + BotState.getXpPerHour(), 385, 445); g.drawString("" + BotState.getXpGained(FISHING), 462, 432); g.drawString("" + formatTime(BotState.getTimeToNext(FISHING)), 340, 393); g.drawString("" + GuiHelper.timeRan.formatTime(), 350, 465); g.drawString(BotState.getStartLevel() + " / " + BotState.getCurrentLevel() + " ( +" + BotState.getLevelsGained() + " )", 438, 390); g.drawString("" + (BotState.getCounter()), 409, 415); } if (Main.hide) { g.drawImage(closeIcon, 500, 350, null); } } }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.