[Mod] Limit chat by distance [0.1.2] [shout]

Post Reply
User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

[Mod] Limit chat by distance [0.1.2] [shout]

by srifqi » Post

Hi!
This mod limit your message by distance so that your message only sent to player within distance boundary.

Features:
  • Limit who can hear your message by distance given in shout.DISTANCE parameter
  • A chat command /sh to broadcast your message (pay 1 stick by default, can be changed in shout.PAYMENT parameter)
See README

Github: https://github.com/srifqi/shout

Downloads: License: CC 1.0 Universal
Dependencies: (none)

No screenshot for now!
Last edited by srifqi on Wed Jun 24, 2015 07:54, edited 3 times in total.
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [Mod] Limit chat by distance [0.1] [shout]

by rubenwardy » Post

it might be better to do:

Code: Select all

math.sqrt(x * x + y * y + z * z)
https://github.com/srifqi/shout/blob/ma ... it.lua#L20

It's less square rooting (but maybe less readable, Idk) probably not worth optimising :P

chatplus can already do this, but it comes with the bloat of ignoring and inboxes, so it's good to have a standalone version (as in, doesn't provide anything else other than distance limiting). /sh having a cost, a stick, is quite interesting as a game play mechanic.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Diamond knight
Member
Posts: 475
Joined: Sun Apr 19, 2015 19:50
GitHub: Diamondknight
In-game: Ferrumprinceps
Location: Chilling in Constantinople
Contact:

Re: [Mod] Limit chat by distance [0.1] [shout]

by Diamond knight » Post

sticks are kinda a little, say cheap, maybe something cheap but not almost unlimited brodcasts kinda cheap

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

Re: [Mod] Limit chat by distance [0.1] [shout]

by srifqi » Post

rubenwardy wrote:it might be better to do:

Code: Select all

math.sqrt(x * x + y * y + z * z)
https://github.com/srifqi/shout/blob/ma ... it.lua#L20

It's less square rooting (but maybe less readable, Idk) probably not worth optimising :P
I was just copying from Minetest built-in lua. Never thought about this optimization, I already know that formula, just forgot when writing the code. :P
rubenwardy wrote:chatplus can already do this, but it comes with the bloat of ignoring and inboxes, so it's good to have a standalone version (as in, doesn't provide anything else other than distance limiting). /sh having a cost, a stick, is quite interesting as a game play mechanic.
Never heard about your mod, sorry. :D
Diamond knight wrote:sticks are kinda a little, say cheap, maybe something cheap but not almost unlimited brodcasts kinda cheap
Maybe, I should add parameter for this, so that you can easily change what we should pay.

Also, should I add a configuration per world?
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

UPDATE: [Mod] Limit chat by distance [0.1.1] [shout]

by srifqi » Post

UPDATE 0.1.1! (Payment Update)
Changes:
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

prestidigitator
Member
Posts: 647
Joined: Thu Feb 21, 2013 23:54

Re: [Mod] Limit chat by distance [0.1] [shout]

by prestidigitator » Post

rubenwardy wrote:It's less square rooting (but maybe less readable, Idk) probably not worth optimising :P
Even better is to compare squares of distances and not need square roots at all. :-P

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

Re: [Mod] Limit chat by distance [0.1] [shout]

by srifqi » Post

prestidigitator wrote:
rubenwardy wrote:It's less square rooting (but maybe less readable, Idk) probably not worth optimising :P
Even better is to compare squares of distances and not need square roots at all. :-P
Ah, Phytagoras Theorem!
Phytagoras Theorem wrote:

Code: Select all

c * c = a * a + b * b
How can I forget that? Thanks prestidigitator. Will be avaiable in next update.
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
lag01
Member
Posts: 321
Joined: Sun Mar 16, 2014 03:41
GitHub: AndrejIT
IRC: lag01
In-game: lag
Contact:

Re: [Mod] Limit chat by distance [0.1.1] [shout]

by lag01 » Post

Minetest have built-in helper: vector.distance(senderpos, recieverpos)

Good idea for taking payment for shouting, i must add it to my chat mod too!

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

Re: [Mod] Limit chat by distance [0.1.1] [shout]

by srifqi » Post

lag01 wrote:Minetest have built-in helper: vector.distance(senderpos, recieverpos)
Do you mean this?

Code: Select all

function vector.distance(a, b)
	local x = a.x - b.x
	local y = a.y - b.y
	local z = a.z - b.z
	return math.hypot(x, math.hypot(y, z))
end
You know? We (me, rubenwardy, and prestidigitator) are doing optimisation. So, rather than do math.hypot several times, we compare the distance "squared". So, we save a little bit time.
lag01 wrote:Good idea for taking payment for shouting, i must add it to my chat mod too!
Yay!
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

User avatar
srifqi
Member
Posts: 570
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi
Location: Indonesia

UPDATE: [Mod] Limit chat by distance [0.1.2] [shout]

by srifqi » Post

UPDATE 0.1.2! (Performance Update)
Change:
  • Use Phytagoras Theorem c^2 = a^2 + b^2
Saya dari Indonesia! · Terjemahkan Minetest! · my mods · My nickname in IPA: /es.rif.qi/

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests