Go to file
tour dffa73e156 fix possible crash detected by luacheck 2024-04-09 23:05:48 +02:00
Screenshots add screenshots to git 2024-02-13 14:42:48 +01:00
locale Translation part 2 2024-02-14 13:38:45 +01:00
.gitignore Translation part 2 2024-02-14 13:38:45 +01:00
.luacheckrc start anew 2024-02-12 22:01:13 +01:00
chatcommands.lua fix: easySyntax not working for "" 2024-02-16 10:54:16 +01:00
context.lua fix error detected by luacheck 2024-02-14 13:31:26 +01:00
init.lua start anew 2024-02-12 22:01:13 +01:00
license.txt start anew 2024-02-12 22:01:13 +01:00
mod.conf start anew 2024-02-12 22:01:13 +01:00
preset_formspecs.lua remove a test formspec 2024-02-13 16:19:43 +01:00
readme.md Document translation in presets 2024-02-14 12:33:18 +01:00
settingtypes.txt start anew 2024-02-12 22:01:13 +01:00
show_receive.lua fix possible crash detected by luacheck 2024-04-09 23:05:48 +02:00
specs.lua box overlay to prevent click-events on the preview area. 2024-02-16 12:02:42 +01:00

readme.md

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 call chat_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)