mod to highlight when a player joins or leaves?

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

mod to highlight when a player joins or leaves?

by Joseph16 » Post

Is there a mod that will show in highlighted text when a player joins or leaves? I joinded a random MT server earlier and It has that feature. I already look on the forums for a mod but no luck. Any help would be awesome! Thanks!
Screenshot:
Image
Attachments
screenshot_20180702_210329.png
screenshot_20180702_210329.png (116.81 KiB) Viewed 1133 times
Testin' mines since 1989

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: mod to highlight when a player joins or leaves?

by AspireMint » Post

You can try this powerful csm: https://github.com/doyousketch2/friendly_chat
But might not work correctly on some servers that already has colored chat.

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: mod to highlight when a player joins or leaves?

by Krock » Post

That's IhrFussel's server with custom mods which aren't public. I don't know any mod which currently does this, but implementing it yourself is quite easy:

Solution for Minetest 5.0.0-dev or newer: Overwrite minetest.send_join_message in a new mod
Solution for Minetest 0.4.x (hacky): Edit the builtin code
Local solution for Minetest >= 0.4.16: Write or use a CSM that checks whether the chat line has the default join message format and colorize it locally.

Here you can find the documentation of "minetest.colorize", which makes colorizing messages very easy.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Thanks for these answers! I’ll look into them soon.
Testin' mines since 1989

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Krock wrote: Local solution for Minetest >= 0.4.16: Write or use a CSM that checks whether the chat line has the default join message format and colorize it locally..
But that wouldn't apply for all clients. Just my client. I'm running a server for my family and some of them are on phones so they can't install CSM's.
Testin' mines since 1989

User avatar
stormchaser3000
Member
Posts: 422
Joined: Sun Oct 06, 2013 21:02
GitHub: stormchaser3000

Re: mod to highlight when a player joins or leaves?

by stormchaser3000 » Post

Joseph13 wrote:
Krock wrote: Local solution for Minetest >= 0.4.16: Write or use a CSM that checks whether the chat line has the default join message format and colorize it locally..
But that wouldn't apply for all clients. Just my client. I'm running a server for my family and some of them are on phones so they can't install CSM's.
as far as i know it should be possible to install CSMs on android phones when using the official client. but just to be sure i will do some testing and then edit this post

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

stormchaser3000 wrote:
as far as i know it should be possible to install CSMs on android phones when using the official client. but just to be sure i will do some testing and then edit this post
But they are playing on iOS devices- so as I said CSM’s won’t work. Is there any way to take a CSM mod and put it on the server mods list? Or is that physically impossible?
Testin' mines since 1989

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: mod to highlight when a player joins or leaves?

by Krock » Post

Joseph13 wrote:
Krock wrote:Local solution for Minetest >= 0.4.16
But that wouldn't apply for all clients. Just my client.
Hence, local solution. Because it only applies to your client.
Joseph13 wrote:But they are playing on iOS devices- so as I said CSM’s won’t work. Is there any way to take a CSM mod and put it on the server mods list? Or is that physically impossible?
They should update to 0.4.16 or newer to make it work. Sending CSMs by the server is yet not possible (not even in 5.0.0-dev, surprise!), so consider using one of the other solutions by writing a SSM (regular mod).
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Krock wrote: by writing a SSM (regular mod).
I looked into doing it as a normal mod, tried this:
Image
but it gave me an error:
Image
I know I did this completely wrong but is it as simple as this code or is it much harder to make work properly?
Attachments
Captur1e.PNG1.PNG
Captur1e.PNG1.PNG (107.92 KiB) Viewed 1133 times
Capture.PNG
Capture.PNG (22.21 KiB) Viewed 1133 times
Testin' mines since 1989

User avatar
stormchaser3000
Member
Posts: 422
Joined: Sun Oct 06, 2013 21:02
GitHub: stormchaser3000

Re: mod to highlight when a player joins or leaves?

by stormchaser3000 » Post

Joseph13 wrote:
stormchaser3000 wrote:
as far as i know it should be possible to install CSMs on android phones when using the official client. but just to be sure i will do some testing and then edit this post
But they are playing on iOS devices- so as I said CSM’s won’t work. Is there any way to take a CSM mod and put it on the server mods list? Or is that physically impossible?
ah i see the problem. also i asked on #minetest on freenode and one of the developers said it is not possible to send CSMs to clients from the server yet. i am sorry to say but minetest is no officially supported on IOS because of the licensing restrictions on the apple app store which would prevent minetest from being put on that store because of the license minetest is licensed under (if i understand correctly). the versions of minetest on the IOS appstore are usually not legal because they break the terms of the LGPL 2.1 (which minetest is licensed under) by not releasing their modified versions of the minetest source code. I am not sure if these IOS clients will ever work with CSMs for 1) because of the restrictions placed on IOS users from apple and 2) because these IOS apps are unofficial and might not properly support CSMs anyway. i wish i could be of better help however i would wait a while to see if anyone else who knows more than me could help.

