FFTL Posted December 2, 2015 Share Posted December 2, 2015 So I just started to learn java and scripting, is there someone out there who can make or share simple looting script with all it needs? I mean the api lines and such. I want to begin with simple feather looter. So i readed a bit and used someones else script to get one feather looter working but i couldnt. Atm i got this but there are still some errors and i dont know how to fix em, doh... Wish i could get 1 working looting script so i can change it myself and stuff. import java.awt.*; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "") { private State state; enum State { LOOTING; } public void getState() { GroundItem feather = closestGroundItemForName("Feather"); if (feather != null) { if (feather.isVisible()) { state = State.LOOTING; } } } private GroundItem closestGroundItemForName(String string) { return null; } public int onLoop() throws InterruptedException { getState(); switch (state) { case LOOTING: return lootFeather(); } return random(20, 50); } private int random(int i, int j) { return 0; } public int lootFeather() throws InterruptedException{ GroundItem feather = closestGroundItemForName("Feather"); feather.interact("Take"); return 2500; } public void pickUpFeathers() { } } Its giving me errors on: private State state; - Syntax error on tokens, delete these tokens enum State { - Multiple markers at this line Illegal modifier for the enum State; only public is permitted case LOOTING: - Type mismatch: cannot convert from State to int Quote Link to comment Share on other sites More sharing options...
Explv Posted December 2, 2015 Share Posted December 2, 2015 So I just started to learn java and scripting, is there someone out there who can make or share simple looting script with all it needs? I mean the api lines and such. I want to begin with simple feather looter. So i readed a bit and used someones else script to get one feather looter working but i couldnt. Atm i got this but there are still some errors and i dont know how to fix em, doh... Wish i could get 1 working looting script so i can change it myself and stuff. Its giving me errors on: private State state; - Syntax error on tokens, delete these tokens enum State { - Multiple markers at this line Illegal modifier for the enum State; only public is permitted case LOOTING: - Type mismatch: cannot convert from State to int Please format your code properly if you are going to post it in the Scripting help section. Otherwise it is a pain to read.. I strongly suggest you learn the basics of Java first. You haven't even declared your "class" as a class. There are a lot of issues in this script not due to your lack of understanding of the API, but due to your lack of Java / programming knowledge. Quote Link to comment Share on other sites More sharing options...
KEVzilla Posted December 2, 2015 Share Posted December 2, 2015 (edited) Does this help you buddy? @ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "") public class FFTLFeathers extends Script { private State state; public enum State { LOOTING, WALKING, FILLTHISINMAN } @Override public int onLoop() throws InterruptedException { getState(); switch (state) { case LOOTING: lootFeather(); break; } return 750; } private void getState() { final GroundItem feather = closestGroundItemForName("Feather"); if (feather != null) { if (feather.isVisible()) { state = State.LOOTING; } } } public void lootFeather() { GroundItem feather = closestGroundItemForName("Feather"); if (feather != null) feather.interact("Take"); } private GroundItem closestGroundItemForName(final String name) { final GroundItems groundItems = new GroundItems(); final List<GroundItem> list = groundItems.filter(new NameFilter<>(name)); for (GroundItem g : list) { if (g.isOnScreen() && g.exists()) { //You could implement a null-check here return g; } } return null; } } Edit: not so familiar with the API yet, let me know if there are better ways lol. Edited December 2, 2015 by KEVzilla Quote Link to comment Share on other sites More sharing options...
Explv Posted December 2, 2015 Share Posted December 2, 2015 (edited) Does this help you buddy? @ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "") public class FFTLFeathers extends Script { private State state; public enum State { LOOTING, WALKING, FILLTHISINMAN } @Override public int onLoop() throws InterruptedException { getState(); switch (state) { case LOOTING: lootFeather(); break; } return 750; } private void getState() { final GroundItem feather = closestGroundItemForName("Feather"); if (feather != null) { if (feather.isVisible()) { state = State.LOOTING; } } } public void lootFeather() { GroundItem feather = closestGroundItemForName("Feather"); if (feather != null) feather.interact("Take"); } private GroundItem closestGroundItemForName(final String name) { final GroundItems groundItems = new GroundItems(); final List<GroundItem> list = groundItems.filter(new NameFilter<>(name)); for (GroundItem g : list) { if (g.isOnScreen() && g.exists()) { return g; } } return null; } } Edit: not so familiar with the API yet, let me know if there are better ways lol. Your code can be simplified / improved to: import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "") public class FFTLFeathers extends Script { @Override public int onLoop() throws InterruptedException { long featherCount = getInventory().getAmount("Feather"); GroundItem feather = getGroundItems().closest("Feather"); if(feather != null){ feather.interact("Take"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getInventory().getAmount("Feather") > featherCount; } }.sleep(); } return 750; } } But that is besides the point. He needs to learn Java xD Edited December 2, 2015 by Explv 1 Quote Link to comment Share on other sites More sharing options...
KEVzilla Posted December 2, 2015 Share Posted December 2, 2015 Your code can be simplified / improved to: import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "") public class FFTLFeathers extends Script { @Override public int onLoop() throws InterruptedException { long featherCount = getInventory().getAmount("Feather"); GroundItem feather = getGroundItems().closest("Feather"); if(feather != null){ if(!feather.isVisible()) getCamera().toEntity(feather); else{ feather.interact("Take"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getInventory().getAmount("Feather") > featherCount; } }.sleep(); } } return 750; } } But that is besides the point. He needs to learn Java xD Yeah, as I said in my reply that I'm not familiar with the API. And I just rewrote his broken script to work. Quote Link to comment Share on other sites More sharing options...
Explv Posted December 2, 2015 Share Posted December 2, 2015 Yeah, as I said in my reply that I'm not familiar with the API. And I just rewrote his broken script to work. You said Edit: not so familiar with the API yet, let me know if there are better ways lol. So I did :xdoge: 1 Quote Link to comment Share on other sites More sharing options...
Joseph Posted December 2, 2015 Share Posted December 2, 2015 Your code can be simplified / improved to: import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "") public class FFTLFeathers extends Script { @Override public int onLoop() throws InterruptedException { long featherCount = getInventory().getAmount("Feather"); GroundItem feather = getGroundItems().closest("Feather"); if(feather != null){ if(!feather.isVisible()) getCamera().toEntity(feather); else{ feather.interact("Take"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getInventory().getAmount("Feather") > featherCount; } }.sleep(); } } return 750; } } But that is besides the point. He needs to learn Java xDI believe default values for turning camera and walking are default for interaction event. You didn't need to check it's visibility Quote Link to comment Share on other sites More sharing options...
Explv Posted December 2, 2015 Share Posted December 2, 2015 I believe default values for turning camera and walking are default for interaction event. You didn't need to check it's visibility You're right, fixed Quote Link to comment Share on other sites More sharing options...
Joseph Posted December 2, 2015 Share Posted December 2, 2015 Does this help you buddy? @ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "") public class FFTLFeathers extends Script { private State state; public enum State { LOOTING, WALKING, FILLTHISINMAN } @Override public int onLoop() throws InterruptedException { getState(); switch (state) { case LOOTING: lootFeather(); break; } return 750; } private void getState() { final GroundItem feather = closestGroundItemForName("Feather"); if (feather != null) { if (feather.isVisible()) { state = State.LOOTING; } } } public void lootFeather() { GroundItem feather = closestGroundItemForName("Feather"); if (feather != null) feather.interact("Take"); } private GroundItem closestGroundItemForName(final String name) { final GroundItems groundItems = new GroundItems(); final List<GroundItem> list = groundItems.filter(new NameFilter<>(name)); for (GroundItem g : list) { if (g.isOnScreen() && g.exists()) { //You could implement a null-check here return g; } } return null; } } Edit: not so familiar with the API yet, let me know if there are better ways lol.You don't create a GroundItems class like that. You grab it's getter methods from within the method provder.So script.getGroundItems() 1 Quote Link to comment Share on other sites More sharing options...
KEVzilla Posted December 2, 2015 Share Posted December 2, 2015 (edited) You don't create a GroundItems class like that. You grab it's getter methods from within the method provder. So script.getGroundItems() Alright, thanks man. No need to call the super btw. Can just do #getGroundItems(). Edited December 2, 2015 by KEVzilla 1 Quote Link to comment Share on other sites More sharing options...
FFTL Posted December 2, 2015 Author Share Posted December 2, 2015 Thanks all who answered and who made better code for me, i got it to working state and will start to tweak it and add stuff such as antiban. Quote Link to comment Share on other sites More sharing options...