NoLifeLogo1 0 Share Posted November 11, 2020 Hey guys I just wanted to share some code. I am new and still learning but would like to share some other ideas for beginners like myself to have some ideas of different types of scripts to write other than the simple ole woodcutting script. This script is super simple and it creates sulphurous fertiliser for getting 100% hosidius favor. also for all the Pro's out there if you have any recommendations on stuff that I could be looking into Please let me know import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.script.Category; @ScriptManifest(author = "NoLife", name = "NoLife's Hosidius Favor", version = 1.0, description = "Hosidius Favor", category = Category.FARMING) public class Main extends AbstractScript { public void onStart() { log("Thank you for using my script"); } public void onExit() { log("Thank you for using my script"); } @Override public int onLoop() { if(getInventory().isEmpty()){ getBank().open(); sleep(400,600); getBank().withdraw("Compost",14); sleep(700,900); getBank().withdraw("Saltpetre",14); sleep(200,900); getBank().close(); sleep(300,800); }else; if(getInventory().onlyContains("Sulphurous fertiliser")){ getBank().open(); sleep(600,875); getBank().depositAllItems(); sleep(300,400); getBank().withdraw("Compost",14); sleepUntil(()-> getInventory().contains("Compost"),3000); getBank().withdraw("Saltpetre",14); sleepUntil(()-> getInventory().contains("Saltpetre"),4000); getBank().close(); sleep(600,700); }else; if(!getInventory().contains("Compost")){ getBank().open(); getBank().withdraw("Compost",14); sleepUntil(()-> getInventory().contains("Compost"),5000); if(getInventory().contains("Sulphurous fertiliser")); getBank().depositAll("Sulphurous fertiliser"); sleepUntil(()->!getInventory().contains("Sulphurous fertiliser"),2000); getBank().close(); sleep(750,950); }else; if(!getInventory().contains("Saltpetre")){ getBank().open(); getBank().withdraw("Saltpetre",14); sleepUntil(()-> getInventory().contains("Saltpetre"),5000); if(getInventory().contains("Sulphurous fertiliser")); getBank().depositAll("Sulphurous fertiliser"); sleepUntil(()->!getInventory().contains("Sulphurous fertiliser"),2000); getBank().close(); sleep(540,850); }else; if(getInventory().contains("Compost")){ if(getInventory().contains("Saltpetre")); getInventory().interact("Compost","use"); sleep(300,600); getInventory().interact("Saltpetre","use"); sleep(40000,41000); } return Calculations.random(500, 600); } } Link to comment Share on other sites More sharing options...
crazykid080 14 Share Posted November 11, 2020 I would recommend looking into states, they are extremely useful. Link to comment Share on other sites More sharing options...
NoLifeLogo1 0 Author Share Posted November 11, 2020 Will do. Thank you Link to comment Share on other sites More sharing options...
pharaoh 130 Share Posted November 11, 2020 looks good, i would recommend looking into sleepuntils for your sleeps! Link to comment Share on other sites More sharing options...
NoLifeLogo1 0 Author Share Posted November 12, 2020 Thank you for the feedback. Link to comment Share on other sites More sharing options...
una_maquina 35 Share Posted November 12, 2020 Hey, congratz on writing your first scripts. Some tips: Learn the node system (it's like states, but it's better, because you can create multiple classes and keep everything neat). This helped me a ton. What you have now is an abstract code. Everything is in one place, and when you're programming or debugging -- it'll get pretty confusing real fast, the more lines of code you write. It's better to have many classes with a node system in place. It'll be confusing at first, but if you put in the effort I think you'll figure this out. Just like I have. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.