Jump to content

Where am I wrong?


MySQLi

Recommended Posts

Hey guys, just working on my first script, I've ran into another issue I can't seem to figure out.

  Reveal hidden contents

Where I'm;

if (feather != null)

return state.LOOT;

 

It's saying feather cannot be resolved to a variable, although I have it declared, can anyone tell me what I did wrong?

Link to comment
Share on other sites

Feather shouldn't be entity. It's a GroundItem. Also, I believe it's "Feathers" not "Feather"

So like this:

GroundItem feather = getGroundItems().closest("Feathers");

 

  On 6/23/2017 at 7:25 PM, MySQLi said:

Entity chicken = getNpcs().closest("Chicken");

Expand  

Chicken is an NPC not Entity.

Same goes for bones. It's a GroundItem

Edited by Visty
Link to comment
Share on other sites

  On 6/23/2017 at 7:34 PM, Visty said:

Feather shouldn't be entity. It's a GroundItem. Also, I believe it's "Feathers" not "Feather"

So like this:

GroundItem feather = getGroundItems().closest("Feathers");

 

Chicken is an NPC not Entity.

Expand  

I fixed that, but it still doesn't fix my issue, thank you for pointing that out though.

Link to comment
Share on other sites

  On 6/23/2017 at 7:42 PM, MySQLi said:

I fixed that, but it still doesn't fix my issue, thank you for pointing that out though.

Expand  

A better way imo to use states, is by creating a method for each state. In your case, make a method like public void Loot() {} //In this method you put everything you need.

Then in your getStates say like if (this & that) { return State.Loot; }

Then in your onLoop say like case LOOT: Loot(); break;

public enum State {
        WALK_TO_OAKS
}

public int onLoop() throws InterruptedException {
        s = getState();

        switch (s) {
			case WALK_TO_OAKS:
                Walk_To_Oak();
                break; 
        }
  
public void Walk_To_Oak() throws InterruptedException {
      paint.status = "Going To Oak Trees...";

      getWalking().walkPath(Arrays.asList(Oak_Path));
}

This is an example in one of my scripts that uses States.

Because tbf, reading that code gives me headaches, I can't see :doge: Because you are simply repeating your States on your onLoop.

Edited by Visty
Link to comment
Share on other sites

  On 6/23/2017 at 7:46 PM, Visty said:

A better way imo to use states, is by creating a method for each state. In your case, make a method like public void Loot() {} //In this method you put everything you need.

Then in your getStates say like if (this & that) { return State.Loot; }

Then in your onLoop say like case LOOT: Loot(); break;

Expand  

I just did that, It is working now. I must of had a small error somewhere that I wasn't picking up. Thanks, I appreciate it. When you're implementing sleeps, what time do you usually use? 5000 MS works for me, I one hit chickens, if you figure a level 3 fighting chickens, what do you image a good wait time is? Or is there another check without using waits to just check if the player is currently fighting, or looting?  

Link to comment
Share on other sites

  On 6/23/2017 at 7:50 PM, MySQLi said:

I just did that, It is working now. I must of had a small error somewhere that I wasn't picking up. Thanks, I appreciate it. When you're implementing sleeps, what time do you usually use? 5000 MS works for me, I one hit chickens, if you figure a level 3 fighting chickens, what do you image a good wait time is? Or is there another check without using waits to just check if the player is currently fighting, or looting?  

Expand  

I would use a conditionalSleep to check whether my player is under attack. I'm not too familiar with looting tbf, haven't worked with it yet. But I think you can do conditionalSleep then check in the inventory.

Edited by Visty
Link to comment
Share on other sites

  On 6/23/2017 at 7:34 PM, Visty said:

Feather shouldn't be entity. It's a GroundItem. Also, I believe it's "Feathers" not "Feather"

So like this:

GroundItem feather = getGroundItems().closest("Feathers");

 

Chicken is an NPC not Entity.

Same goes for bones. It's a GroundItem

Expand  

I'd suggest you read about inheritance and familiarise yourself with the API before you starting throwing claims about what is what.
Both GroundItem and NPC implement Entity.

Link to comment
Share on other sites

  On 6/23/2017 at 8:43 PM, Adept said:

l0l would you prefer to be corrected or continue living in ignorance?
oh wait, I know the answer
I appreciate it when ppl point out my mistakes. You'll start making mistakes too once you start writing your own code :leech:
:kappa:

Expand  

Considering actually learning Java as a language is neither my career choice nor something I actually give two shitsticks about, as long as I pull in an income to avoid having to slave while at Uni, ignorance is bliss. :boge:

(Also still awaiting for my own special :spoonfeed: emote :kappa:)

  • Like 1
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...