Conversation API Confusion - Help please?

Discussion in 'Plugin Development' started by Chris Herbert, Mar 30, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Chris Herbert

    Would someone be so nice as to provide a very simple working example of a conversation.

    Something I can trigger on an NPC like... Would you like an [Apple] [Pear] or [Banana]

    I have looked at the API docs and searched the forums and I find bits of stuff here an there but nothing concrete that a simple beginner can grab and insert into a basic plugin template. I have seen class examples but no example included to actually call/trigger the conversation - this might be simple to Java veterans but I am totally new to Java and would appreciate a quick basic runnable example on the Conversation API since it seems quite complicated and little used by others so examples are thin on the ground.

    I have achieved quite a bit so far in the few days I have been coding - I have used the Citizens API to spawn some NPC's and I have managed to get them to react to Right Click and then trigger welcome messages stored in MySQL. All I need now is to be able to get them to offer quests from a database and have the user either ask for more information or to accept a quest. Obviously I can't use simple /commands because I need proof they are talking to the specific quest giver and that he is controlling and validating the conversation. It would seem the Conversation API is what is needed in this situation?

    Maybe someone has written a library to simplify the Conversation API? I couldn't find one. I know Questioner existed long ago but I guess that stopped development when the Conversation API was first implemented by Bukkit?

    I do appreciate anyone who can help.

    P.S I am using bleeding edge 1.5.1 dev builds.

    Thank you.
     
  2. Offline

    Nitnelave

    You have to understand one thing : you can't do a conversation directly between a player and an NPC. What you can do, though, is a conversation between a player and your plugin. For example, to create a conversation :
    Code:
    Conversation c = new ConversationFactory (myplugin).withFirstPrompt (firstPrompt).withPrefix ("quest giver").withTimeOut (30).addConversationAbandonnedListener (myListener).buildConversation (player);
    
    You have to create "Prompts" (question-answer pairs) to structure the conversation.

    But you can find more details here : https://docs.google.com/document/d/1ofTMA6dv7Vk3v4kKhLTC1sUooHgTq71ti44AI09OsNM/edit (first draft at a documentation)
    and an example plugin here : https://github.com/rmichela/ConversationsDemo/
     
  3. Offline

    lycano

    No one know the good old text based adventure games where you have to answer questions (prompts) to choose what to do next?
     
  4. Offline

    Chris Herbert

    Thats funny because I have already done it.

    I have NPC's and you can right click on them and start talking to them.
     
  5. I wrote Vocalise about a year ago. It's a small library to add some default prompts and has a prompt builder that takes a yaml config and builds a graph of prompts from the config.

    The source code is here:
    https://github.com/tehbeard/Vocalise

    Example code:
    (Setup,configuration and loading yaml)
    https://github.com/tehbeard/BeardSt...rd/BeardStat/commands/StatCommand.java#L39-47

    (Starting a conversation)
    https://github.com/tehbeard/BeardSt...rd/BeardStat/commands/StatCommand.java#L79-91

    (yaml config)
    https://github.com/tehbeard/BeardStat/blob/develop/src/main/resources/interactive.yml
     
    Chris Herbert likes this.
Thread Status:
Not open for further replies.

Share This Page