Playing sounds in a room

20 views
Skip to first unread message

Antonio Cascales

unread,
Oct 20, 2020, 11:56:37 AM10/20/20
to moo-...@googlegroups.com
Hi again, everybody:


I come to consult another question.


I am trying to reproduce a sound in a room, and I am finding that it is
not possible.


I have defined two functions in this regard. send_sound () in $ player
and send_sound () in $ room. So that I can send sounds to the player or
the room respectively as I am interested.


The player's send_sound () function roughly does the following:


player: tell ("!! SOUND (", @args, ")");


And the function send_sound () of the room, the following:


for p in (connected_players ())

if (p.location == this.location)

p: send_sound ();

endif

endfor


However, the player's one works, and the room's doesn't. Especially when
I intend to execute the latter from an object or another room.


Can anyone give me a hint why this is happening or how to fix it?


Thank you very much for your help.


Michael Munson

unread,
Oct 20, 2020, 11:58:58 AM10/20/20
to Antonio Cascales, moo-...@googlegroups.com
That’s definitely the wrong way to do that. Instead, do this:

for object in (this.contents)
if (is_player(object))
object:tell(....);
endif
end for

--
You received this message because you are subscribed to the Google Groups "MOO Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to MOO-talk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/MOO-talk/d1f8d055-5240-8571-ed85-e844e1d0d82c%40gmail.com.

Michael Munson

unread,
Oct 20, 2020, 12:00:05 PM10/20/20
to Antonio Cascales, moo-...@googlegroups.com

And put that verb on a room parent, that way if you send a sound to a room it does everyone in the room. But it’s not much different than verbs already available on $room to be honest.

Steven Owens

unread,
Oct 20, 2020, 1:10:47 PM10/20/20
to Michael Munson, Antonio Cascales, MOO Talk
First, what core are you working with? If it's lambdacore or
something similar, you already have the announce verbs:

$room:announce (@text) => broadcasts to all except player
$room:announce_all (@text) => broadcasts to all
$room:announce_all_but (objects,@text) => broadcasts to all except
those in objects

These verbs basically loop through room.contents() and call
object:tell(@args) on each object. Note that this means looping
through all objects, not just player objects. All objects in MOO have
a :tell() verb, #1:tell() just calls through to object:notify(), which
in turn, if the object is a player object, calls the built-in notify()
which sends the string to the telnet connection connected to the
player.

Second, be more specific and detailed when you say that the room
version doesn't work. What happens when you try?

Offhand, one thought is to check the permissions on your verbs. See
the lambdamoo programmer's manual:

http://www.moo-cows.com/docs/manuals/ProgrammersManual.html

"The execute bit determines whether or not the verb can be invoked
from within a MOO program (as opposed to from the command line, like
the `put' verb on containers). If the `x' bit is not set, the verb
cannot be called from inside a program. The `x' bit is usually set."

By the way, some years ago I wrote up a very rough draft of a
programmer's tutorial for LambdaMOO, you may find it somewhat useful:

http://www.darksleep.com/notablog/articles/LambdaMOO_Programming_Tutorial

Steve (aka puff @ lambdamoo)
> To view this discussion on the web visit https://groups.google.com/d/msgid/MOO-talk/CAE3pSMdYo1fQ%2BAifby048rNYud5Ucc%3DpTJmykZCC43aoRnv1OA%40mail.gmail.com.



--
Steven J. Owens
steven...@gmail.com
pu...@darksleep.com
412-401-8060

Antonio Cascales

unread,
Oct 21, 2020, 9:06:57 PM10/21/20
to moo-...@googlegroups.com

Hello Michael:


   Thank you very much for the help.


   It is true. This is a more suitable way of checking the existing players in the room, and therefore getting the sound to them.


   What I don't understand is why it works now, and not before. JeJe.


Thanks again. Greetings.

Antonio Cascales

unread,
Oct 21, 2020, 9:06:57 PM10/21/20
to moo-...@googlegroups.com
Hi Steven:


   I use Lambdamoo 1.8.1.


   When I said that the verb send_sound () did not work in the room, I
meant that no sound was heard.


Thanks for the tips and links. I'll take a look at them.


Greetings.

Steven Owens

unread,
Oct 22, 2020, 12:01:24 PM10/22/20
to Antonio Cascales, MOO Talk
On Wed, Oct 21, 2020 at 9:06 PM Antonio Cascales
<antonio....@gmail.com> wrote:
> I use Lambdamoo 1.8.1.
>
> When I said that the verb send_sound () did not work in the room, I
> meant that no sound was heard.

But you didn't get any errors?

> Thanks for the tips and links. I'll take a look at them.

Good plan.

Also note, when I said that the #1:tell() verb calls object:notify()
which calls built-in function notify(), I implied but didn't
explicitly state: if the object is not a player object, and hence
has no telnet connection associated with it, then nothing happens.

Steve
> To view this discussion on the web visit https://groups.google.com/d/msgid/MOO-talk/e2ffbb39-838e-6c4a-41b3-fb8b84b989f7%40gmail.com.
Reply all
Reply to author
Forward
0 new messages