From ea2eaaa1dca548da9afab94826a8247a27309f2f Mon Sep 17 00:00:00 2001 From: Tmanyo Date: Wed, 2 Nov 2016 19:37:40 -0400 Subject: [PATCH] New Files --- init.lua | 101 +++++++++++++++++++++++++++++++++++++ license.txt | 19 +++++++ sounds/Space filler.txt | 1 + textures/tmusic_player.png | Bin 0 -> 2901 bytes 4 files changed, 121 insertions(+) create mode 100644 init.lua create mode 100644 license.txt create mode 100644 sounds/Space filler.txt create mode 100644 textures/tmusic_player.png diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..753b897 --- /dev/null +++ b/init.lua @@ -0,0 +1,101 @@ +music = { + list = {} +} + +music_playing = nil + +function music_list() + music.list = minetest.get_dir_list(minetest.get_modpath("tmusic_player") .. "/sounds", false) + local s = minetest.serialize(music.list) + return s:gsub("%p", ""):gsub("return",""):gsub("tmusicplayer", ""):gsub("ogg", ""):gsub(" ", ",") +end + +minetest.register_chatcommand("music", { + func = function(name, param) + minetest.show_formspec(name, "tmusic_player:songs", + "size[12,12]" .. + "label[0,0;Playable songs:]" .. + "image[8,0;6,1.5;tmusic_player.png]" .. + "table[.5,1;9,9;song_list;".. music_list() .. "]" .. + "field[.5,10.75;5,1;song_to_play;Song to play:; ]" .. + "button[10,4;2,1;play;Play]" .. + "button[10,5;2,1;stop;Stop]" .. + "button[10,1;2,1;loop_current;Loop Current]" .. + "button[10,9;2,1;help;Help]" .. + "button_exit[10,10.5;2,1;exit;Close]") + end +}) + +minetest.setting_set("individual_loop", "true") + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname == "tmusic_player:songs" then + if fields.play then + if music_playing ~= nil then + return false + else + music_playing = minetest.sound_play("tmusic_player_" .. fields.song_to_play, { + gain = 10, + to_player = minetest.get_connected_players() + }) + end + elseif fields.stop then + if music_playing == nil then + return false + else + music_playing = minetest.sound_stop(music_playing) + minetest.setting_set("individual_loop", "false") + end + end + if fields.loop_current then + if minetest.setting_getbool("individual_loop") == true then + if music_playing ~= nil then + return false + else + music_playing = minetest.sound_play("tmusic_player_" .. fields.song_to_play, { + gain = 10, + object = player, + loop = true + }) + end + end + end + if fields.help then + minetest.show_formspec(player:get_player_name(), "tmusic_player:help", + "size[9,9]" .. + "label[4,0;Help]" .. + "label[.25,.5;Adding Music:]" .. + "label[0,1;To add music, convert your audio file into an OGG Vorbis format and save it to the mod's sounds folder. The]" .. + "label[0,1.25;filename convention is - tmusic_player_soundname. An example is tmusic_player_bowwowcow.]" .. + "label[.25,1.75;Playing Music:]" .. + "label[0,2.25;To play music, enter the song's name exactly as it is in the list into the text box and]" .. + "label[0,2.5;click Play. If the song does not start playing, you entered the song name incorrectly.]" .. + "label[.25,3;Stopping Music:]" .. + "label[0,3.5;To stop music, click the Stop button. If there was no music playing to begin with, nothing will happen.]" .. + "label[.25,4;Looping Current Song:]" .. + "label[0,4.5;To repeat the current song, enter the song's name exactly as it is in the list into the text box]" .. + "label[0,4.75;and click Loop Current. If the song does not start playing, you entered the song name incorrectly.]" .. + "image[2,5.5;6,1.5;tmusic_player.png]" .. + "button[0,8;2,1;back;Back]" .. + "button_exit[2,8;2,1;exit;Close]") + end + end +end) + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname == "tmusic_player:help" then + if fields.back then + minetest.show_formspec(player:get_player_name(), "tmusic_player:songs", + "size[12,12]" .. + "label[0,0;Playable songs:]" .. + "image[8,0;6,1.5;tmusic_player.png]" .. + "table[.5,1;9,9;song_list;".. music_list() .. "]" .. + "field[.5,10.75;5,1;song_to_play;Song to play:; ]" .. + "button[10,4;2,1;play;Play]" .. + "button[10,5;2,1;stop;Stop]" .. + "button[10,1;2,1;loop_current;Loop Current]" .. + "button[10,9;2,1;help;Help]" .. + "button_exit[10,10.5;2,1;exit;Close]") + end + end +end) diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..2b734fa --- /dev/null +++ b/license.txt @@ -0,0 +1,19 @@ +LGPL 2.1 +License for Code +---------------- + +Copyright (C) 2016 Tmanyo + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation; either version 2.1 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. \ No newline at end of file diff --git a/sounds/Space filler.txt b/sounds/Space filler.txt new file mode 100644 index 0000000..a440a5c --- /dev/null +++ b/sounds/Space filler.txt @@ -0,0 +1 @@ +This document is to fill space. Once you add a song, you can remove this document. \ No newline at end of file diff --git a/textures/tmusic_player.png b/textures/tmusic_player.png new file mode 100644 index 0000000000000000000000000000000000000000..73dc0023359effb2271b2e94327b62b53f3d61e7 GIT binary patch literal 2901 zcmd5;`CAj`7XBs#h=3485k$zyVv7RNpcdI2FhW#RZcr?UA|ze~7eu`Q8kT9Tpt42U z$6c{*R4w4(l|?q|1rtO-1tk~}EhxqWEC>M%kbV=W-an!9L!Qi;@0|0#?|J7ub0l!B z|5Srn1^|GmD>-Z~06HlAFQMtdUwZbTSpXQ$Udi@ZAOF0keci8Dw~dMWWRIf)&djZQ z@U?~AHJbJBq3knH(4WKJ+{-k~6ExU{4d~C>v4K8g`eQ~zuzCK)mKBB(wijzlIZ7rq zD%1T6t7||Ut$ZjKx_Y7h{!L4plEPbu?)0`Ade?WHN>ePgE*$#c*|a|ufdKv~m-PHl zN5YQgEp8o_m~E@L_lVbY^={?2$}H)&EIokOV&Li`zx#H?Eux`&x1DOQ@@W=rBD^<9 zS#$hP>7Bet#(&lW8XckBEMQD!jy8x#1RIsNvy8OI1d41~Ms|ZH?LnQ?!`ce8Q#twX zq6Ryt-!{vwsgmfX8tfWp7^Xxyy)_hUMNT}7K+6ItUM z_8}Cf1=#&DJ5_`9N|udQ1cV#e86K#KQi?kDG2F=mds}sYpWrkwIOZpW^{O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