locale | ||
Screenshots | ||
.gitignore | ||
.luacheckrc | ||
chatcommands.lua | ||
context.lua | ||
init.lua | ||
license.txt | ||
mod.conf | ||
preset_formspecs.lua | ||
readme.md | ||
settingtypes.txt | ||
show_receive.lua | ||
specs.lua |
Chat Formspec
Players do not respond to messages in Chat? Maybe they don't even notice because there Chat is hidden. Show them a formspec, so they need to show some sort of reaction (even closing the formspec is something)
Easy Syntax
For better usability, this mod provides an easy syntax for formspecs:
<some text>[#answer1[#answer2]]
Everything until the first #
will be displayed as text in a textarea. With the first #
the answer options start.
Each answer option you give will be added as a new button.
If you provide no answer option, a field will be added.
As the sender you can also select from preset formspecs.
Examples:
You have shown behavior about which we have some questions for reasons of moderation. It would be nice if you could answer them. Otherwise we will unfortunately have to resort to other means.#
Can you read this#YES#NO
Chatcommands
/chat_formspec
will open a formspec where you can create your own chat_formspec before sending it out/chat_formspec <playername>
will autofill the field for the playername/chat_formspec <playername>,<easy syntax>
will prepare your creation formspec with the easy syntax you provided. You just have to hit the send button if it looks like you want to have it/chat_formspec <playername>,<preset>
will look if there is a preset chat_formspec (see configuration) and will pepare you creation formspec with that one. If none is defined,<preset>
will be interpreted as easy syntax
Configuration
- In
settingtypes.txt
you can set the priv needed to allow players to send out chat_formspecs. - you can modify
chat_formspec.preset
from another mod. This is a table indexed by name, with a easy Syntax String as value. you must callchat_formspec.update()
afterwards- You can use translated text in the presets too. make sure that the translation is not splitted by #'s. The text will already appear translated in the senders formspec so he will see the translation based on his locale
Example
chat_formspec.preset = {} -- delete all presets defined so far
chat_formspec.preset.Question = "What is the answer#42"
chat_formspec.preset.tell_me = "Tell me something#"
-- translation example
local S = minetest.get_translator("mymod")
chat_formspec.preset.translation = S("Can you read this") .. "#"
.. S("Yes") .. "#" .. S("No")
chat_formspec.update()
Known problems
Easy Syntax
Easy Syntax uses #
's to split text and answers. This makes it impossible to use a # inside a chat_formspec
Minetest Formspec Problems
Minetest provides no way to check wheter a player has a formspec open. Sending him a chat_formspec will close any formspec this player has open. This might lead to problems with another mod still waiting for input from this formspec.
All this mod can do is to check wheter a player is dead and not show a formspec in that case.
Same goes for the other direction. This mod makes use of contexts. If a chat_formspec is closed without a quit-event, the context can't be cleared (minor memory leak)