Compare commits

...

5 Commits

Author SHA1 Message Date
BuckarooBanzay 4191aaf9a6 fix code highlight typo 2020-12-21 11:00:58 +01:00
BuckarooBanzay 75348a580b add digiline interface / switch to mod.conf 2020-12-21 10:50:18 +01:00
BuckarooBanzay 87738918ab gh action 2019-12-20 08:06:19 +01:00
BuckarooBanzay b9a5d135f1 horror support 2019-12-20 08:05:42 +01:00
Thomas Rudin 9b1d5c3903 mesecons compat 2019-11-23 19:38:00 +01:00
10 changed files with 135 additions and 17 deletions

17
.github/workflows/luacheck.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: luacheck
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: apt
run: sudo apt-get install -y luarocks
- name: luacheck install
run: luarocks install --local luacheck
- name: luacheck run
run: $HOME/.luarocks/bin/luacheck ./

View File

@ -10,6 +10,9 @@ read_globals = {
-- Minetest
"minetest",
"vector", "ItemStack"
"vector", "ItemStack",
-- mods
"digilines"
}

View File

@ -1,6 +0,0 @@
default?
doors?
mesecons?
technic?
ambience?
mobs_monster?

42
digiline.lua Normal file
View File

@ -0,0 +1,42 @@
soundblock.digiline_rules = {
-- digilines.rules.default
{x= 1,y= 0,z= 0},{x=-1,y= 0,z= 0}, -- along x side
{x= 0,y= 0,z= 1},{x= 0,y= 0,z=-1}, -- along z side
{x= 1,y= 1,z= 0},{x=-1,y= 1,z= 0}, -- 1 node above along x diagonal
{x= 0,y= 1,z= 1},{x= 0,y= 1,z=-1}, -- 1 node above along z diagonal
{x= 1,y=-1,z= 0},{x=-1,y=-1,z= 0}, -- 1 node below along x diagonal
{x= 0,y=-1,z= 1},{x= 0,y=-1,z=-1}, -- 1 node below along z diagonal
{x= 0,y= 1,z= 0},{x= 0,y=-1,z= 0}, -- along y above and below
}
function soundblock.digiline_effector(pos, _, channel, msg)
local msgt = type(msg)
if msgt ~= "table" then
return
end
if channel ~= "soundblock" then
return
end
if msg.command == "play" then
-- default position
local playpos = pos
if msg.pos then
-- relative position offset
playpos = vector.add(pos, {
x = tonumber(msg.pos.x) or 0,
y = tonumber(msg.pos.y) or 0,
z = tonumber(msg.pos.z) or 0
})
end
minetest.sound_play(msg.name, {
pos = playpos,
gain = math.min(10, tonumber(msg.gain) or 1),
max_hear_distance = math.min(32, tonumber(msg.hear_distance) or 10)
})
end
end

View File

@ -91,10 +91,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.toggle_state then
if state == "on" then
state = "mesecons"
timer:stop()
elseif state == "mesecons" then
state = "off"
timer:stop()
@ -129,9 +125,5 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end
if state == "on" then
timer:start(0)
end
timer:start(0)
end)

View File

@ -6,6 +6,7 @@ soundblock = {
local MP = minetest.get_modpath("soundblock")
dofile(MP.."/api.lua")
dofile(MP.."/form.lua")
dofile(MP.."/digiline.lua")
dofile(MP.."/soundblock.lua")
dofile(MP.."/recipe.lua")
@ -13,6 +14,10 @@ if minetest.get_modpath("default") then
dofile(MP.."/mods/default.lua")
end
if minetest.get_modpath("horror") then
dofile(MP.."/mods/horror.lua")
end
if minetest.get_modpath("doors") then
dofile(MP.."/mods/doors.lua")
end

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = soundblock
description = Soundblock
optional_depends = default, doors, horror, mesecons, technic, ambience, mobs_monster, digilines

26
mods/horror.lua Normal file
View File

@ -0,0 +1,26 @@
for i=1,7 do
soundblock.register({
filename = "horror_" .. i,
key = "horror_" .. i,
name = "Horror track " .. i
})
end
soundblock.register({
filename = "clock",
key = "horror_clock",
name = "Horror clock"
})
soundblock.register({
filename = "clock_strikes_twelve",
key = "clock_strikes_twelve",
name = "Horror clock strikes twelve"
})
soundblock.register({
filename = "Undersea_Garden",
key = "Undersea_Garden",
name = "Horror undersea garden"
})

View File

@ -25,7 +25,22 @@ soundblocks.register({
```
# Digiline api
```lua
if event.type == "program" then
digiline_send("soundblock", {
command = "play",
name = "default_grass_footstep.1.ogg",
-- relative position (optional)
pos = { x=0, y=10, z=0 },
-- gain, defaults to 1
gain = 1,
-- max_hear_distance, defaults to 10
hear_distance = 32
})
end
```
# License

View File

@ -97,13 +97,34 @@ minetest.register_node("soundblock:block", {
mesecons = {
effector = {
action_on = function (pos)
execute(pos)
local meta = minetest.get_meta(pos)
meta:set_string("state", "on")
local timer = minetest.get_node_timer(pos)
timer:start(0)
end,
action_off = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("state", "off")
local timer = minetest.get_node_timer(pos)
timer:stop()
stop_sound(pos)
end
}
},
digiline = {
receptor = {
rules = soundblock.digiline_rules,
action = function() end
},
effector = {
rules = soundblock.digiline_rules,
action = soundblock.digiline_effector
}
},
on_rightclick = soundblock.showform
})