ID:2269108
 
(See the best response by Kaiochao.)
My problem is this:
I'm trying to make a jukebox and for the moment this is what I have
obj/jukebox
var/list
sounds = list("def1" = 'def1.ogg', "def2" = 'def.ogg')
verb/Playsound()
set src in oview(1)
var/Sound = input("Which one?") in sounds
usr << sounds[Sound]

It works fine, but I've made two different icons for when it's off and when it's on.
And I do not know how to add them
if anyone knows how to add them, I would appreciate it
Best response
If you have different icon files, then changing the icon is a matter of setting the "icon" var of the jukebox inside the verb. Usually it would be an icon state within the same icon file, though... that would be the "icon_state" var.
obj/jukebox
var/list
sounds = list("def1" = 'def1.ogg', "def2" = 'def.ogg')
verb/Playsound()
set src in oview(1)
var/Sound = input("Which one?") in sounds
usr << sounds[Sound]
icon = 'jukebox on.dmi' // if it's a separate icon file
icon_state = "on" // if it's a state in the same icon file

The difficult part is turning it off once the sound ends. DM doesn't provide a way to get the duration of a sound file... One thing I've done is to specify the durations of the sounds in some way, and checking them manually. Or, you could avoid the problem by having it play on loop until turned off.
Thanks for help me.
But now i have other issue with the same code.
When def1 it's changed to def2 they sound at the same time.
i would like to make def1 stop playing when def2 is selected to play but i don't know how to do it.

PD: i'm not very experienced with Dream Maker
usr<<sound(null)

Use that before you use you play then next song
^