Jump to content

need help finding a good way to make a if statement to a state more reliable.


Twin

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

maybe instead of checking if the inventory has cannonballs, check when you have no supplies left to make cannonballs in your inventory? smile.png

 

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 by twin 763
Link to comment
Share on other sites

 

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.

 

Link to comment
Share on other sites

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 by 7331337
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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

 

 

 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...