mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-12-25 02:00:37 +01:00
Part 2 of jukebox rewrite
- Added soundset as a dependency of jukebox - Rewritten disc code - Added new method to register discs - Moved old texture to new format (jukebox_disc_%d.png) - Used @ObaniGemini 's event sound for disc number 1 : Event song - Solves #72
This commit is contained in:
parent
cfdbe71466
commit
29578792a0
@ -1 +1,2 @@
|
||||
default
|
||||
soundset
|
||||
|
@ -1,6 +1,5 @@
|
||||
local discs = {
|
||||
[1] = "track_1",
|
||||
}
|
||||
jukebox = {}
|
||||
jukebox.tracks = {}
|
||||
|
||||
minetest.register_node("jukebox:box", {
|
||||
description = "Jukebox",
|
||||
@ -25,13 +24,30 @@ minetest.register_node("jukebox:box", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if not clicker then return end
|
||||
if minetest.get_item_group(clicker:get_wielded_item():get_name(), "disc") == 1 then
|
||||
-- Rewrite this
|
||||
if minetest.get_item_group(
|
||||
clicker:get_wielded_item():get_name(), "disc") == 1
|
||||
and inv:is_empty("main") then
|
||||
local discname = clicker:get_wielded_item():get_name()
|
||||
local tracknum = tonumber(discname:split("_")[2])
|
||||
local track = jukebox.tracks[tracknum]
|
||||
|
||||
if not track then
|
||||
minetest.chat_send_player(clicker:get_player_name(), "ERROR: Cannot find track number " .. (tracknum or "<nil>") .. "...")
|
||||
return
|
||||
end
|
||||
|
||||
inv:add_item("main", itemstack:take_item())
|
||||
meta:set_string("now_playing", minetest.sound_play(track, {
|
||||
gain = soundset.get_gain(clicker:get_player_name(),
|
||||
"music"),
|
||||
max_hear_distance = 25,
|
||||
}))
|
||||
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
|
||||
end
|
||||
end
|
||||
@ -53,15 +69,6 @@ minetest.register_node("jukebox:box", {
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craftitem("jukebox:disc", {
|
||||
description = "Music Disc",
|
||||
inventory_image = "jukebox_disc.png",
|
||||
liquids_pointable = false,
|
||||
stack_max = 1
|
||||
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "jukebox:box",
|
||||
recipe = {
|
||||
@ -71,11 +78,39 @@ minetest.register_craft({
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
local function register_disc(trackname, trackdesc, craftitem)
|
||||
-- Vital information
|
||||
if not trackname then
|
||||
minetest.log("error", "[jukebox] Failed registering disc")
|
||||
end
|
||||
-- Default values for the other ones
|
||||
trackdesc = trackdesc or "???"
|
||||
craftitem = craftitem or "group:wood"
|
||||
|
||||
local id = #jukebox.tracks
|
||||
|
||||
minetest.register_craftitem("jukebox:disc_" .. id, {
|
||||
description = "Music Disc : " .. trackdesc,
|
||||
inventory_image = "jukebox_disc_" .. id .. ".png",
|
||||
liquids_pointable = false,
|
||||
stack_max = 1,
|
||||
groups = {disc = 1},
|
||||
})
|
||||
|
||||
jukebox.tracks[id] = trackname
|
||||
|
||||
minetest.register_craft({
|
||||
output = "jukebox:disc",
|
||||
output = "jukebox:disc_" .. id,
|
||||
recipe = {
|
||||
{"", "default:coal_lump", "", },
|
||||
{"default:coal_lump", "default:gold_lump", "default:coal_lump", },
|
||||
{"", "default:coal_lump", "", }
|
||||
{"", "default:coal_lump", ""},
|
||||
{"default:coal_lump", craftitem,"default:coal_lump"},
|
||||
{"","default:coal_lump",""}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.log("action", "[jukebox] Registrered disc " .. trackdesc ..
|
||||
", id = " .. id .. " for file " .. trackname)
|
||||
end
|
||||
|
||||
register_disc("jukebox_event.ogg", "Event song", "default:stone")
|
||||
|
BIN
mods/jukebox/sounds/jukebox_event.ogg
Executable file
BIN
mods/jukebox/sounds/jukebox_event.ogg
Executable file
Binary file not shown.
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 457 B |
Loading…
Reference in New Issue
Block a user