Page 1 of 1

[Mod] Central Message [0.3.0] [central_message]

Posted: Wed Jul 01, 2015 22:07
by Wuzzy
This Minetest mod is purely an API mod which allows other mods to display a short message at the center of the screen.
It is directed to mod and subgame authors. Players only need to download this if another mod depends on it.

Each message is displayed for 5 seconds, then it is removed. By default, up to 7 messages are displayed at once (further messages will cause the oldest message to be removed).
When multiple messages are pushed quickly in succession, the messages will be “stacked” on the screen.
Messages can either be displayed to a single single player, or to all players at once.
Some server configuration can be made in the advanced settings menu.
The API functions are thus very analogous to minetest.send_chat_player and minetest.send_chat_all.

This is how it looks after I have quickly pushed 10 example messages:
Image

This mod can be useful to inform about all sorts of events and is an alternative to use the chat log to display special events. In my opinion, the chat log can be quickly become very crowded if mods put all sorts of generic messages into it. Which motivated the creation of this mod.

Some usage examples:
  • Messages about game events, like victory, defeat, next round starting, etc.
  • Error message directed to a single player
  • Informational messages
  • Administational messages to warn players about a coming server shutdown
The API documentation is in the README.md file.


Download: http://repo.or.cz/minetest_central_mess ... 05a58a.zip
Dependencies: None!
License of everything: WTPFL
Project page (with Git repository links): http://repo.or.cz/w/minetest_central_message.git
Current version: 0.3.0 (For this mod I use Semantic Versioning 2.0.0, see http://semver.org/)

Re: [Mod] Central Message [0.1.0] [central_message]

Posted: Thu Jul 02, 2015 14:49
by Hybrid Dog
What happens if a message contains newlines (\n or \r)?

Re: [Mod] Central Message [0.1.0] [central_message]

Posted: Thu Jul 02, 2015 16:21
by Wuzzy
Sorry, messages with newlines are currently not supported.
If you provide a newline in a message anyways, the message will be written as 2 lines indeed; however, the problems begin when there are multiple messages with newlines; the texts will overlap.

I could try to add newline support if you want, however, I would not recommend to push a lot of messages containing newlines even then.

Re: [Mod] Central Message [0.1.0] [central_message]

Posted: Fri Jul 03, 2015 10:39
by Hybrid Dog
l currently don't need a mod displaying important messages to players.
Do the messages also overlap if players use different font sizes?

Re: [Mod] Central Message [0.1.0] [central_message]

Posted: Fri Jul 03, 2015 18:05
by Wuzzy
Yes, but only if the font is very big. This is also the case for custom GUI scaling.

I just had an idea how to fix both issues at once: I simply store the entire text in a single HUD element, and add newlines, rather than putting each message into a single HUD element. Hopefully this works. :-)

Version 0.1.1 released!

Posted: Fri Jul 03, 2015 22:06
by Wuzzy
Okay, I have released version 0.1.1.

As I said, I have changed the way how the text is displayed, so this fixes issues with custom font sizes, gui scalings or multi-line texts, as pointed out by Hybrid Dog. This mod should now work no matter on the font or GUI scaling.

However, there is a regression as well; text is no longer centered, but left-justified. This is because apparently Minetest fails to actually align multi-line text (“align” as in “left-justified”, “centered”, “right-justified”), see here: https://github.com/minetest/minetest/issues/2871. I hope this issue to be fixed in Minetest.

Re: [Mod] Central Message [0.1.1] [central_message]

Posted: Tue Jul 14, 2015 12:00
by TeTpaAka
Wuzzy wrote:Okay, I have released version 0.1.1.

As I said, I have changed the way how the text is displayed, so this fixes issues with custom font sizes, gui scalings or multi-line texts, as pointed out by Hybrid Dog. This mod should now work no matter on the font or GUI scaling.

However, there is a regression as well; text is no longer centered, but left-justified. This is because apparently Minetest fails to actually align multi-line text (“align” as in “left-justified”, “centered”, “right-justified”), see here: https://github.com/minetest/minetest/issues/2871. I hope this issue to be fixed in Minetest.
There is another regression, too. Previously, messages could have individual colors. Now, every message has the same color.

