[Mod] Central Message [0.3.0] [central_message]

Post Reply
User avatar
Wuzzy
Member
Posts: 4065
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

[Mod] Central Message [0.3.0] [central_message]

by Wuzzy » Post

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/)
Attachments
cmsg_demo.png
(27.64 KiB) Not downloaded yet
Last edited by Wuzzy on Sat Nov 12, 2016 18:21, edited 3 times in total.

User avatar
Hybrid Dog
Member
Posts: 2768
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

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

by Hybrid Dog » Post

What happens if a message contains newlines (\n or \r)?

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
Wuzzy
Member
Posts: 4065
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

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

by Wuzzy » Post

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.

User avatar
Hybrid Dog
Member
Posts: 2768
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

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

by Hybrid Dog » Post

l currently don't need a mod displaying important messages to players.
Do the messages also overlap if players use different font sizes?

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

User avatar
Wuzzy
Member
Posts: 4065
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

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

by Wuzzy » Post

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. :-)

User avatar
Wuzzy
Member
Posts: 4065
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Version 0.1.1 released!

by Wuzzy » Post

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.

User avatar
TeTpaAka
Member
Posts: 141
Joined: Sat Dec 28, 2013 21:54

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

by TeTpaAka » Post

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.

User avatar
Wuzzy
Member
Posts: 4065
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

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

by Wuzzy » Post

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. :-(

User avatar
Wuzzy
Member
Posts: 4065
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

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

by Wuzzy » Post

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).

slemon
Member
Posts: 111
Joined: Sun Apr 27, 2014 03:56

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

by slemon » Post

Hi Wuzzy. I think you might be interested in this mod viewtopic.php?f=9&t=13795&p=202584

User avatar
cd2
Member
Posts: 562
Joined: Mon Jun 01, 2015 06:30
GitHub: cdqwertz
In-game: cd cd2
Location: Linux
Contact:

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

by cd2 » Post

This looks nice, I will add it to rpgtest :)

User avatar
cd2
Member
Posts: 562
Joined: Mon Jun 01, 2015 06:30
GitHub: cdqwertz
In-game: cd cd2
Location: Linux
Contact:

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

by cd2 » Post

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)

wilkgr76
Member
Posts: 833
Joined: Wed Feb 18, 2015 02:44
GitHub: wilkgr76

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

by wilkgr76 » Post

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?
N/A

User avatar
Wuzzy
Member
Posts: 4065
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Version 0.3.0

by Wuzzy » Post

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.
My creations. I gladly accept bitcoins: 17fsUywHxeMHKG41UFfu34F1rAxZcrVoqH

User avatar
ratmix
Member
Posts: 148
Joined: Mon May 01, 2017 19:45
In-game: ratmix
Contact:

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

by ratmix » Post

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.
King of the Hill :: Modern Warfare Server RATMIX.COM:30000 | King of the Hill Community Site

User avatar
texmex
Member
Posts: 1752
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

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

by texmex » Post

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
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests