Well, reading through some recent changelogs I found out about this feature I didn't even know about. It's not really mentioned anywhere in the helpfile that I can see, but that's not as important.
I'm kind of sad that the little window that pops up is so... limited. The list of words that it can match is limited to Lua only (for as far I can tell), and I'd personally like to throw some Python stuff into it. Or worse... I'd like to use it for totally different purposes. (In advance I want to apologize for having so many suggestions lately. :D)
A bunch of things I am envisioning to be able to use it for are:
- auto-completing Python code
- using it as a word list for ingame languages (see example at bottom)
- context-sensitive popups with choices (travel where? <list of locations>, barter/flirt/threaten for an encount with a merchant, etc)
A bunch of changes that I think would be needed to make it possible: (I'll include code examples in Python, since I will otherwise totally ruin Lua grammar with Pythonisms in it.)
- a way to open the list with choices of my liking. Preferably it passing some kind of list/table as choices, and to specify a callback to use upon completion. Example:
Note that it will just put the stuff in the command window and will require the user to press enter to actually send it. If direct-sending was preferred, world.Send() is your friend. I'm sure there's a command to change the contents of the inputbox somewhere too, in the case people want to adjust it differently.
- Maybe have a lot of little prettiness features, too. For example, basing it on the previous example:
Or maybe an xml-inspired template would be easier and more customisable in the long run:
Idea being that it makes it possible to give simple choices that are somewhat customizable and easy to use and understand.
Another example of how I'd like to implement some sort of translation-help. It's a bit pseudo-codish, seeing how I'm pretty tired and it's just to give an idea of the uses.
Basic idea: you're writing a say, and your character likes to occasionally speak in his native tongue. You don't want to replace all words, but rather translate specific ones. So when you need them, you go CTRL+D, find "I" (or type it), enter, find "love" (or type it), enter, find "you" (or type it), enter, escape. Then you can happily continue to write the rest of your emote.
The above might be a little troublesome due to popping up a second window from the callback. Probably the API suggestions I made above won't be usable (if only for the horrid choice of naming), but I hope it demonstrates the uses I see with this window+functionality opened up to scripting.
I'm kind of sad that the little window that pops up is so... limited. The list of words that it can match is limited to Lua only (for as far I can tell), and I'd personally like to throw some Python stuff into it. Or worse... I'd like to use it for totally different purposes. (In advance I want to apologize for having so many suggestions lately. :D)
A bunch of things I am envisioning to be able to use it for are:
- auto-completing Python code
- using it as a word list for ingame languages (see example at bottom)
- context-sensitive popups with choices (travel where? <list of locations>, barter/flirt/threaten for an encount with a merchant, etc)
A bunch of changes that I think would be needed to make it possible: (I'll include code examples in Python, since I will otherwise totally ruin Lua grammar with Pythonisms in it.)
- a way to open the list with choices of my liking. Preferably it passing some kind of list/table as choices, and to specify a callback to use upon completion. Example:
# you get a choice, plugin goes
world.ShowSuggestions(["barter", "flirt", "threaten"], "MerchantBartering")
# definition of MerchantBartering
def MerchantBartering(choice):
if (choice != None):
world.Note("The choice was '%s', and we will insert '%s' in the command window at the current position." % (choice, choice.upper())
return choice.upper() # Place choice.upper() at current position in the command-window. None would be the same as not outputting anything.
else:
world.Note("Left the choices popup without making a choice.")
return "run from merchant for wasting his time"Note that it will just put the stuff in the command window and will require the user to press enter to actually send it. If direct-sending was preferred, world.Send() is your friend. I'm sure there's a command to change the contents of the inputbox somewhere too, in the case people want to adjust it differently.
- Maybe have a lot of little prettiness features, too. For example, basing it on the previous example:
# Put a label with Action above the choices, with flirt selected by default.
world.ShowSuggestions("Action?", ["barter", "flirt", "threaten"], "flirt", "MerchantBartering")Or maybe an xml-inspired template would be easier and more customisable in the long run:
# Use the template interact_mob:
world.ShowSuggestions(["barter", "flirt", "threaten"], "interact_mob", "MerchantBartering")
# Example XML:
<suggestions>
<suggestion
name="interact_mob"
label="Action?"
label_fg="#550000"
label_bg="lightgreen"
label_font="Verdana"
label_font_size="12"
choice_bg="white"
choice_fg="black"
choice_selected_bg="lightblue"
choice_selected_fg="yellow"
choice_font="Dina"
choice_font_size="10">
</suggestion>
</suggestions>
Idea being that it makes it possible to give simple choices that are somewhat customizable and easy to use and understand.
Another example of how I'd like to implement some sort of translation-help. It's a bit pseudo-codish, seeing how I'm pretty tired and it's just to give an idea of the uses.
world.Accelerator("Ctrl+D", "/TranslationHelp()")
Words = {"I":"nia", "love":"goqu", "you":"dii"}
def TranslationHelp():
world.ShowSuggestions("Word?", Words.getkeys(), "TranslateWord")
def TranslateWord(choice):
if (choice != None):
# Pop the dialog up for the next word.
TranslationHelp()
# Insert current choice, but translated.
return Words[choice]
Basic idea: you're writing a say, and your character likes to occasionally speak in his native tongue. You don't want to replace all words, but rather translate specific ones. So when you need them, you go CTRL+D, find "I" (or type it), enter, find "love" (or type it), enter, find "you" (or type it), enter, escape. Then you can happily continue to write the rest of your emote.
The above might be a little troublesome due to popping up a second window from the callback. Probably the API suggestions I made above won't be usable (if only for the horrid choice of naming), but I hope it demonstrates the uses I see with this window+functionality opened up to scripting.