Re: [Mod] Central Message [0.1.1] [central_message]

Posted: Wed Jul 15, 2015 04:23
by Wuzzy
Oh boy. This is bad. Basically there is no real way to fix this. Basically, there are two possibilities:
  • Implement each message as independent HUD element.
  • Put all messages in a single HUD element and seperate them with newlines
Too bad that both possibilities have drawbacks. The first one does not scale well with the screen and does not work at all with custom font and GUI sizes.
The drawbacks of the second are pointed out in the last 2 posts.

So no matter what I do, there is always a loss. Apparently, there is currently no way to both have individual colorzied messages and a proper spacing between lines.

I guess I stick with the second option for now, even if it sucks. The proper line spacing is more important than individual color. But I first have to change the mod a bit to handle color in a less-stupid way. Maybe configure the text color in a single minetest.conf setting, and this color is used by all messages. Of course, this also means that the color parameter in the functions has to go. :-(

Re: [Mod] Central Message [0.2.0] [central_message]

Posted: Wed Jul 15, 2015 17:10
by Wuzzy
I have just released 0.2.0 to clean up the color-related regression.
Basically, I have accepted this regression. I had to choose between two “bads”, and I hope I picked the “lesser bad”.
  • “color” parameter has been removed from functions, because it doesn't work anyways (the message color just “stick” to be the color of the first posted message, so it's pretty pointless). This change is backwards-compatible; if your code still provides the “color” argument, it is simply ignored now.
  • Message color is instead configured in a new minetest.conf setting central_message_color (see readme file). This setting affects all messages globally. Default color is white (0xFFFFFF).

Re: [Mod] Central Message [0.2.0] [central_message]

Posted: Sun Dec 27, 2015 02:34
by slemon
Hi Wuzzy. I think you might be interested in this mod viewtopic.php?f=9&t=13795&p=202584

Re: [Mod] Central Message [0.2.0] [central_message]

Posted: Wed Dec 30, 2015 16:19
by cd2
This looks nice, I will add it to rpgtest :)

Re: [Mod] Central Message [0.2.0] [central_message]

Posted: Sat Jan 16, 2016 10:42
by cd2
When a player leaves the game after 0 - 5 seconds after he/she got a message, the server will shut down.
(I fixed this bug in the version of this mod, I use for RPGtest)

Re: [Mod] Central Message [0.2.0] [central_message]

Posted: Sat Jan 23, 2016 06:15
by wilkgr76
Perhaps add a way to add a bar, such as to show how long to wait before the max. damage can be inflicted by a sword.
I am currently unsure about new features. Do you have any suggestions or questions concerning the API?

Version 0.3.0

Posted: Sat Nov 12, 2016 18:24
by Wuzzy
Version 0.3.0 released! Changelog:

- Fix crash when player leaves before the messages disappear (thanks, cd2!)
- It is now possible to set the message duration in the server configuration
- You can now change the mod configuration in the advanced settings menu
- Add mod.conf, fix typos and clearnup README
Perhaps add a way to add a bar, such as to show how long to wait before the max. damage can be inflicted by a sword.
Suggestion rejected. This is out of scope for this mod. The scope is showing simple text messages.

Re: [Mod] Central Message [0.3.0] [central_message]

Posted: Wed May 31, 2017 09:42
by ratmix
Great mod. It would be nice to overrule the default message time for particular messages that need a longer duration. Something like: cmsg.push_message_player(player, message, duration) where duration is optional. I guess there might be a problem if shorter duration messages replace (scroll up) those with a longer duration.

Re: [Mod] Central Message [0.3.0] [central_message]

Posted: Wed May 31, 2017 13:44
by texmex
Hey Wuzzy. I've been looking for a mod to display notifications type of messages to the player. This one seems closest to what I need. Knowing you're developing MineClone2, I guess sooner or later you'll need notifications of a similar type I'm looking for as well.

I feel that a chat should contain players' messages to each other, not be a miniature event log. Interception could remedy that. I wonder if you'd thought about intercepting certain message types to display with central_message instead. Is it even possible?

I also wonder if you'd thought about some super simple styling of each message, like so. Not sure where you draw the line for the scope of "showing simple text messages". :)

Cheers