Page 1 of 1

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

PostPosted: Thu Jun 11, 2015 06:58
by srifqi
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!

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

PostPosted: Thu Jun 11, 2015 07:37
by rubenwardy
it might be better to do:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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.

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

PostPosted: Thu Jun 11, 2015 16:28
by Diamond knight
sticks are kinda a little, say cheap, maybe something cheap but not almost unlimited brodcasts kinda cheap

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

PostPosted: Thu Jun 11, 2015 17:19
by srifqi
rubenwardy wrote:it might be better to do:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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?

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

PostPosted: Sat Jun 13, 2015 00:10
by srifqi
UPDATE 0.1.1! (Payment Update)
Changes:

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

PostPosted: Sat Jun 13, 2015 02:20
by prestidigitator
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

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

PostPosted: Sun Jun 14, 2015 06:22
by srifqi
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:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
c * c = a * a + b * b


How can I forget that? Thanks prestidigitator. Will be avaiable in next update.

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

PostPosted: Sat Jun 20, 2015 10:11
by lag01
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!

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

PostPosted: Wed Jun 24, 2015 07:30
by srifqi
lag01 wrote:Minetest have built-in helper: vector.distance(senderpos, recieverpos)

Do you mean this?
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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!

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

PostPosted: Wed Jun 24, 2015 07:54
by srifqi
UPDATE 0.1.2! (Performance Update)
Change:
  • Use Phytagoras Theorem c^2 = a^2 + b^2