[Mod] Central Message [0.3.0] [central_message]

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

[Mod] Central Message [0.3.0] [central_message]

by Wuzzy » Wed Jul 01, 2015 22:07

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

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

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

by Hybrid Dog » Thu Jul 02, 2015 14:49

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

User avatar
Wuzzy
Member
 
Posts: 2161
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 » Thu Jul 02, 2015 16:21

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.
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

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

by Hybrid Dog » Fri Jul 03, 2015 10:39

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: 2161
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 » Fri Jul 03, 2015 18:05

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: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Version 0.1.1 released!

by Wuzzy » Fri Jul 03, 2015 22:06

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.
 

TeTpaAka
Member
 
Posts: 131
Joined: Sat Dec 28, 2013 21:54

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

by TeTpaAka » Tue Jul 14, 2015 12:00

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: 2161
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 » Wed Jul 15, 2015 04:23

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: 2161
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 » Wed Jul 15, 2015 17:10

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: 77
Joined: Sun Apr 27, 2014 03:56

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

by slemon » Sun Dec 27, 2015 02:34

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

User avatar
cd2
Member
 
Posts: 552
Joined: Mon Jun 01, 2015 06:30
GitHub: cdqwertz
IRC: freenode - cd2 InchraNet - cd
In-game: cd cd2

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

by cd2 » Wed Dec 30, 2015 16:19

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

User avatar
cd2
Member
 
Posts: 552
Joined: Mon Jun 01, 2015 06:30
GitHub: cdqwertz
IRC: freenode - cd2 InchraNet - cd
In-game: cd cd2

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

by cd2 » Sat Jan 16, 2016 10:42

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)
 

User avatar
wilkgr76
Member
 
Posts: 680
Joined: Wed Feb 18, 2015 02:44
GitHub: wilkgr76
IRC: wilkgr
In-game: wilkgr

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

by wilkgr76 » Sat Jan 23, 2016 06:15

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?
I do not care.
 

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

Version 0.3.0

by Wuzzy » Sat Nov 12, 2016 18:24

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.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 8 guests

cron