Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Need some help, really appreciated


    Nosta
     Share

    Recommended Posts

    Hey! I'm new to botting and I'm trying to make a Firemaking bot. I'm currently stuck at checking if the tile which I am standing on contains a "Fire".
    To check this, I'd like to refer to the tile that GetLocalPlayer() is currently standing on, but I cannot find it in the documentation?

    How do I get the tile which GetLocalPlayer() is standing on? Shouldn't it be something like this?:

    new Tile tile = Tile.getLocalPlayer();


    Thanks for any insight you might be able to provide me with! Have a great day :)

    Link to comment
    Share on other sites

    No offense, but I think you need to go and learn the basics of Java. Once you have a grasp on that you'll be able to figure out what is wrong with that line.

    Link to comment
    Share on other sites

    Hi Uplift, thank you for the reply, I actually enjoy learning the basics of Java like this. I'll post an update here, this is what I've got so far:
     

    		case FIREMAKINGFIRST:
    			playerTile = getLocalPlayer().getTile();
    			GameObjects[] objectList = {getObjectsOnTile(playerTile)};
    			for(int i = 0; i < Objects.length; i++) {
    				if (Objects[i].getName().equals("Fire")) {
    					//Move to another tile, this one already has a fire.
    				}
    			}
    			break;

    Obviously it's not functional yet :D I still need to bend the words right, so to say hehe. Feel free to help me out 😇

    Link to comment
    Share on other sites

    for(int i = 0; i < Objects.length; i++) {

    Objects has not been defined, unless it is defined outside of your scope you've shown

    if (Objects[i].getName().equals("Fire")) {

    Objects is not an array, as above it's not decleared.

    GameObjects[] objectList = {getObjectsOnTile(playerTile)};

    I'm assuming getObjectsOnTile is supposed to return an array, so you shouldn't have to put it in, otherwise if it is returning one Object the array length will always be one and defeats the purpose

    playerTile = getLocalPlayer().getTile();

    Has playerTile been decleared out of what you've shown?

    Are you using an IDE? It should be telling you those errors?

    Edited by Uplift
    Link to comment
    Share on other sites

    Hi again Uplift, thank you for your elaborate responce! Following your suggestions and notes I've learned a lot and got it to work! Thank you once again mate :)
    As to your question, yes, playerTile is declared further up in my code 😇

    Here is the working code:
     

    case FIREMAKINGFIRST:
    			playerTile = getLocalPlayer().getTile();
    			GameObject[] objectList = GameObjects.getObjectsOnTile(playerTile);
    			for(int i = 0; i < objectList.length; i++) {
    				if (objectList[i].getName().equals("Fire")) {
    					//Move to another tile, this one already has a fire.
    				}
    			}
    			break;


    I saw you also responded to my question in the normal chat on the front page of the site, thank you for this also. If you PM me your paypal I'll gladly tip you for your time!
    Have a great day.

    Link to comment
    Share on other sites

    6 minutes ago, Nosta said:

    Hi again Uplift, thank you for your elaborate responce! Following your suggestions and notes I've learned a lot and got it to work! Thank you once again mate :)
    As to your question, yes, playerTile is declared further up in my code 😇

    Here is the working code:
     

    case FIREMAKINGFIRST:
    			playerTile = getLocalPlayer().getTile();
    			GameObject[] objectList = GameObjects.getObjectsOnTile(playerTile);
    			for(int i = 0; i < objectList.length; i++) {
    				if (objectList[i].getName().equals("Fire")) {
    					//Move to another tile, this one already has a fire.
    				}
    			}
    			break;


    I saw you also responded to my question in the normal chat on the front page of the site, thank you for this also. If you PM me your paypal I'll gladly tip you for your time!
    Have a great day.

    That looks much better. Good job!

    Link to comment
    Share on other sites

    if you wanted to use lambdas you could also simplify the code to this:

            Tile lpt = Players.localPlayer().getTile();
            boolean fireOnTile = GameObjects.closest((g) -> g != null && g.getTile().equals(lpt) && g.getName().equals("Fire")) != null;
            if (fireOnTile) {
                //Move
            }
            // Tile is ok

     

    Link to comment
    Share on other sites

    Hi TheCloakedOne, thank you for the responce! I've further improved my code with your suggestions, thank you so much!
    I've got one question in responce, at the end of the lambdas it says && f.getName().equals("Fire")) != null;

    What does the !=null here do? Does it check if "GameObjects.closest" is not equal to null just as we check if "f" is not equal to null?

    I'm very thankful for the responces! Thanks you guys :)
     

    		case FIREMAKINGFIRST:
    			log("Making 1 Fire");
    			playerTile = getLocalPlayer().getTile();
    			boolean fireOnTile = GameObjects.closest((f) -> f != null && f.getTile().equals(playerTile) && f.getName().equals("Fire")) != null;
    			GameObject[] objectList = GameObjects.getObjectsOnTile(playerTile);
    			if (fireOnTile) {
    				log("Tile not occupied - lighting fire");
    				if(!Tabs.isOpen(Tab.INVENTORY)){
    					Tabs.openWithMouse(Tab.INVENTORY);
    				}
    				Inventory.interact("Tinderbox", "Use");
    				sleep(randomNum(500, 1000));
    				Inventory.interact("Logs", "Use");
    				sleep(randomNum(1000, 1500));
    				log("Waiting for the logs to be lighted, program will wait 25-30 seconds for this to succeed.");
    				sleepUntil(() -> !getLocalPlayer().isAnimating(), randomNum(25000, 30000));
    			}
    			log("Tile occupied, moving to new tile");
    			Walking.walk(fireMakingArea.getRandomTile());
    			sleep(randomNum(1000, 1500)); //Wait for player to start moving
    			sleepUntil(() -> !getLocalPlayer().isMoving(), randomNum(5000,7000));
    			break;

     

    Link to comment
    Share on other sites

    So `fireOnTile` should return false when there are no (aka null) fires on the players tile so we have just inversed that logic. Ive adjusted your code slightly to ensure its checking the correct object, things i would suggest you could look at improving would be:

    * Most dreambot methods return a boolean to say if the action was performed or not (like Inventory.interact) so you should add in checks to ensure when your interacting with the tinderbox/logs it was successful before continuing.

    * You can check if the tinderbox is selected with Inventory.isItemSelected()

    * random sleeps arent great as you cant gaurentee the action has completed within that random time, try and use sleepUntil wherever you can for a more fluid script

    * Try breaking each "case" block into its own function, it will help maintain readabilty as your script gets larger when using switch loops

     

                case FIREMAKINGFIRST:
                    log("Making 1 Fire");
                    playerTile = getLocalPlayer().getTile();
                    boolean fireOnTile = GameObjects.closest((f) -> f != null && f.getTile().equals(playerTile) && f.getName().equals("Fire")) != null;
                    if (fireOnTile) { //If there is a fire on the tile, lets move away
                        log("Tile occupied, moving to new tile");
                        Walking.walk(fireMakingArea.getRandomTile());
                        sleepUntil(() -> getLocalPlayer().isMoving(), randomNum(1000,1500)); //Wait until we are moving
                        sleepUntil(() -> !getLocalPlayer().isMoving(), randomNum(5000,7000)); //Wait until we are no longer moving
                    }
    
                    log("Tile not occupied - lighting fire");
                    if(!Tabs.isOpen(Tab.INVENTORY)){
                        Tabs.openWithMouse(Tab.INVENTORY);
                    }
                    Inventory.interact("Tinderbox", "Use");
                    sleep(randomNum(500, 1000));
                    Inventory.interact("Logs", "Use");
                    sleep(randomNum(1000, 1500));
                    log("Waiting for the logs to be lighted, program will wait 25-30 seconds for this to succeed.");
                    sleepUntil(() -> !getLocalPlayer().isAnimating(), randomNum(25000, 30000));
                    break;

     

    Link to comment
    Share on other sites

    Thank you so much for the elaborate responce TheCloakdOne! 💙

    I learned so much from your input and I've ajusted my code as to your suggestions:
    *I'm now using a boolean check to see if I completed the action that I wanted.
    *I converted the Case to a Function, enabling me to run it from outside the function/case and re-use the code.
     

    	public void lightFireSingle() {
    		while(true) {
    			log("lightFireSingle runs");
    			if(!Inventory.contains("Logs")){
    				log("Stopped lightFireSingle from running, no logs found in inventory.");
    				break;
    			}
    			shouldBreak = false;
    			log("Making 1 Fire");
    			playerTile = getLocalPlayer().getTile();
    			boolean fireOnTile = GameObjects.closest((f) -> f != null && f.getTile().equals(playerTile) && f.getName().equals("Fire")) != null;
    			if (fireOnTile) {
    				log("Tile occupied, moving to new tile");
    				Walking.walk(fireMakingArea.getRandomTile());
    				sleepUntil(() -> getLocalPlayer().isMoving(), randomNum(1000, 1500));
    				sleepUntil(() -> !getLocalPlayer().isMoving(), randomNum(5000,7000));
    				shouldBreak = false;
    				}
    			log("Tile not occupied - lighting fire");
    			if(!Tabs.isOpen(Tab.INVENTORY)){
    				Tabs.openWithMouse(Tab.INVENTORY);
    			}
    			Inventory.interact("Tinderbox", "Use");
    			sleep(randomNum(1000, 1500));
    			selectionComplete = Inventory.isItemSelected();
    			if(selectionComplete) {
    				log("Successfully selected Tinderbox to use.");
    				Inventory.interact("Logs", "Use");
    				log("Waiting for the logs to be lighted, program will wait 25-30 seconds for this to succeed.");
    				sleepUntil(() -> !getLocalPlayer().isAnimating(), randomNum(25000, 30000));
    				if(!getLocalPlayer().isAnimating()) {
    					shouldBreak = true;
    				}
    			}else {
    				log("Did not select Tinderbox successfully.");
    				shouldBreak = false;
    			}
    			if(shouldBreak == true) {
    				break;
    			}
    		}
    	}


    If you don't mind me tipping you for your time, please PM me your paypal and I'll send you a gift for helping me to learn :)
    Thanks once again! I really appreciate it!

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.