EDIT: previous edit deleted because i should read everything before posting

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

OK. I already knew about the licensing issues on iOS. And even if it ever did get licensed you couldn't access the file system like you can on android.
Testin' mines since 1989

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

I guess the main objective is to make a mod that will act very similar to that of IhrFussel's server. Green text, better join/leave message and maybe the time counter(although not really going for that.)
Maybe the owner of IhrFussel's server could PM me and share the details of the mod(maybe even the code? :) )
Testin' mines since 1989

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: mod to highlight when a player joins or leaves?

by ExeterDad » Post

Joseph... player_list is local to the builtin. So you can't see it with another mod. You need to make your own.
Right before the code posted above add:

Code: Select all

local player_list = {}
I'm at work and unable to test... but I bet it will work for you. But.... it won't override the existing builtin function unless you comment the builtin function out.

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

ExeterDad wrote:Joseph... player_list is local to the builtin. So you can't see it with another mod. You need to make your own.
Right before the code posted above add:

Code: Select all

local player_list = {}
I'm at work and unable to test... but I bet it will work for you. But.... it won't override the existing builtin function unless you comment the builtin function out.
I’ll try it! Thanks!
Testin' mines since 1989

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

I addd that line and it works - but Minetest still puts the old server messages as well. So when I join my sever it looks like:
Joseph joined the game.
Joseph joined the mod.
The second message being the modded one. I need to disable the old one and change the color of the text. Know how to do both?
Testin' mines since 1989

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: mod to highlight when a player joins or leaves?

by ExeterDad » Post

Joseph13 wrote:I addd that line and it works - but Minetest still puts the old server messages as well. So when I join my sever it looks like:
Joseph joined the game.
Joseph joined the mod.
The second message being the modded one. I need to disable the old one and change the color of the text. Know how to do both?
This is the hacky part mentioned earlier. You have to disable the code in the builtin file. Not the best way because you will lose your modification when you upgrade. But if you must....
Edit builtin/game/misc.lua
Find:

Code: Select all

core.register_on_joinplayer(function(player)
	local player_name = player:get_player_name()
	player_list[player_name] = player
	if not minetest.is_singleplayer() then
		core.chat_send_all("*** " .. player_name .. " joined the game.")
	end
end)

core.register_on_leaveplayer(function(player, timed_out)
	local player_name = player:get_player_name()
	player_list[player_name] = nil
	local announcement = "*** " ..  player_name .. " left the game."
	if timed_out then
		announcement = announcement .. " (timed out)"
	end
	core.chat_send_all(announcement)
end)
and add a multi line comment to one to stop it from loading.
The second one comments out the announcement, and removes the player from the list that's needed in connected players.

Code: Select all

--[[
core.register_on_joinplayer(function(player)
	local player_name = player:get_player_name()
	player_list[player_name] = player
	if not minetest.is_singleplayer() then
		core.chat_send_all("*** " .. player_name .. " joined the game.")
	end
end)
--]]
core.register_on_leaveplayer(function(player, timed_out)
	local player_name = player:get_player_name()
	player_list[player_name] = nil
--	local announcement = "*** " ..  player_name .. " left the game."
--	if timed_out then
--		announcement = announcement .. " (timed out)"
--	end
--	core.chat_send_all(announcement)
end)
Do not touch the

Code: Select all

local player_list = {}
that's above those two functions. It's needed by core.get_connected_players

Edited to fix my screw up.
Last edited by ExeterDad on Tue Jul 03, 2018 20:18, edited 2 times in total.

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Tysm!
Testin' mines since 1989

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Now to make the text green..
Testin' mines since 1989

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: mod to highlight when a player joins or leaves?

by ExeterDad » Post

Joseph13 wrote:Tysm!
Wait! Both need not be commented out. I'm editing now.

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Ok?
Testin' mines since 1989

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

But it will still show the “player left” messages won’t it?
Testin' mines since 1989

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: mod to highlight when a player joins or leaves?

by ExeterDad » Post

Joseph13 wrote:But it will still show the “player left” messages won’t it?
No the message part is commented out, but it will still remove their name from the list which must happen.

To change the color to a green, change the needed messages to something like this:

Code: Select all

core.chat_send_all(core.colorize("#2aff00", "*** " .. player_name .. " joined the game100."))
core.chat_send_all(core.colorize("#2aff00", announcement))

In whatever code you posted earlier.

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Alright! So I can make the “join”messages green and the “leave” messages red or grey!
Testin' mines since 1989

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: mod to highlight when a player joins or leaves?

by ExeterDad » Post

You can change the color to anything. What's used in my example is hex colors.
https://www.w3schools.com/colors/colors_picker.asp

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: mod to highlight when a player joins or leaves?

by Joseph16 » Post

Very good!
Testin' mines since 1989

Post Reply

Who is online

Users browsing this forum: Bing [Bot], TPH and 7 guests