Jump to content

Search the Community

Showing results for tags 'improve'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • OSBot
    • News & Announcements
    • Community Discussion
    • Bot Manager
    • Support Section
    • Mirror Client VIP
    • Script Factory
  • Scripts
    • Official OSBot Scripts
    • Script Factory
    • Unofficial Scripts & Applications
    • Script Requests
  • Market
    • OSBot Official Voucher Shop
    • Currency
    • Accounts
    • Services
    • Other & Membership Codes
    • Disputes
  • Graphics
    • Graphics
  • Archive

Product Groups

  • Premium Scripts
    • Combat & Slayer
    • Money Making
    • Minigames
    • Others
    • Plugins
    • Agility
    • Mining & Smithing
    • Woodcutting & Firemaking
    • Fishing & Cooking
    • Fletching & Crafting
    • Farming & Herblore
    • Magic & Prayer
    • Hunter
    • Thieving
    • Construction
    • Runecrafting
  • Donations
  • OSBot Membership
  • Backup

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


MSN


Website URL


ICQ


Yahoo


Skype


Location:


Interests

Found 1 result

  1. Okay so i've been coding for not that long, mabye 2-3 weeks, but i see alot of really good coders around here, and what i can tell is that the better coder you are, the bigger the toolset of your coding. So the last few days i've been trying to improve my coding with making a questing script, which both improved my understanding of whenever to make a method for repeating task, passing arguments, aswell as overloading methods. However when i look at other scripters i se that the really good ones use lambdas when it's suitable, and i want to be able to do that aswell, as it makes for really smooth code and seem easier to manage. I've understood some parts of it, as on how to make a Lambda, and by that i mean making a functional interface that the Lambda can implement use as a type, aswell as on how to write it's syntax. What i've not fully grasped is how to use it in the context of my own scripts.. So what i really would like input on is, do you se any feature that i could extract further or improve? 1)Is there any code i should try to make a method of instead? 2)is there some code i should put in a superclass or interface? (Any input on why, and when that is suitable would also be super helpful) 3)Is there some part i can turn into a Lamda statement? I'm personally thinking of the dialogueV2 parts, but not quite sure on how to.. this is would really really make me happy if someone could provide help on 4)My main questing script is atm 630 lines, and involves 8-9 quests, I intend to script pretty much every quest(which is going to make it really big if i keep it up this way) , so should i try to like make some kind of superclass, and make the subquests children? or mabye some other smart solution? 5) If yes on number 4, would it make sense to make an abstract class, and mabye have dialoguehandling, and dialoguehandlingV2, in there as concrete methods, so i could just make an object of that class to implement them without really cluttering up to much of my code? 6) So i have a class called "Platser" where i save many areas or positions around runescape, however i read that when u create an object, the constructor makes space for the object on the heap for that object based on the constructor, does that mean it's bad practice for me to make a new object to call my spots more easily (cause the object have to store all the diffrent spots?) rather then just making them method variables, to save memory? 7) Any other coder out there that want to talk on skype with me to exchange ideas, if so feel free to add me on skype: Slazter My code to give input on: import org.osbot.rs07.api.filter.Filter; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import static org.osbot.rs07.api.Quests.Quest.THE_KNIGHTS_SWORD; @ScriptManifest(author = "slazter", name = "Knights Sword f2p q", info = "Does Knights sword if u have all items", version = 0.1, logo = "") public final class KnightsSword extends Script { @Override public final int onLoop() throws InterruptedException { if(canKnight()){ questKnightsSword(); } return (random(150,250)); } //Method for dialoguehandling when not needing to give extra input public void dialogueHandling() throws InterruptedException { String[] options = {""}; if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); } else if (dialogues.isPendingOption()) { dialogues.completeDialogue(options); } } //method for when i want to supply the talking options, public void dialogueHandling(String[] opt) throws InterruptedException { String[] options = opt; if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); } else if (dialogues.isPendingOption()) { dialogues.completeDialogue(options); } } //method for making it easier to select npc - default dialogue options public void dialogueV2(NPC name) throws InterruptedException { NPC qNpc; qNpc = name; if (Tab.INVENTORY.isDisabled(this.getBot())) { Sleep.sleepUntil(() -> !Tab.INVENTORY.isDisabled(this.getBot()), 15000); } else if (!dialogues.inDialogue()) { qNpc.interact("Talk-to"); Sleep.sleepUntil(() -> dialogues.inDialogue(), 5000); } else if (dialogues.inDialogue()) { dialogueHandling(); } } //method for making it easier to select npc - With supplied talk options public void dialogueV2(NPC name, String[] opts) throws InterruptedException { NPC qNpc; qNpc = name; String[] options = opts; if (Tab.INVENTORY.isDisabled(this.getBot())) { Sleep.sleepUntil(() -> !Tab.INVENTORY.isDisabled(this.getBot()), 15000); } else if (!dialogues.inDialogue()) { qNpc.interact("Talk-to"); Sleep.sleepUntil(() -> dialogues.inDialogue(), 5000); } else if (dialogues.inDialogue()) { dialogueHandling(options); } } //bolean to see if quest isn't done public boolean canKnight() { if (!quests.isComplete(THE_KNIGHTS_SWORD)) { return true; } else return false; } //the main quest method public void questKnightsSword() throws InterruptedException { String[] val = {"Something else.","Would you like some redberry pie?"}; RS2Object bluerite = getObjects().closest(7495); NPC squire = getNpcs().closest("Squire"); NPC thurgo = getNpcs().closest("Thurgo"); NPC reldo = getNpcs().closest("Reldo"); String[] qItems = {"Iron bar", "Redberry pie"}; Area squire_spot = new Area(2980, 3339, 2975, 3344); Area thurgo_spot = new Area(3001, 3143, 2995, 3146); Area reldo_spot = new Area(3213, 3490, 3207, 3497); Filter<Item> pickaxe = new Filter<Item>() { @Override public boolean match(Item item) { return item.getName().contains("pickaxe"); } }; //withdraw q items if not in inv if (!inventory.contains(qItems) && configs.isSet(122,0)) { if (!getBank().isOpen()) { getWalking().webWalk(Banks.FALADOR_WEST); getBank().open(); } else if (getBank().isOpen()) { getBank().withdraw("Iron bar", 2); getBank().withdraw("Redberry pie", 1); getBank().withdraw(pickaxe, 1); } } else if (configs.isSet(122,0)) { if (squire != null) { dialogueV2(squire); } else getWalking().webWalk(squire_spot); } else if (getConfigs().isSet(122,1)) { if(reldo!=null){ if(!dialogues.inDialogue()){ reldo.interact("Talk-to"); sleep(random(1200,1800)); } else if(dialogues.inDialogue()){ if(dialogues.isPendingContinuation()){ dialogues.clickContinue(); } else if(dialogues.isPendingOption()){ String[] options = {"What do you know about the Imcando dwarves?"}; dialogues.completeDialogue(options); } } } else getWalking().webWalk(reldo_spot); } else if(configs.isSet(122,2)){ String[] opts = {"Something else.","Would you like some redberry pie?"}; if(thurgo!=null){ dialogueV2(thurgo,opts); } else getWalking().webWalk(thurgo_spot); } else if(configs.isSet(122,3)){ String[] opts = {"Something else."}; if(thurgo!=null){ dialogueV2(thurgo,opts); } } else if(configs.isSet(122,4)){ if(squire!=null){ dialogueV2(squire); } else getWalking().webWalk(squire_spot); } else if(configs.isSet(122,5)){ String[] food = {"Trout"}; RS2Object cup = getObjects().closest("Cupboard"); if(inventory.contains("Portrait")) { //get food before getting near ice warriors if(!inventory.contains(food)){ if (!getBank().isOpen()){ getWalking().webWalk(Banks.FALADOR_EAST); getBank().open(); } else if(getBank().isOpen()) { getBank().withdraw("Trout", 4); getBank().close(); } } else if(thurgo!=null){ dialogueV2(thurgo,val); } else getWalking().webWalk(thurgo_spot); } else if(cup!=null && getMap().canReach(cup)){ if(getDialogues().isPendingContinuation()){ dialogues.clickContinue(); } cup.interact("Open"); sleep(random(1500,2100)); cup.interact("Search"); } else getWalking().webWalk(new Position(2984,3335,2)); } else if(configs.isSet(122,6)){ if(inventory.contains("Blurite sword")){ if(squire!=null){ dialogueV2(squire); } else getWalking().webWalk(squire_spot); } else if(!inventory.contains("Blurite ore")){ if(bluerite!=null && !myPlayer().isAnimating()){ bluerite.interact("Mine"); Sleep.sleepUntil(()-> myPlayer().isAnimating(),5000); } else getWalking().webWalk(new Position(3049,9567,0)); } else if(thurgo!=null) { dialogueV2(thurgo,val); } else getWalking().webWalk(thurgo_spot); } } }
×
×
  • Create New...