Conversations API Q&A - I wrote the Conversations API, AMA

Discussion in 'Plugin Development' started by deltahat, Apr 2, 2012.

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

    deltahat

    Plugin developers,
    The Conversations API is a new Bukkit API for creating an interactive dialog between your plugin and a player. For the duration of the conversation your plugin has exclusive access to the player's console, enabling a back and forth conversation to take place.

    Example uses include:
    • Creating Bethesda-esque (KOTR, Mass Effect, Dragon Age) dialog trees between players and NPCs
    • Creating an in-game line editor for writing books
    • Requesting parameters one at a time with descriptions and validation, rather than all at once using command parameters
    The initial draft of the documentation can be found here (it's kind of advanced). Please ask me any questions you may have about what the API can do and how you can integrate it into your plugins. I will use the feedback here to write a more introductory wiki page for the bukkit wiki.
    I also wrote a sample plugin that demonstrates how to use the Conversations API on github.
     
  2. Offline

    Father Of Time

    Simply brilliant, I had no idea that this API even existed! I was only able to quickly read over the external link you provided regarding the API because I'm currently at work, but from what I've seen so far I am very excited to dive in and begin experimenting. I can think of many ways this API can be implemented into my current projects to help bring the project together in a usability perspective, but i do have one question.

    From what I've read it appears to be a text based interface, by this I mean it appears that a conversation is conducted utilizing the in game chat and commands; is this true? I am wondering if this API has a new "conversation" GUI, or is an entire conversation conducted via chat input?

    either way I am excited about the potential of this API, I've been hoping for a vanilla API that would allow me to put a "GUI" of sorts, a navigable menu to several of my plug-ins.

    Thank you for making these additions to Bukkit's API more publicly know, I look forward to seeing how the public utilizes these new tools. :D
     
  3. Offline

    deltahat

    Conversations can only be text-only in the console. There is no way for bukkit to modify the client UI.
     
  4. Thanks, I already read a bit of tehbeard introduction which already helped me, but some things we not included e.g. the prefix. So I have a question regarding this prefix. Is it possible to only add the prefix to the prompt message and not the player message? So when a plugin starts a conversation with a prompt saying "can you help me?" the prefix gets applied to it, but when the players writes "yes" in the chat it won't get applied. Is this possible?
     
  5. Offline

    deltahat

    Sure. Use the NullConversationPrefix for your conversation and put a fake prefix at the beginning of all your prompt messages.
     
  6. I feel pretty dumb now not seeing this obvious possibility. Thanks!
     
  7. Holy crap. Lot of stuff I didn't know about the API :)

    Might be able to get my villagerVoice example out in the next week or two that shows off a Bethesda style setup. No promises though, RL is getting in the way.
     
  8. Well, it's really easy to work with, but since the provided prompts doesn't do what I really want to I did my own prompts and stuff and it works really amazing. I might look like a showoff here, but this is what it looks like:
    Show Spoiler

    [​IMG]

    Everything is stored in a database and only like 5% hard-coded. And no, it's not the real notch ofc. However, prompts are likely to be similar to boolean-prompts with the addition of making sentences and not just having the output true and false but true, nearly true, false, nearly false and considering are valid inputs. So for each answer the player gives there are 5 possible ways the dialog could continue. The "ai" is in an alpha state and might not accept all answers, but it's getting better :)
     
    Choltfo, Sabersamus and deltahat like this.
  9. Offline

    deltahat

    I love it! This kind of thing is what Conversations were made for.

    If you created a ConversationCanceller, you could have the conversation terminate if you walk too far from the NPC you are talking to.
     
  10. Offline

    Lolmewn

    Very, very interesting. Will definitely try it out very soon :D
     
  11. Offline

    Father Of Time

    kumpelblase2 Just curious, for the NPC aspect of your system are you using vanilla Bukkit, or are you using the NPCLib? At this point I am utilizing villagers because players can breed and cultivate them, but it would be nice to gain more flexibility.
     
  12. Offline

    dsmyth1915

    This API is AMAZING. I absolutely live it. The in depth that in can go is endless, somebody(with enough time of course) could recreate dialogue from dragon age or skyrim just for they're RPG server. Looking through the gituhub of your example API, shouldn't you have an @EventHandler over your conversationAbandoned event? deltahat
     
  13. Thanks for the tip, gonna take a look at that!

    Currently I use the npc lib and it works pretty well. The problem I'm currently having is that the faces of the npcs don't look in the correct direction even if you change the yaw (pitch works completely fine though). Also setting the skin doesn't work for me either, but maybe I can find a way.
     
  14. Offline

    Father Of Time

    Ah cool beans, I figured as much since I had not read anything about a new NPC library yet. I've just been avoiding that library all together in hopes that some day Bukkit would offer something comparable in the vanilla. I have really been enjoying using villagers to perform job task on my server, but having more skin and profession choices would definitely be a bonus. However, because of the new gained "purposes" of the NPC the players are growing an insane loyalty to their villagers, protecting them for dear life. For instance...

    I have a vault system that utilizes librarian villagers as "bankers". Players can only access their bank accounts if they either know someone with a secure bank already built, or lore a wild villager to their city and breed them until a librarian is born. By the time they go through the work of finding, luring, building housing for, and breeding villagers they grow a level of pride over them... Which was completely unexpected.

    Ever since I released this I have been tickled to death with the player created cities that have popped up, and the lengths people are going through to save their villagers. The idea of providing these villagers with programmable conversations only increases my excitement for this and other projects in which I wished to "humanize" the villagers and give them some level of worth other than slaying aimlessly for giggles.

    Well I've managed to get way off topic, sorry I was just interested in the NPC aspect of this conversation. :D
     
  15. Offline

    Crast

    Is there a way to have a conversation "passthru" slash commands? That is, I have a certain part of a conversation where the user is asked to walk to the first corner of a region he is selecting and type 'start', then go to the next point and type somehting else, etc.

    It'd be nice if during this conversation, the user is allowed to use commands he might have use of, like /warp, /top, whatever (and I don't know these commands specifically, since they're not part of my plugin, I'd just like to have it pass through any possible command.)

    One way I am thinking of trying is having it intercept the input and pass it to plugin.getServer().getPluginCommand(name).execute(...), but that requires me to:
    1) parse the command into command and args portions (string splitting and such)
    2) look up the command label in the aliases lookup
    3) get the appropriate command and pass info

    There has to be an easier way, can I get it at some other level in the conversation API?

    edit I just found Player.performCommand, this could potentially work, though perhaps some state would be needed to prevent a prompt being shown immediately after the command.
     
  16. Offline

    deltahat

    Good! You found Player.performCommand(). I was just going to suggest that. You can use the ConversationContext to track any state you need to get the user back on track with the conversation.
     
  17. Offline

    Crast

    It sort of works, but the display is a little out of order. Also ideally, the /command input would be suppressed, is there any way for a Conversation or Prompt to completely hide the user's input?

    Code looks like:
    (in acceptValidatedInput)
    Code:
    protected Prompt acceptValidatedInput(ConversationContext ctx, String s) {
        Conversable c = ctx.getForWhom();
        if (c instanceof Player) {
            Player player = (Player) c;
     
            if (s.startsWith("/")) {
                player.performCommand(s.substring(1));
                return this;
            }
            // other input options follow
        }
    }
    
    I type in /top

    I expect the chat to look something like:
    Code:
    PromptText1
    /top
    <output of top command, if any>
    PromptText2
    
    What it actually looks like:

    Code:
    PromptText1
    <output of top command>
    PromptText2
    /top
    
    Which leaves me scratching my head, though I suppose it could be due to 1.3.1 running its chat engine in a separate thread, causing out-of-order responses.

    Any suggestions?

    Screenshot follows:
    [​IMG]
     
  18. Offline

    gokarter24

    deltahat I'm trying to understand how this exactly works, could you help me? I'm trying to use it so when a player right clicks a sign and if its a sell sign in the chat it comes up with a prompt/question asking them how many they'd like to sell they then type in how many they want to sell then I can do whatever I want with the amount.
     
  19. Offline

    mythbusterma

Thread Status:
Not open for further replies.

Share This Page