making a music mod

idfk101
New member
 
Posts: 3
Joined: Wed Oct 28, 2015 18:41
In-game: bitchidfk

making a music mod

by idfk101 » Wed Oct 28, 2015 18:48

so i changed a bit of the music code for the mesecon noteblock mod and i was wondering if someone had some advice on how to get the music to stop playing when hit again. i want it to play from a list of songs i changed to the directory so it is like an in game sort of pandora playlist i guess. And if theres also a way to maybe set somesort of global variable to be turned off if another noteblock is placed and used while that one is playing
 

User avatar
qwertymine3
Member
 
Posts: 194
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: making a music mod

by qwertymine3 » Wed Oct 28, 2015 23:31

If you only want one block playing (or positionless music) at any given time, AFAIK this shouldn't be too hard.
When you play a sound with minetest.sound_play it should return a 'handle' (a reference to the sound). You can put this in a global variable (just create a variable outside a function) and test that the global is not nil to know if the music is playing. If it is you can then use minetest.sound_stop to stop the music and then set the global to nil.

You may also have to check the song hasn't finished using some form of timer or check against os.clock (store the start time in a global), as I don't think the handle is automatically deleted when the song ends, but I may be wrong.

I haven't tried this, but hopefully this is correct.
Avatar by :devnko-ennekappao:
 

User avatar
kaadmy
Member
 
Posts: 627
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD

Re: making a music mod

by kaadmy » Wed Oct 28, 2015 23:47

Never paint white stripes on roads near Zebra crossings.
 

idfk101
New member
 
Posts: 3
Joined: Wed Oct 28, 2015 18:41
In-game: bitchidfk

Re: making a music mod

by idfk101 » Thu Oct 29, 2015 16:19

so i took your music mod folder lol but it doesnt play anything at all? when i place the block it automatically says disabled by server
 

User avatar
kaadmy
Member
 
Posts: 627
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD

Re: making a music mod

by kaadmy » Thu Oct 29, 2015 18:13

You need the configuration setting music_enable = true in your minetest.conf, or the file that the config is read from.
Never paint white stripes on roads near Zebra crossings.
 

idfk101
New member
 
Posts: 3
Joined: Wed Oct 28, 2015 18:41
In-game: bitchidfk

Re: making a music mod

by idfk101 » Fri Oct 30, 2015 03:21

Since you seem to know what youre doing lol how difficult would it be to add some sort of function to play another song after the first ends because right now its the 28 second timer but if i want it to play the next song right after each song ends is that possible? Like i said i sorta want an in game pandora if you will that when you place it it will actually just randomize the music from the sounds folder but im veryyyyy new to lua.
 


Return to Modding Discussion

Who is online

Users browsing this forum: Google [Bot] and 19 guests

cron