[Demo Mod]Sound Block Example

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46
Location: Nürtingen, Germany

[Demo Mod]Sound Block Example

by Jeija » Mon Mar 26, 2012 17:50

Hello!
I made a mod example which plays a demo song (http://www.newgrounds.com/audio/listen/426165)
when the musicblock is punched. It turns off when punched again.
(I had to use a global variable for this because you can't save values in the node itself, can you?

As there is no crafting recipe, get the music block by writing
Code: Select all
/giveme soundblocks:musicblock


Future: Do you have more Creative Commons music that I should add? You can make it yourself or suggest other's artwork! If there is enough I could make a jukebox with disks like in minecraft.
This should also be mesecon controlled.
If there is a dev out there who wants to create note blocks you may wanna use this code.

Download:
Version 0.1 as .zip (3.5 MB)


Source Code:
Code: Select all
soundblocks_music={} --This is needed because you cannot save the handle of the sound in param2 of the node

minetest.register_node("soundblocks:musicblock", {
    description = "Music Block",
    tile_images = {"default_wood.png"},
    groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
})


--Some functions that you need to save the handle in soundblocks_music:
function soundblocks_get_handle(pos)
    local i=0
    while soundblocks_music[i]~=nil do
        if soundblocks_music[i].pos.x==pos.x and soundblocks_music[i].pos.y==pos.y and soundblocks_music[i].pos.z==pos.z then
            return soundblocks_music[i].handle
        end
        i=i+1
    end
    return 0
end

function soundblocks_set_handle(pos, handle)
    local i=0
    while soundblocks_music[i]~=nil do
        if soundblocks_music[i].pos.x==pos.x and soundblocks_music[i].pos.y==pos.y and soundblocks_music[i].pos.z==pos.z then
            soundblocks_music[i].handle=handle
            return
        end
        i=i+1
    end
    soundblocks_music[i]={}
    soundblocks_music[i].pos=pos
    soundblocks_music[i].handle=handle
end


--This is the actual code that plays the sound:
minetest.register_on_punchnode(function(pos, node, puncher)
    if node.name=="soundblocks:musicblock" then
        if soundblocks_get_handle(pos)==0 then
            local handle=0
            handle = minetest.sound_play("soundblocks_music", { --name of sound, file name extension is .ogg
            pos = pos, --pos where sound comes from
            gain = 1.0,
            max_hear_distance = 32,}) --sound gets lower the farer you get away from the jukebox
            soundblocks_set_handle(pos, handle)
        else
            minetest.sound_stop(soundblocks_get_handle(pos))
            soundblocks_set_handle(pos, 0)
        end
    end
end)
Last edited by Jeija on Tue Mar 27, 2012 14:52, edited 1 time in total.
Redstone for minetest: Mesecons (mesecons.net)
 

Gilli
Member
 
Posts: 20
Joined: Sat Mar 17, 2012 21:15

by Gilli » Mon Mar 26, 2012 18:57

Nice Mod.
Last edited by Gilli on Mon Mar 26, 2012 19:20, edited 1 time in total.
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46
Location: Nürtingen, Germany

by Jeija » Mon Mar 26, 2012 18:58

you have to get the newest minetest version from git!
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
sfan5
Moderator
 
Posts: 3800
Joined: Wed Aug 24, 2011 09:44
Location: Germany
GitHub: sfan5
IRC: sfan5

by sfan5 » Mon Mar 26, 2012 19:04

Nice Mod!
Mods: Mesecons | WorldEdit | Nuke & Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Tue Mar 27, 2012 00:58

[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Tue Mar 27, 2012 01:13

chilling to some tunes in minetest
Image
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Tue Mar 27, 2012 01:16

by the way lag spike on high chords :P
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

User avatar
jordan4ibanez
Member
 
Posts: 1895
Joined: Tue Sep 27, 2011 18:44
Location: Rhode Island, USA
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Tue Mar 27, 2012 02:53

very very nice
I've been gone for a long time
 

celeron55
Administrator
 
Posts: 452
Joined: Tue Apr 19, 2011 10:10
GitHub: celeron55
IRC: celeron55

by celeron55 » Tue Mar 27, 2012 05:30

If you make a demo mod, you should probably post the source code too so that people can easily look at it; either in the post if it isn't huge or in a pastebin or github otherwise.

For example I would like to see this, but won't bother opening a .zip.
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46
Location: Nürtingen, Germany

by Jeija » Tue Mar 27, 2012 14:53

You're right celeron, I posted the code in the first post.
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
Death Dealer
Member
 
Posts: 1379
Joined: Wed Feb 15, 2012 18:46
Location: Limbo

by Death Dealer » Tue Mar 27, 2012 14:57

Awesome some kind of sound:D it would be nice to have menu music to tho.
Keep calm and code python^_^
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31
Location: California, USA

by randomproof » Tue Mar 27, 2012 15:15

If you add
metadata_name = "generic",
to your node def you can save data to the node. Though, I don't think you can save the handle from sound_play or you could, but it would lose its meaning if the server is reset.
 

User avatar
Jordach
Member
 
Posts: 4523
Joined: Mon Oct 03, 2011 17:58
Location: Blender Scene
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Tue Mar 27, 2012 15:16

@Jeija: I have some free music on my Newgrounds free of charge, or use some I have posted here before.

EG: http://www.mediafire.com/?o96iy9b9ld9bqtf

NEWGROUNDS URL: jordach.newgrounds.com
Last edited by Jordach on Tue Mar 27, 2012 15:19, edited 1 time in total.
viewtopic.php?f=10&t=19056 Solar Plains Dev Server
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46
Location: Nürtingen, Germany

by Jeija » Tue Mar 27, 2012 15:56

I think minetest needs its own music style, just like minecraft. I like hang music:
http://www.youtube.com/watch?v=wpJu2xI8L6E

What do you think about that, do you have other free hang music?
What music genre do you suggest (I don't mean things like rock or hiphop, minetest music should be calm)?
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
Death Dealer
Member
 
Posts: 1379
Joined: Wed Feb 15, 2012 18:46
Location: Limbo

by Death Dealer » Tue Mar 27, 2012 15:58

Jeija wrote:I think minetest needs its own music style, just like minecraft. I like hang music:
http://www.youtube.com/watch?v=wpJu2xI8L6E

What do you think about that, do you have other free hang music?
What music genre do you suggest (I don't mean things like rock or hiphop, minetest music should be calm)?

Dubstep:D
Keep calm and code python^_^
 

User avatar
Jordach
Member
 
Posts: 4523
Joined: Mon Oct 03, 2011 17:58
Location: Blender Scene
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Tue Mar 27, 2012 16:08

Im busy in my DAW Basement, I think its time to unleash some nosie!
viewtopic.php?f=10&t=19056 Solar Plains Dev Server
 

User avatar
RAPHAEL
Member
 
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Tue Mar 27, 2012 16:18

Well I just tested this mod and it mostly works. It will start playing but very loudly. Also hitting it doesn't stop it from playing. However still nice. Now we need a soundpack made for minetest. Multiple soundpacks.
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
 

User avatar
Jordach
Member
 
Posts: 4523
Joined: Mon Oct 03, 2011 17:58
Location: Blender Scene
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Tue Mar 27, 2012 16:18

Just made something with a little electro house synths. Very questionable, such as finding mese.

Sounds are WTFPL.

http://www.mediafire.com/download.php?os9oikh5lcn6971
Last edited by Jordach on Tue Mar 27, 2012 16:18, edited 1 time in total.
viewtopic.php?f=10&t=19056 Solar Plains Dev Server
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46
Location: Nürtingen, Germany

by Jeija » Tue Mar 27, 2012 16:28

Also hitting it doesn't stop it from playing.

It should...?!?
Redstone for minetest: Mesecons (mesecons.net)
 

User avatar
RAPHAEL
Member
 
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Tue Mar 27, 2012 19:34

Jeija wrote:
Also hitting it doesn't stop it from playing.

It should...?!?

On local tests with latest dev compiled.. nope doesn't stop playing on hit lol. Also even removing block doesn't make it stop playing.
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Tue Mar 27, 2012 19:47

i can stop the playing
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

User avatar
RAPHAEL
Member
 
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Tue Mar 27, 2012 20:10

sdzen wrote:i can stop the playing

Well then I'm unsure what differs between us but something does apparently lol.
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
 

User avatar
sdzen
Member
 
Posts: 1170
Joined: Fri Aug 05, 2011 22:33
Location: Paradise (your not allowed)

by sdzen » Tue Mar 27, 2012 20:11

well i got that error once when i was running 8 soundblocks at once :P 7's fine but at 8 its oh no!!!
[h]Zen S.D.[/h] The next generation of tranquility!
malheureusement mon français n'est pas bon :<
Owner of the Zelo's
In game name: MuadTralk, spdtainted, sdzen, sd zen, sdzeno
 

User avatar
Death Dealer
Member
 
Posts: 1379
Joined: Wed Feb 15, 2012 18:46
Location: Limbo

by Death Dealer » Tue Mar 27, 2012 20:47

your link is broken.
Keep calm and code python^_^
 

User avatar
Jeija
Member
 
Posts: 686
Joined: Fri Dec 23, 2011 21:46
Location: Nürtingen, Germany

by Jeija » Wed Mar 28, 2012 15:01

Death Dealer wrote:your link is broken.

Download link? No
Link to newgrounds? No
Redstone for minetest: Mesecons (mesecons.net)
 

Next

Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 5 guests