From caf99c9488da6622209f561564476334cc01bc57 Mon Sep 17 00:00:00 2001 From: LeMagnesium Date: Tue, 9 Jun 2015 22:11:21 +0200 Subject: [PATCH] Added jukebox's music notes from @jordan4ibanez 's redo --- mods/jukebox/init.lua | 53 ++++++++++++++++++++++++- mods/jukebox/textures/jukebox_note.png | Bin 0 -> 1203 bytes 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 mods/jukebox/textures/jukebox_note.png diff --git a/mods/jukebox/init.lua b/mods/jukebox/init.lua index 6d0061f8..693fea0a 100755 --- a/mods/jukebox/init.lua +++ b/mods/jukebox/init.lua @@ -1,5 +1,51 @@ jukebox = {} jukebox.tracks = {} +jukebox.particles = {} + +function make_particles(pos) + -- create particles table + if jukebox.particles[pos.x] == nil then + jukebox.particles[pos.x] = {} + end + if jukebox.particles[pos.x][pos.y] == nil then + jukebox.particles[pos.x][pos.y] = {} + end + if jukebox.particles[pos.x][pos.y][pos.z] == nil then + jukebox.particles[pos.x][pos.y][pos.z] = {} + end + --create particle spawner + local particle = minetest.add_particlespawner({ + amount = 1, + time = 0, + minpos = {x=pos.x, y=pos.y, z=pos.z}, + maxpos = {x=pos.x, y=pos.y, z=pos.z}, + minvel = {x=0, y=2, z=0}, + maxvel = {x=0, y=2, z=0}, + minacc = {x=0, y=0, z=0}, + maxacc = {x=0, y=0, z=0}, + minexptime = 1, + maxexptime = 1, + minsize = 5, + maxsize = 5, + collisiondetection = false, + vertical = true, + texture = "jukebox_note.png", + }) + --add the particle spawner to the global table + jukebox.particles[pos.x][pos.y][pos.z] = particle +end + +function free_particles(pos) + --remove particle spawner + if jukebox.particles[pos.x] ~= nil then + if jukebox.particles[pos.x][pos.y] ~= nil then + if jukebox.particles[pos.x][pos.y][pos.z] ~= nil then + minetest.delete_particlespawner(jukebox.particles[pos.x][pos.y][pos.z]) + jukebox.particles[pos.x][pos.y][pos.z] = nil + end + end + end +end minetest.register_node("jukebox:box", { description = "Jukebox", @@ -41,14 +87,19 @@ minetest.register_node("jukebox:box", { gain = soundset.get_gain(clicker:get_player_name(), "music"), max_hear_distance = 25, + loop = 1, })) + make_particles(pos) else if not inv:is_empty("main") then local drop_pos = minetest.find_node_near(pos, 1, "air") if drop_pos == nil then drop_pos = {x=pos.x, y=pos.y+1,z=pos.z} end minetest.add_item(drop_pos, inv:get_stack("main",1)) inv:remove_item("main", inv:get_stack("main",1)) - if meta:get_string("now_playing") then minetest.sound_stop(meta:get_string("now_playing")) end + if meta:get_string("now_playing") then + minetest.sound_stop(meta:get_string("now_playing")) + free_particles(pos) + end end end end, diff --git a/mods/jukebox/textures/jukebox_note.png b/mods/jukebox/textures/jukebox_note.png new file mode 100644 index 0000000000000000000000000000000000000000..36b62b7d3b22521da8c84c04789218ef62d0f8af GIT binary patch literal 1203 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~8w(4U#jmP)sX!sg64!_l=ltB<)VvY~=c3falGGH1 z^30M91$R&1fbd2>aRvq!X-^l&5DP&@0haf_fqEzdj99e)$0CMH2%CPO$B6@Abu2j4 z5^D%n?Zj#Zt7F1y1POwp1~4#C90ss-KvL8pM-s&@7_qw1y|UK$<;W L{an^LB{Ts5?!Pj6 literal 0 HcmV?d00001