Skip to content

Commit

Permalink
Improve disc API, Add documentation, Bump to 2.0!
Browse files Browse the repository at this point in the history
  • Loading branch information
LNJ2 committed May 23, 2016
1 parent d273a23 commit 151ab04
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 10 deletions.
35 changes: 32 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Minetest mod "Jukebox"
======================
Version: 1.2
Version: 2.0

License of source code:
-----------------------
Expand All @@ -23,6 +23,7 @@ Copyright (C) 2016 Rui
0. You just DO WHAT THE FUCK YOU WANT TO.



License of textures:
--------------------
(by Authors)
Expand All @@ -43,6 +44,11 @@ The authors are (freesound.org):



Notice:
-------
This mod is only useable with Minetest 0.4.14 or above!


Description:
------------
In the Jukebox plus mod you've got 9 different music discs.
Expand All @@ -59,14 +65,37 @@ So you can have up to 9x10 (90) songs!

Using the mod:
--------------

To use the jukebox, you have to craft one. You need 8 wood and 1 mese crystal to craft it following way:

wood wood wood
wood mese crystal wood
wood wood wood


Just rightclick with a music disc in your hand on the jukebox and it will play a random song from this disc.
To stop the music rightclick the box again and it will drop the music disc.


API Documentation:
------------------
The jukebox mod offers a simple API to register new discs. See here how to use it:

jukebox.register_disc("mymod:new_disc", {
description = "New Disc",
^ The item description
inventory_image = "mymod_new_disc.png",
^ The disc image / texture
music_name = "mymod_new_disc",
^ This is the sound that'll be played if you insert the disc

-- if you want to you can add here more options as in minetest.register_craftitem (except stack_max)
})



Links:
------
Forum Topic:
https://forum.minetest.net/viewtopic.php?id=13505

GitHub:
https://github.com/lnj2/jukebox
28 changes: 21 additions & 7 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
jukebox = {}
jukebox.registered_discs = {}

function jukebox.register_disc(name, description, inventory_image, music_name)
minetest.register_craftitem(":" .. name, {
description = description,
inventory_image = inventory_image,
stack_max = 1
})
function jukebox.register_disc(name, def)
def.stack_max = 1

local music_name = def.music_name
def.music_name = nil

minetest.register_craftitem(":" .. name, def)

jukebox.registered_discs[name] = music_name
end

-- +-----------+
-- | The Box |
-- +-----------+


local handlers = {}

minetest.register_node("jukebox:box", {
Expand Down Expand Up @@ -120,13 +126,21 @@ minetest.register_craft({
}
})

-- +---------+
-- | Discs |
-- +---------+

for i = 1, 9 do
local item_name = "jukebox:disc_" .. i
local description = "Music Disc " .. i
local inventory_image = "jukebox_disc_" .. i .. ".png"
local music_name = "jukebox_disc_" .. i

jukebox.register_disc(item_name, description, inventory_image, music_name)
jukebox.register_disc(item_name, {
description = description,
inventory_image = inventory_image,
music_name = music_name
})
end

minetest.register_craft({
Expand Down

0 comments on commit 151ab04

Please sign in to comment.