add digiline interface / switch to mod.conf
parent
87738918ab
commit
75348a580b
|
@ -10,6 +10,9 @@ read_globals = {
|
||||||
|
|
||||||
-- Minetest
|
-- Minetest
|
||||||
"minetest",
|
"minetest",
|
||||||
"vector", "ItemStack"
|
"vector", "ItemStack",
|
||||||
|
|
||||||
|
-- mods
|
||||||
|
"digilines"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
default?
|
|
||||||
doors?
|
|
||||||
horror?
|
|
||||||
mesecons?
|
|
||||||
technic?
|
|
||||||
ambience?
|
|
||||||
mobs_monster?
|
|
|
@ -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
|
1
init.lua
1
init.lua
|
@ -6,6 +6,7 @@ soundblock = {
|
||||||
local MP = minetest.get_modpath("soundblock")
|
local MP = minetest.get_modpath("soundblock")
|
||||||
dofile(MP.."/api.lua")
|
dofile(MP.."/api.lua")
|
||||||
dofile(MP.."/form.lua")
|
dofile(MP.."/form.lua")
|
||||||
|
dofile(MP.."/digiline.lua")
|
||||||
dofile(MP.."/soundblock.lua")
|
dofile(MP.."/soundblock.lua")
|
||||||
dofile(MP.."/recipe.lua")
|
dofile(MP.."/recipe.lua")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
name = soundblock
|
||||||
|
description = Soundblock
|
||||||
|
optional_depends = default, doors, horror, mesecons, technic, ambience, mobs_monster, digilines
|
15
readme.md
15
readme.md
|
@ -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
|
# License
|
||||||
|
|
||||||
|
|
|
@ -115,5 +115,16 @@ minetest.register_node("soundblock:block", {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
digiline = {
|
||||||
|
receptor = {
|
||||||
|
rules = soundblock.digiline_rules,
|
||||||
|
action = function() end
|
||||||
|
},
|
||||||
|
effector = {
|
||||||
|
rules = soundblock.digiline_rules,
|
||||||
|
action = soundblock.digiline_effector
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
on_rightclick = soundblock.showform
|
on_rightclick = soundblock.showform
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue