th3gos Posted March 22, 2018 Share Posted March 22, 2018 (edited) I want to add in my script the option that when you reach a specific level in "Attack, force or defense" change the attack form to start uploading another melee skill Ex: reach level 30 of attack and I want to change to the mode of "Block" so that it raises defense and later that it changes to "Stab" to raise force when it reaches certain levels. Can you help me with that? if (getSkills().getStatic(Skill.DEFENCE) < 30) { } else if (getSkills().getStatic(Skill.DEFENCE) >=30) { log ("Defence level es 30."); this.stop (false); } I have this code but the only thing it can do is when it reaches level 30 of Defense it stops and I want it to change from Defense to Attack or Force ... to keep reaching melee levels. Quote @H0rn said: For your example you would do the following: If you are using the defensive attack style and your attack is over the desired level, change the attack style to strength? If I have already tried to think about that and I have searched the API for hours but I can not get anything. Please help guys! Edited March 22, 2018 by th3gos Quote Link to comment Share on other sites More sharing options...
Charlotte Posted March 22, 2018 Share Posted March 22, 2018 else if (getSkills().getStatic(Skill.DEFENCE) >=30) { log ("Defence level es 30."); this.stop (false); If you have read the api under https://osbot.org/api/org/osbot/rs07/script/Script.html The method stop(), will stop the script and will logout the accounts. What you want to do is to change the style of attack if defence reaches a certain level. In order to change attack styles, you can either use config values or through widget ids. Quote Link to comment Share on other sites More sharing options...
blogans Posted March 22, 2018 Share Posted March 22, 2018 (edited) One way to do it is by widgets and configs. Check if the config isn't the same as you want it to be (to stop a loop) && a check if its above 30 defence, then do some NPE checks for the widget, then interact. private int getdefLevel(){ return api.getSkills().getStatic(Skill.DEFENCE); } private int defConfig = 2; //Not right config RS2Widget defence = api.getWidgets().get(1,1 ); //not the right widget ids, dont use this method btw, use filters if(getdefLevel() >= 30 && api.getConfigs().get(43) != defConfig){ api.log("Defence is 30, attempting to switch attack styles"); if(defence != null){ if(defence.isVisible()){ if(defence.interact("change")){ api.log("Switched attack styles"); } }else{ if(api.getTabs().open(Tab.ATTACK)){ api.log("Successfully opened attack tab"); } } } } That by no means will work at all, just remember the npe checks and to get widgets by filters (eg: text, actions etc.) edit: Dont forget to check if the widget is visible, if not, youll have to open the tab first. Edited March 22, 2018 by blogans Quote Link to comment Share on other sites More sharing options...
Alek Posted March 22, 2018 Share Posted March 22, 2018 You do know that if defence is not less than 30, that means its greater than or equal to 30? If you have specific weapons you are using, then the easiest would be to search for widgets with actions/messages with the nomenclature for "controlled", "defence", etc. 2 Quote Link to comment Share on other sites More sharing options...
th3gos Posted March 23, 2018 Author Share Posted March 23, 2018 On 22/3/2018 at 8:21 AM, Alek said: You do know that if defence is not less than 30, that means its greater than or equal to 30? If you have specific weapons you are using, then the easiest would be to search for widgets with actions/messages with the nomenclature for "controlled", "defence", etc. I do not understand you very well, I have to modify it to work ... On 22/3/2018 at 8:11 AM, blogans said: private int getdefLevel(){ return api.getSkills().getStatic(Skill.DEFENCE); } private int defConfig = 2; //Not right config RS2Widget defence = api.getWidgets().get(1,1 ); //not the right widget ids, dont use this method btw, use filters if(getdefLevel() >= 30 && api.getConfigs().get(43) != defConfig){ api.log("Defence is 30, attempting to switch attack styles"); if(defence != null){ if(defence.isVisible()){ if(defence.interact("change")){ api.log("Switched attack styles"); } }else{ if(api.getTabs().open(Tab.ATTACK)){ api.log("Successfully opened attack tab"); } } } } The script is personal, I just want you to do what I said Quote Link to comment Share on other sites More sharing options...
th3gos Posted March 23, 2018 Author Share Posted March 23, 2018 @blogans Look this. Quote Link to comment Share on other sites More sharing options...
Butters Posted March 23, 2018 Share Posted March 23, 2018 55 minutes ago, th3gos said: @blogans Look this. you made your getDefLevel as a variable and not a method. The { } below is just a code block (not a method body). Needs to be int getDefLevel() { return ....; } Quote Link to comment Share on other sites More sharing options...
th3gos Posted March 23, 2018 Author Share Posted March 23, 2018 3 hours ago, Butters said: you made your getDefLevel as a variable and not a method. The { } below is just a code block (not a method body). Needs to be int getDefLevel() { return ....; } Not work! Quote Link to comment Share on other sites More sharing options...
blogans Posted March 24, 2018 Share Posted March 24, 2018 I advise you to learn java before learning to make scripts. If you get a basic understanding of java first, you'll be able to learn more throughout coding. But starting with no knowledge of how to create a method is a really bad place to start. Quote Link to comment Share on other sites More sharing options...