maferosrs 2 Posted June 18, 2017 i Guys, I'm reading the API documentation, is there a method for picking up the floor items? What class do you belong to?Hi Guys, I'm reading the API documentation, is there a method for picking up the floor items? What class do you belon
maferosrs 2 Author Posted June 18, 2017 ty ty ty this is correct ? public class Main extends AbstractScript { public GroundItem pickThisItems[] = {"Bones" , "Coins"}; @Override public int onLoop() { getGroundItems(pickThisItems); return 100; } }
Nex 2546 Posted June 18, 2017 ty ty ty this is correct ? public class Main extends AbstractScript { public GroundItem pickThisItems[] = {"Bones" , "Coins"}; @Override public int onLoop() { getGroundItems(pickThisItems); return 100; } } no.
Genius 50 Posted June 18, 2017 ty ty ty this is correct ? public class Main extends AbstractScript { public GroundItem pickThisItems[] = {"Bones" , "Coins"}; @Override public int onLoop() { getGroundItems(pickThisItems); return 100; } } Try this: public class Main extends AbstractScript { GroundItem coins = getGroundItems().closest(c -> c != null && c.getName().equals("Coins")); //this filter will look for ground items that are not null and have the name "Coins" @Override public int onLoop() { if (coins != null) coins.interact("Pick up"); //I'm not sure if that text is right, make sure the text matches the in-game text for hovering over a ground item. Also, you might want to make sure the coins are on-screen. return 100; } }
maferosrs 2 Author Posted June 18, 2017 Try this: public class Main extends AbstractScript { GroundItem coins = getGroundItems().closest(c -> c != null && c.getName().equals("Coins")); //this filter will look for ground items that are not null and have the name "Coins" @Override public int onLoop() { if (coins != null) coins.interact("Pick up"); //I'm not sure if that text is right, make sure the text matches the in-game text for hovering over a ground item. Also, you might want to make sure the coins are on-screen. return 100; } } ty ty package Main; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.items.GroundItem; import java.awt.*; @SuppressWarnings("ALL") @ScriptManifest( author = "Mafer", name = "My First Script Pick", version = 1.0, description = "Pick Items", category = Category.MONEYMAKING) public class Main extends AbstractScript { int c1 = 0; GroundItem itemBones = getGroundItems().closest("Bones"); @Override public int onLoop() { if (itemBones.isOnScreen() && itemBones != null ){ itemBones.interact("Take"); c1++; } return 100; } @Override public void onPaint(Graphics g) { g.setFont(new Font("Arial", Font.PLAIN,14)); // Text In Screeen g.drawString("Bones Takes: " + c1, 20, 60); } } What about now? But does not start the script because?
Soldtodie 76 Posted June 18, 2017 ty ty package Main; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.items.GroundItem; import java.awt.*; @SuppressWarnings("ALL") @ScriptManifest( author = "Mafer", name = "My First Script Pick", version = 1.0, description = "Pick Items", category = Category.MONEYMAKING) public class Main extends AbstractScript { int c1 = 0; GroundItem itemBones = getGroundItems().closest("Bones"); @Override public int onLoop() { if (itemBones.isOnScreen() && itemBones != null ){ itemBones.interact("Take"); c1++; } return 100; } @Override public void onPaint(Graphics g) { g.setFont(new Font("Arial", Font.PLAIN,14)); // Text In Screeen g.drawString("Bones Takes: " + c1, 20, 60); } } What about now? But does not start the script because? GroundItem itemBones = getGroundItems().closest("Bones"); Not possible. Use: GroundItem itemBones; @Override public int onLoop() { itemBones = getGroundItems().closest("Bones"); if (itemBones.isOnScreen() && itemBones != null ){ itemBones.interact("Take"); c1++; } return 100; }
Hashtag 9071 Posted June 18, 2017 GroundItem itemBones = getGroundItems().closest("Bones"); Not possible. Use: GroundItem itemBones; @Override public int onLoop() { itemBones = getGroundItems().closest("Bones"); if (itemBones.isOnScreen() && itemBones != null ){ itemBones.interact("Take"); c1++; } return 100; } You should null check the item before checking if it's on the screen .
Soldtodie 76 Posted June 18, 2017 You should null check the item before checking if it's on the screen . I didn't wrote this I just wrote the answer to the question. = But does not start the script because?
Recommended Posts
Archived
This topic is now archived and is closed to further replies.