Select vinyl
This commit is contained in:
parent
0766bfee36
commit
27eb943ec3
105
init.lua
105
init.lua
@ -21,6 +21,105 @@ minetest.register_node("vinylplayer:player", {
|
||||
|
||||
drop = "vinylplayer:player_fragments",
|
||||
|
||||
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local aa = meta:get_string("a")
|
||||
local bb = tonumber(meta:get_string("b")) or 5
|
||||
local cc = tonumber(meta:get_string("c")) or 3
|
||||
local dd = meta:get_string("d")
|
||||
local ee = tonumber(meta:get_string("e")) or 10
|
||||
local ff = tonumber(meta:get_string("e")) or 1
|
||||
|
||||
minetest.show_formspec(player:get_player_name(),"fs",
|
||||
"size[6,7;]"..
|
||||
"background[-0.5,-0.5;7,8;mysoundblocks_bg.png]"..
|
||||
"field[1,1;4.5,1;snd;Enter Sound Name;"..aa.."]"..
|
||||
"field[1,2;4.5,1;txt;Enter Chat Message;"..dd.."]"..
|
||||
"field[1,3;2,1;sndl;Length;"..bb.."]"..
|
||||
"field[3.5,3;2,1;sndhd;Radius;"..cc.."]"..
|
||||
"label[0.7,3.4;Player or All]"..
|
||||
"dropdown[0.7,3.8;2,1;pora;Player,All;]"..
|
||||
"field[3.5,4;2,1;snddis;Hear Distance;"..ee.."]"..
|
||||
"field[2.75,5;1,1;sndgn;Gain;"..ff.."]"..
|
||||
"button_exit[0.75,5.75;1.5,1;ents;Sound]"..
|
||||
"button_exit[2.25,5.75;1.5,1;entc;Chat]"..
|
||||
"button_exit[3.75,5.75;1.5,1;entb;Both]"
|
||||
)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local thing1 = fields["snd"]
|
||||
local thing2 = fields["sndl"]
|
||||
local thing3 = fields["sndhd"]
|
||||
local thing4 = fields["txt"]
|
||||
local thing5 = ""
|
||||
local thing6 = fields["pora"]
|
||||
local thing7 = fields["snddis"]
|
||||
local thing8 = fields["sndgn"]
|
||||
|
||||
|
||||
if fields["ents"]
|
||||
or fields["entc"]
|
||||
or fields["entb"]
|
||||
or fields["snd"]
|
||||
or fields["txt"] then
|
||||
|
||||
if fields["ents"]
|
||||
and fields["snd"] ~= "" then
|
||||
|
||||
meta:set_string("a", thing1)
|
||||
meta:set_string("b", thing2)
|
||||
meta:set_string("c", thing3)
|
||||
meta:set_string("d", thing4)
|
||||
meta:set_string("e", "sound")
|
||||
meta:set_string("f", thing6)
|
||||
meta:set_string("g", thing7)
|
||||
meta:set_string("h", thing8)
|
||||
|
||||
return true
|
||||
|
||||
elseif fields["entc"]
|
||||
and fields["txt"] ~= "" then
|
||||
|
||||
meta:set_string("a", thing1)
|
||||
meta:set_string("b", thing2)
|
||||
meta:set_string("c", thing3)
|
||||
meta:set_string("d", thing4)
|
||||
meta:set_string("e", "chat")
|
||||
|
||||
|
||||
return true
|
||||
|
||||
elseif fields["entb"]
|
||||
and fields["txt"] ~= ""
|
||||
and fields["snd"] ~= "" then
|
||||
|
||||
meta:set_string("a", thing1)
|
||||
meta:set_string("b", thing2)
|
||||
meta:set_string("c", thing3)
|
||||
meta:set_string("d", thing4)
|
||||
meta:set_string("e", "both")
|
||||
meta:set_string("f", thing6)
|
||||
meta:set_string("g", thing7)
|
||||
meta:set_string("h", thing8)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
end)
|
||||
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
|
||||
@ -129,7 +228,11 @@ minetest.register_on_punchnode(function(pos, node, player, pointed_thing)
|
||||
local handle = 0
|
||||
print( "Play sound Node/block at ".. mypos)
|
||||
|
||||
handle = minetest.sound_play("vinylplayer_keepyourweeds", {
|
||||
local meta = minetest.get_meta(pos)
|
||||
local vinyl_name = meta:get_string("a")
|
||||
print("vinyl name: " .. vinyl_name)
|
||||
|
||||
handle = minetest.sound_play(vinyl_name, {
|
||||
pos = pos,
|
||||
gain = 1.0,
|
||||
max_hear_distance = 32,
|
||||
|
BIN
sounds/vinylplayer_roads.ogg
Normal file
BIN
sounds/vinylplayer_roads.ogg
Normal file
Binary file not shown.
BIN
textures/mysoundblocks_bg.png
Normal file
BIN
textures/mysoundblocks_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 KiB |
Loading…
x
Reference in New Issue
Block a user