init project

This commit is contained in:
Nitro 2020-09-16 03:17:02 +02:00
commit a72ccdcce3
8 changed files with 103 additions and 0 deletions

38
README.md Normal file

@ -0,0 +1,38 @@
MineTest - Sound block
======================
This is mod for game: MineTest.
Allows to play OGG file.
It easy to set up.
1. Copy OGG file to mesecons_soundblock\sounds folder.
2. Take soundblock (type /give <player> mesecons_soundblock:block on the chat or search block in the inventory).
3. Place soundblock on the ground.
4. Click right button of mouse on soundblock - it opens configuration window.
- Channel - (string) channel's name,
- Hearing distance - (int) max. distance between block and player. If is greater than declared, player don't hear anything from block,
- Volume
5. Next connect soundblock using digilines with e.g. microcontroller.
6. If you want play sound, type in e.g. controller:
digiline_send("channel", "oggfilename")
where:
**channel** - name of earlier declared channel
**oggfilename** - name of ogg file in "mesecons_soundblock\sounds folder" without file extension
If is correct you should listen sound file.
**Depends:**
- digilines
- mesecons
**License:**
CC BY 4.0

2
depends.txt Normal file

@ -0,0 +1,2 @@
digilines
mesecons

61
init.lua Normal file

@ -0,0 +1,61 @@
local on_digiline_receive = function (pos, _, channel, msg)
local setchan = minetest.get_meta(pos):get_string("channel")
if channel == setchan then
local meta = minetest.get_meta(pos)
local heardistance = tonumber(meta:get_string("heardistance")) or 10
local gain = tonumber(meta:get_string("gain")) or 1
minetest.sound_play(
msg, {
pos = pos,
max_hear_distance = heardistance,
gain = gain,
}, true)
end
end
minetest.register_node("mesecons_soundblock:block", {
description = "mesecons_soundblock",
tiles = {"mesecons_soundblock.png"},
is_ground_content = false,
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2},
digiline =
{
receptor = {},
effector = {
action = on_digiline_receive
},
},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
local channel = meta:get_string("channel")
local heardistance = tonumber(meta:get_string("heardistance")) or 10
local gain = tonumber(meta:get_string("gain")) or 1
minetest.show_formspec(player:get_player_name(),"fs",
"size[6,5;]"..
"bgcolor[#0000;fullscreen]"..
"field[1,1;4.5,1;channel;Channel;"..channel.."]"..
"field[1,2;4.5,1;heardistance;Hearing distance;"..heardistance.."]"..
"field[1,3;4.5,1;gain;Volume;"..gain.."]"..
"button_exit[2,4;1.5,1;save;Save]"
)
minetest.register_on_player_receive_fields(function(player, formname, fields)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local channel = fields["channel"]
local heardistance = fields["heardistance"]
local gain = fields["gain"]
if fields["save"] then
meta:set_string("channel", channel)
meta:set_string("heardistance", heardistance)
meta:set_string("gain", gain)
end
end)
end
})

2
mod.conf Normal file

@ -0,0 +1,2 @@
name = mesecons_soundblock
depends = digilines, mesecons

BIN
sounds/a.ogg Normal file

Binary file not shown.

BIN
sounds/b.ogg Normal file

Binary file not shown.

BIN
sounds/c.ogg Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B