scriptersteve Posted December 18, 2017 Share Posted December 18, 2017 There was a warriorguild tokens script that didn't work and the code was lying around so i am trying to fix it: The first method works, however the second method doesn't. Mouse just hovers animate and was wondering why: help would be greatly appreciated. Can copy paste full code if that wouldhelp but pretty sure it'sthis else statement that is broken. Thanks if(lootables != null){ if (lootables.interact("Take")) { sleep(random(1200, 1500)); } }else{ if(hasArmour()){ if (getObjects().closest("Magical Animator").interact("Animate")) { sleep(random(1200, 2000)); } } } Quote Link to comment Share on other sites More sharing options...
Explv Posted December 18, 2017 Share Posted December 18, 2017 14 minutes ago, scriptersteve said: There was a warriorguild tokens script that didn't work and the code was lying around so i am trying to fix it: The first method works, however the second method doesn't. Mouse just hovers animate and was wondering why: help would be greatly appreciated. Can copy paste full code if that wouldhelp but pretty sure it'sthis else statement that is broken. Thanks if(lootables != null){ if (lootables.interact("Take")) { sleep(random(1200, 1500)); } }else{ if(hasArmour()){ if (getObjects().closest("Magical Animator").interact("Animate")) { sleep(random(1200, 2000)); } } } Check that the hasArmour function returns true Check that the object is actually called "Magical Animator", and is an object not an NPC Check that the interaction is actually called "Animate" Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 18, 2017 Author Share Posted December 18, 2017 It's definately not an NPC, so think it is an object. hasArmour function must be true? as it loots mithril platebodies if they are on the floor which requires this function to be true (i think, how else could i check this?). The object is called Magical Animator (case sensitive) IKR second one caps too. Left click option is called Animate in front off. Bit stuck Quote Link to comment Share on other sites More sharing options...
Explv Posted December 18, 2017 Share Posted December 18, 2017 1 minute ago, scriptersteve said: It's definately not an NPC, so think it is an object. hasArmour function must be true? as it loots mithril platebodies if they are on the floor which requires this function to be true (i think, how else could i check this?). The object is called Magical Animator (case sensitive) IKR second one caps too. Left click option is called Animate in front off. Bit stuck Put a log statement inside hasArmour: log("hasArmour is true") Just to make sure it is infact returning true. Are you sure you don't have to "Use" a piece of the armour *before* clicking on the Magical Animator? Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 18, 2017 Author Share Posted December 18, 2017 not quite sure howi can check whether that 'hasarmour statement is true?' Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 18, 2017 Author Share Posted December 18, 2017 ah think i understand, when i did the followoing nothing was input into the logger import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import javax.swing.*; import java.awt.*; import java.util.concurrent.TimeUnit; @ScriptManifest(name = "Animator by RickyD", author = "RickyD", version = 1.0, info = "Animates your armour to farm warrior guild tokens", logo = "") public class Warriorguild extends Script { String[] foodName = {"Monkfish"}; NPC anim; GroundItem lootables; private String armorType = "Mithril"; private String a1 = " platebody"; private String a2 = " full helm"; private String a3 = " platelegs"; String [] lootNames = {armorType.concat("a1"), "Warrior guild token", armorType.concat("a2"), armorType.concat("a3")}; @Override public void onStart() { startTime = System.currentTimeMillis(); if(hasArmour()!=true){ log("false"); } } @Override public void onExit() { log("Script has exited successfully"); } private long startTime; public boolean hasArmour(){ if(getInventory().contains(armorType + " platebody") && getInventory().contains(armorType + " platelegs") && getInventory().contains(armorType + " full helm")){ log("hasarmour is true"); return true; } return false; } //public boolean hasArmour(){ // return getInventory().contains(armorType + " platebody") && getInventory().contains(armorType + " platelegs") && getInventory().contains(armorType + " full helm"); // } @Override public int onLoop() throws InterruptedException{ // anim = getNpcs().closest(2454); if(hasArmour()!=true){ log("false"); } anim = getNpcs().closest("Animated " + armorType + " armour"); lootables = getGroundItems().closest(lootNames); if(getInventory().contains(foodName) && getInventory().getAmount("Warrior guild token") < 1000){ if(anim != null && anim.isInteracting(myPlayer())){ if(myPlayer().getHealthPercent() < 50){ getInventory().interact("Eat", foodName); //DTiming.waitCondition(() -> myPlayer().getAnimation() == 829, 2000); new ConditionalSleep(2000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650)); }else{ if(myPlayer().getInteracting() == null){ anim.interact("Attack"); sleep(random(800, 1100)); } } }else{ if(lootables != null){ if (lootables.interact("Take")) { sleep(random(1200, 1500)); } }else{ if(hasArmour()){ if (getObjects().closest("Magical Animator").interact("Animate")) { sleep(random(1200, 2000)); } } } } }else{ stop(false); JOptionPane.showMessageDialog(null, "NO FOOD or 1k Tokens", "Alert", JOptionPane.WARNING_MESSAGE); } return random(400, 700); //The amount of time in milliseconds before the loop starts over } @Override public void onPaint(Graphics2D g) { long millis = System.currentTimeMillis() - startTime; String timeStr = String.format("%02d min, %02d sec", TimeUnit.MILLISECONDS.toMinutes(millis), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)) ); g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14)); g.setColor(Color.WHITE); g.drawString("Time running: " + timeStr, 10, 250); } } So, i think then the hasarmour function is incorrect, unable to quite see why though Quote Link to comment Share on other sites More sharing options...
sonda Posted December 18, 2017 Share Posted December 18, 2017 Are you trying to hardcode one specific armor type? You can skip all the GUI and selection stuff and replace armorType + blahblah with (“Mithril platelegs”) (same for the rest) maybe there’s an issue with the GUI or however it is determining which armor your using Quote Link to comment Share on other sites More sharing options...
Chris Posted December 18, 2017 Share Posted December 18, 2017 Quote Link to comment Share on other sites More sharing options...
sonda Posted December 18, 2017 Share Posted December 18, 2017 Reading he code i would gather you should be using (armorType +a1) etc. but idk it’s not the way I would do it. Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 19, 2017 Author Share Posted December 19, 2017 Yeah, just trying to fix that animated armour's script because it doesn't work at the moment. Have tried the changing but again it just hovers over the animate armour and doesn't click. It's not the end of the world for me as I have d-defenders on all my accs and alts but it's a script i thought would be useful to get running again ;(. if (getObjects().closest("Magical Animator").interact("Animate")) { sleep(random(1200, 2000)); My only thought now is, is there a different way to write this so it left clicks on something? Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 19, 2017 Author Share Posted December 19, 2017 Okay, sorry everyone - turns out i was rebuilding the project and not the artefact which meant the jar wasn't being updated :'(. Now correctly attacks the warrior just doesn't look the mith so going to have a look at that later Quote Link to comment Share on other sites More sharing options...
FrostBug Posted December 19, 2017 Share Posted December 19, 2017 (edited) 3 hours ago, scriptersteve said: Okay, sorry everyone - turns out i was rebuilding the project and not the artefact which meant the jar wasn't being updated :'(. Now correctly attacks the warrior just doesn't look the mith so going to have a look at that later The lootNames array is wrong. According to the code you last posted, it would contain this: {"Mithril a1", "Mithril a2", "Mithril a3"}. Hint: This is wrong Even if you fixed the concatenation, there's still a typo in the mithril full helm Edited December 19, 2017 by FrostBug Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 19, 2017 Author Share Posted December 19, 2017 Yeah thanks, i've fixed it now so should be working. Quote Link to comment Share on other sites More sharing options...