forked from Mineclonia/Mineclonia
Merge branch 'master' into master
This commit is contained in:
commit
972237a474
|
@ -149,7 +149,7 @@ These groups are used mostly for informational purposes
|
||||||
* `trapdoor=2`: Open trapdoor
|
* `trapdoor=2`: Open trapdoor
|
||||||
* `glass=1`: Glass (full cubes only)
|
* `glass=1`: Glass (full cubes only)
|
||||||
* `rail=1`: Rail
|
* `rail=1`: Rail
|
||||||
* `music_record`: Music Disc (rating is track ID)
|
* `music_record=1`: Music Disc
|
||||||
* `tnt=1`: Block is TNT
|
* `tnt=1`: Block is TNT
|
||||||
* `boat=1`: Boat
|
* `boat=1`: Boat
|
||||||
* `minecart=1`: Minecart
|
* `minecart=1`: Minecart
|
||||||
|
|
|
@ -207,6 +207,10 @@ end
|
||||||
function mcl_autogroup.can_harvest(nodename, toolname)
|
function mcl_autogroup.can_harvest(nodename, toolname)
|
||||||
local ndef = minetest.registered_nodes[nodename]
|
local ndef = minetest.registered_nodes[nodename]
|
||||||
|
|
||||||
|
if not ndef then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if minetest.get_item_group(nodename, "dig_immediate") >= 2 then
|
if minetest.get_item_group(nodename, "dig_immediate") >= 2 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
# mcl_jukebox
|
||||||
|
|
||||||
|
## mcl_jukebox.register_record(title, author, identifier, image, sound)
|
||||||
|
|
||||||
|
* title: title of the track
|
||||||
|
* author: author of the track
|
||||||
|
* identifier: short string used in the item registration
|
||||||
|
* image: the texture of the track
|
||||||
|
* sound: sound file of the track
|
||||||
|
|
||||||
|
## mcl_jukebox.registered_records
|
||||||
|
|
||||||
|
Table indexed by item name containing:
|
||||||
|
* title: title of the track
|
||||||
|
* author: author of the track
|
||||||
|
* identifier: short string used in the item registration
|
||||||
|
* image: the texture of the track
|
||||||
|
* sound: sound file of the track
|
|
@ -1,5 +1,8 @@
|
||||||
local S = minetest.get_translator("mcl_jukebox")
|
local S = minetest.get_translator("mcl_jukebox")
|
||||||
|
|
||||||
|
mcl_jukebox = {}
|
||||||
|
mcl_jukebox.registered_records = {}
|
||||||
|
|
||||||
-- Player name-indexed table containing the currently heard track
|
-- Player name-indexed table containing the currently heard track
|
||||||
local active_tracks = {}
|
local active_tracks = {}
|
||||||
|
|
||||||
|
@ -10,47 +13,30 @@ local active_huds = {}
|
||||||
-- Used to make sure that minetest.after only applies to the latest HUD change event
|
-- Used to make sure that minetest.after only applies to the latest HUD change event
|
||||||
local hud_sequence_numbers = {}
|
local hud_sequence_numbers = {}
|
||||||
|
|
||||||
-- List of music
|
function mcl_jukebox.register_record(title, author, identifier, image, sound)
|
||||||
local recorddata = {
|
mcl_jukebox.registered_records["mcl_jukebox:record_"..identifier] = {title, author, identifier, image, sound}
|
||||||
-- { title, author, identifier }
|
local entryname = S("Music Disc")
|
||||||
{ "The Evil Sister (Jordach's Mix)", "SoundHelix", "13" } ,
|
local longdesc = S("A music disc holds a single music track which can be used in a jukebox to play music.")
|
||||||
{ "The Energetic Rat (Jordach's Mix)", "SoundHelix", "wait" },
|
local usagehelp = S("Place a music disc into an empty jukebox to play the music. Use the jukebox again to retrieve the music disc. The music can only be heard by you, not by other players.")
|
||||||
{ "Eastern Feeling", "Jordach", "blocks"},
|
minetest.register_craftitem(":mcl_jukebox:record_"..identifier, {
|
||||||
{ "Minetest", "Jordach", "far" },
|
|
||||||
{ "Credit Roll (Jordach's HD Mix)", "Junichi Masuda", "chirp" },
|
|
||||||
{ "Winter Feeling", "Tom Peter", "strad" },
|
|
||||||
{ "Synthgroove (Jordach's Mix)", "HeroOfTheWinds", "mellohi" },
|
|
||||||
{ "The Clueless Frog (Jordach's Mix)", "SoundHelix", "mall" },
|
|
||||||
}
|
|
||||||
local records = #recorddata
|
|
||||||
|
|
||||||
for r=1, records do
|
|
||||||
local doc = false
|
|
||||||
local entryname, longdesc, usagehelp
|
|
||||||
if r == 1 then
|
|
||||||
doc = true
|
|
||||||
entryname = S("Music Disc")
|
|
||||||
longdesc = S("A music disc holds a single music track which can be used in a jukebox to play music.")
|
|
||||||
usagehelp = S("Place a music disc into an empty jukebox to play the music. Use the jukebox again to retrieve the music disc. The music can only be heard by you, not by other players.")
|
|
||||||
end
|
|
||||||
minetest.register_craftitem("mcl_jukebox:record_"..r, {
|
|
||||||
description =
|
description =
|
||||||
core.colorize("#55FFFF", S("Music Disc")) .. "\n" ..
|
core.colorize("#55FFFF", S("Music Disc")) .. "\n" ..
|
||||||
core.colorize("#989898", S("@1—@2", recorddata[r][2], recorddata[r][1])),
|
core.colorize("#989898", S("@1—@2", author, title)),
|
||||||
_doc_items_create_entry = doc,
|
_doc_items_create_entry = true,
|
||||||
_doc_items_entry_name = entryname,
|
_doc_items_entry_name = entryname,
|
||||||
_doc_items_longdesc = longdesc,
|
_doc_items_longdesc = longdesc,
|
||||||
_doc_items_usagehelp = usagehelp,
|
_doc_items_usagehelp = usagehelp,
|
||||||
inventory_image = "mcl_jukebox_record_"..recorddata[r][3]..".png",
|
--inventory_image = "mcl_jukebox_record_"..recorddata[r][3]..".png",
|
||||||
|
inventory_image = image,
|
||||||
stack_max = 1,
|
stack_max = 1,
|
||||||
groups = { music_record = r },
|
groups = { music_record = 1 },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function now_playing(player, track_id)
|
local function now_playing(player, name)
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local hud = active_huds[playername]
|
local hud = active_huds[playername]
|
||||||
local text = S("Now playing: @1—@2", recorddata[track_id][2], recorddata[track_id][1])
|
local text = S("Now playing: @1—@2", mcl_jukebox.registered_records[name][2], mcl_jukebox.registered_records[name][1])
|
||||||
|
|
||||||
if not hud_sequence_numbers[playername] then
|
if not hud_sequence_numbers[playername] then
|
||||||
hud_sequence_numbers[playername] = 1
|
hud_sequence_numbers[playername] = 1
|
||||||
|
@ -106,18 +92,20 @@ minetest.register_craft({
|
||||||
})
|
})
|
||||||
|
|
||||||
local play_record = function(pos, itemstack, player)
|
local play_record = function(pos, itemstack, player)
|
||||||
local record_id = minetest.get_item_group(itemstack:get_name(), "music_record")
|
local item_name = itemstack:get_name()
|
||||||
if record_id ~= 0 then
|
-- ensure the jukebox uses the new record names for old records
|
||||||
|
local name = minetest.registered_aliases[item_name] or item_name
|
||||||
|
if mcl_jukebox.registered_records[name] then
|
||||||
local cname = player:get_player_name()
|
local cname = player:get_player_name()
|
||||||
if active_tracks[cname] ~= nil then
|
if active_tracks[cname] ~= nil then
|
||||||
minetest.sound_stop(active_tracks[cname])
|
minetest.sound_stop(active_tracks[cname])
|
||||||
active_tracks[cname] = nil
|
active_tracks[cname] = nil
|
||||||
end
|
end
|
||||||
active_tracks[cname] = minetest.sound_play("mcl_jukebox_track_"..record_id, {
|
active_tracks[cname] = minetest.sound_play(mcl_jukebox.registered_records[name][5], {
|
||||||
to_player = cname,
|
to_player = cname,
|
||||||
gain = 1,
|
gain = 1,
|
||||||
})
|
})
|
||||||
now_playing(player, record_id)
|
now_playing(player, name)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
@ -239,3 +227,22 @@ minetest.register_craft({
|
||||||
recipe = "mcl_jukebox:jukebox",
|
recipe = "mcl_jukebox:jukebox",
|
||||||
burntime = 15,
|
burntime = 15,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
mcl_jukebox.register_record("The Evil Sister (Jordach's Mix)", "SoundHelix", "13", "mcl_jukebox_record_13.png", "mcl_jukebox_track_1")
|
||||||
|
mcl_jukebox.register_record("The Energetic Rat (Jordach's Mix)", "SoundHelix", "wait", "mcl_jukebox_record_wait.png", "mcl_jukebox_track_2")
|
||||||
|
mcl_jukebox.register_record("Eastern Feeling", "Jordach", "blocks", "mcl_jukebox_record_blocks.png", "mcl_jukebox_track_3")
|
||||||
|
mcl_jukebox.register_record("Minetest", "Jordach", "far", "mcl_jukebox_record_far.png", "mcl_jukebox_track_4")
|
||||||
|
mcl_jukebox.register_record("Credit Roll (Jordach's HD Mix)", "Junichi Masuda", "chirp", "mcl_jukebox_record_chirp.png", "mcl_jukebox_track_5")
|
||||||
|
mcl_jukebox.register_record("Winter Feeling", "Tom Peter", "strad", "mcl_jukebox_record_strad.png", "mcl_jukebox_track_6")
|
||||||
|
mcl_jukebox.register_record("Synthgroove (Jordach's Mix)", "HeroOfTheWinds", "mellohi", "mcl_jukebox_record_mellohi.png", "mcl_jukebox_track_7")
|
||||||
|
mcl_jukebox.register_record("The Clueless Frog (Jordach's Mix)", "SoundHelix", "mall", "mcl_jukebox_record_mall.png", "mcl_jukebox_track_8")
|
||||||
|
|
||||||
|
--add backward compatibility
|
||||||
|
minetest.register_alias("mcl_jukebox:record_1", "mcl_jukebox:record_13")
|
||||||
|
minetest.register_alias("mcl_jukebox:record_2", "mcl_jukebox:record_wait")
|
||||||
|
minetest.register_alias("mcl_jukebox:record_3", "mcl_jukebox:record_blocks")
|
||||||
|
minetest.register_alias("mcl_jukebox:record_4", "mcl_jukebox:record_far")
|
||||||
|
minetest.register_alias("mcl_jukebox:record_5", "mcl_jukebox:record_chirp")
|
||||||
|
minetest.register_alias("mcl_jukebox:record_6", "mcl_jukebox:record_strad")
|
||||||
|
minetest.register_alias("mcl_jukebox:record_7", "mcl_jukebox:record_mellohi")
|
||||||
|
minetest.register_alias("mcl_jukebox:record_8", "mcl_jukebox:record_mall")
|
Loading…
Reference in New Issue