Jump to content
bthebrave

Talking with NPCs

Recommended Posts

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

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
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.

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...