Jump to content

Talking with NPCs


Recommended Posts

Posted (edited)

I'm trying to make a simple blast furnace script for myself and friends to use, i.e. no paint & bare bones code. When it talks to the foreman, I just hard-coded a simple 3-second sleep after every command. Is there a method in the API that can tell when the next dialogue has not yet appeared and it's still waiting for the next one? My current code is like so:

dialogues.clickContinue();
sleep(3000);
dialogues.selectOption("What?");
sleep(3000);
dialogues.clickContinue();
sleep(3000);
dialogues.clickContinue();
sleep(3000);
dialogues.selectOption("Can I use the furnace to smelt ore?");
sleep(3000);

I would prefer it to be like this:

dialogues.clickContinue();
while(/*is waiting for the next prompt*/){
   sleep(250);
}
dialogues.selectOption("What?");
while(/*is waiting for the next prompt*/){
   sleep(250);
}
dialogues.clickContinue();
while(/*is waiting for the next prompt*/){
   sleep(250);
}
dialogues.clickContinue();
while(/*is waiting for the next prompt*/){
   sleep(250);
}
dialogues.selectOption("Can I use the furnace to smelt ore?");
while(/*is waiting for the next prompt*/){
   sleep(250);
}

Thanks, BTheBrave

Edited by bthebrave
Posted (edited)

I wouldn't do this. This will be really buggy and hardly work. Use if-else method and get the ids for every widget; by that you can check if a widget is null or not.

 

For instance:

if(widget1 != null) {
    do action
      for(int i = 0; i < 100 && widget1 != null; i++) {
             sleep(random(4, 8));   // will sleep random 400-800 ms since 4*100=400 and 8*100=800, or till widget1 == null
      }
} else {
    talk to foreman and wait for widget1 using dynamic sleep like a for-loop
}

and so on

Edited by Woody
  • Like 1

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
  • Recently Browsing   0 members

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