Twin Posted February 26, 2015 Share Posted February 26, 2015 My whole script works fine, it's just this if(SMITH.contains(myPlayer())&&inventory.contains(2353)&&!myPlayer().isAnimating()&&!inventory.contains("Cannonball")) everything works all fine and dandy until an event comes in the middle of smithing, because when it goes to dismiss a random event, it will have cannon balls and won't go back to smithing, What would be abetter way to do this. Quote Link to comment Share on other sites More sharing options...
Precise Posted February 26, 2015 Share Posted February 26, 2015 My whole script works fine, it's just this if(SMITH.contains(myPlayer())&&inventory.contains(2353)&&!myPlayer().isAnimating()&&!inventory.contains("Cannonball")) everything works all fine and dandy until an event comes in the middle of smithing, because when it goes to dismiss a random event, it will have cannon balls and won't go back to smithing, What would be abetter way to do this. maybe instead of checking if the inventory has cannonballs, check when you have no supplies left to make cannonballs in your inventory? Precise Quote Link to comment Share on other sites More sharing options...
Swizzbeat Posted February 26, 2015 Share Posted February 26, 2015 More than likely you're doing this because the player stops animating in between smelting and the bot goes and attempts to smelt again? Just monitor your last smithing xp gain and if it was over a certain threshold then you know you have to smith. 1 Quote Link to comment Share on other sites More sharing options...
Twin Posted February 26, 2015 Author Share Posted February 26, 2015 (edited) maybe instead of checking if the inventory has cannonballs, check when you have no supplies left to make cannonballs in your inventory? Precise I think I already have that there with the inventory.contains(2353)//2353 is steel bar id When I had it without the cannonballs, it would constantly go back and redo the entire process of selecting the steel bar, furnace, then clicking on steel bars and making all again. and it would do this after every 3 or 4 cannon balls. case SMITH: Entity furnace = objects.closest("Furnace"); sleep(random(1000,2000)); inventory.interact("Use", 2353); sleep(random(500,1000)); furnace.interact("Use"); sleep(random(2000,3000)); if(!inventory.isItemSelected()) { this.interfaces.interactWithChild(309, 2, "Make All"); sleep(random(10000,20000)); break; } that's my smith state if that helps Edited February 26, 2015 by twin 763 Quote Link to comment Share on other sites More sharing options...
Botre Posted February 26, 2015 Share Posted February 26, 2015 maybe instead of checking if the inventory has cannonballs, check when you have no supplies left to make cannonballs in your inventory? Precise Quote Link to comment Share on other sites More sharing options...
Precise Posted February 26, 2015 Share Posted February 26, 2015 what do you do after that if statement? Quote Link to comment Share on other sites More sharing options...
Twin Posted February 26, 2015 Author Share Posted February 26, 2015 what do you do after that if statement? The one that this thread was about or the if statement in my state? The one my thread is talking is return State.SMITH; the one in the code I linked just breaks after a little bit Quote Link to comment Share on other sites More sharing options...
Botre Posted February 26, 2015 Share Posted February 26, 2015 (edited) Pseudocode: if !got steel bars -> bank if animating -> idle else -> smith Edited February 26, 2015 by Botre 1 Quote Link to comment Share on other sites More sharing options...
Precise Posted February 26, 2015 Share Posted February 26, 2015 Pseudocode: if !got steel bars -> bank else { } this^^ what is should be: if(SMITH.contains(myPlayer()) && inventory.contains(2353) && !myPlayer().isAnimating()) { //smith } Quote Link to comment Share on other sites More sharing options...
Twin Posted February 26, 2015 Author Share Posted February 26, 2015 Pseudocode: if !got steel bars -> bank if animating -> idle else -> smith I had animating originally, but the smithing animation stops for about 2 seconds or so inbetween, so it goes back and does it all over again. I'm going to try an idea I had to see if that works i'll report back. Quote Link to comment Share on other sites More sharing options...
7331337 Posted February 26, 2015 Share Posted February 26, 2015 (edited) Why not do something like; // Check the distance on how close we are if ((myPlayer().getX() - objects.closest("Furnace").getX()) < 3 && (myPlayer().getY() - objects.closest("Furnace").getY()) < 3){ // Check if we're doing anything if (myPlayer().getInteracting() == null && myPlayer().isAnimating() == false){ // Check if we have steel bars or whatever in our inventory still if (inventory.contains("Steel Bar")){ return somethingSmithingGoesHere; // Return to make it start smithing } } } Edit; I'm bored I'll make a c-ball maker. Edited February 26, 2015 by 7331337 Quote Link to comment Share on other sites More sharing options...
Botre Posted February 26, 2015 Share Posted February 26, 2015 I had animating originally, but the smithing animation stops for about 2 seconds or so inbetween, so it goes back and does it all over again. I'm going to try an idea I had to see if that works i'll report back. You could track the time since you last animated; variable t = time since last animation constant x = duration of the smithing animation if t exceeds x -> if you still have supplies -> smith else -> bank else -> idle Quote Link to comment Share on other sites More sharing options...
Twin Posted February 26, 2015 Author Share Posted February 26, 2015 Why not do something like; // Check the distance on how close we are if ((myPlayer().getX() - objects.closest("Furnace").getX()) < 3 && (myPlayer().getY() - objects.closest("Furnace").getY()) < 3){ // Check if we're doing anything if (myPlayer().getInteracting() == null && myPlayer().isAnimating() == false){ // Check if we have steel bars or whatever in our inventory still if (inventory.contains("Steel Bar")){ return somethingSmithingGoesHere; // Return to make it start smithing } } } Edit; I'm bored I'll make a c-ball maker. Had no idea getInteracting was a method, that should fix this actually. Quote Link to comment Share on other sites More sharing options...
Roar Posted February 26, 2015 Share Posted February 26, 2015 declare steelBar variable locally or globally depending on where you need it. int steelBar; //assign steelBar a value - find osbot getID method in api - I don't remember it exactly; if(SMITH.contains(myPlayer())&&inventory.contains(steelBar)&&!myPlayer().isAnimating()) { smith your shit } So if you have a steel bar, proceed to smith it to cannonballs - else do something else. That's how I'd do it anyway ^^ although I'm new so maybe there are better ways Quote Link to comment Share on other sites More sharing options...
Botre Posted February 26, 2015 Share Posted February 26, 2015 Had no idea getInteracting was a method, that should fix this actually. Will not work. getInteracting() returns a Character. Quote Link to comment Share on other sites More sharing options...