summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2021-02-05 20:16:32 -0600
committercheapie <no-email-for-you@example.com>2021-02-05 20:16:32 -0600
commit8e652528262e47d48e2ec81cdc528f743ef2f79a (patch)
treef31a1628f9e05a7ded7b74e5668ff4ac0a6ffbb2
parent6c299b2fe545cd006df85b03744b288d9861cd8c (diff)
downloaddigistuff-8e652528262e47d48e2ec81cdc528f743ef2f79a.tar
digistuff-8e652528262e47d48e2ec81cdc528f743ef2f79a.tar.gz
digistuff-8e652528262e47d48e2ec81cdc528f743ef2f79a.tar.bz2
digistuff-8e652528262e47d48e2ec81cdc528f743ef2f79a.tar.xz
digistuff-8e652528262e47d48e2ec81cdc528f743ef2f79a.zip
Make piston sounds configurable
-rw-r--r--README1
-rw-r--r--piston.lua20
2 files changed, 15 insertions, 6 deletions
diff --git a/README b/README
index d9f0b9b..31a4935 100644
--- a/README
+++ b/README
@@ -108,6 +108,7 @@ You can also send a command as a table. If so, the fields that can be used in th
* action: "extend" or "retract"
* max: The maximum number of nodes to push/pull, cannot be set higher than 16. Set to 0 (or omit) when retracting to perform a non-sticky retraction.
* allsticky: Pull a whole stack of nodes (like movestone), not just one.
+* sound: The sound to make. "mesecons" for the mesecons piston sounds, "digilines" for the digilines piston sounds (default), or "none" for no sounds at all.
How to use the digilines movestone:
Commands for this node are in the form of a table, with the field "command" set to the desired action, and other fields providing parameters.
diff --git a/piston.lua b/piston.lua
index bd8860b..299982e 100644
--- a/piston.lua
+++ b/piston.lua
@@ -3,14 +3,18 @@ if not minetest.get_modpath("mesecons_mvps") then
return
end
-local function extend(pos,node,max)
+local function extend(pos,node,max,sound)
local meta = minetest.get_meta(pos):to_table()
local facedir = minetest.facedir_to_dir(node.param2)
local actiondir = vector.multiply(facedir,-1)
local ppos = vector.add(pos,actiondir)
local success,stack,oldstack = mesecon.mvps_push(ppos,actiondir,max)
if not success then return end
- minetest.sound_play("digistuff_piston_extend",{pos = pos,max_hear_distance = 20,gain = 0.6})
+ if sound == "digilines" then
+ minetest.sound_play("digistuff_piston_extend",{pos = pos,max_hear_distance = 20,gain = 0.6})
+ elseif sound == "mesecons" then
+ minetest.sound_play("piston_extend",{pos = pos,max_hear_distance = 20,gain = 0.6})
+ end
minetest.swap_node(pos,{name = "digistuff:piston_ext",param2 = node.param2})
minetest.swap_node(ppos,{name = "digistuff:piston_pusher",param2 = node.param2})
mesecon.mvps_process_stack(stack)
@@ -18,7 +22,7 @@ local function extend(pos,node,max)
minetest.get_meta(pos):from_table(meta)
end
-local function retract(pos,node,max,allsticky)
+local function retract(pos,node,max,allsticky,sound)
local facedir = minetest.facedir_to_dir(node.param2)
local actiondir = vector.multiply(facedir,-1)
local ppos = vector.add(pos,actiondir)
@@ -26,7 +30,11 @@ local function retract(pos,node,max,allsticky)
if minetest.get_node(ppos).name == "digistuff:piston_pusher" then
minetest.remove_node(ppos)
end
- minetest.sound_play("digistuff_piston_retract",{pos = pos,max_hear_distance = 20,gain = 0.6})
+ if sound == "digilines" then
+ minetest.sound_play("digistuff_piston_retract",{pos = pos,max_hear_distance = 20,gain = 0.6})
+ elseif sound == "mesecons" then
+ minetest.sound_play("piston_retract",{pos = pos,max_hear_distance = 20,gain = 0.6})
+ end
minetest.check_for_falling(ppos)
if type(max) ~= "number" or max <= 0 then return end
local pullpos = vector.add(pos,vector.multiply(actiondir,2))
@@ -91,7 +99,7 @@ minetest.register_node("digistuff:piston", {
if type(msg.max) == "number" then
max = math.max(0,math.min(16,math.floor(msg.max)))
end
- extend(pos,node,max)
+ extend(pos,node,max,msg.sound or "digilines")
end
end
},
@@ -171,7 +179,7 @@ minetest.register_node("digistuff:piston_ext", {
elseif msg.max == nil then
max = 0
end
- retract(pos,node,max,msg.allsticky)
+ retract(pos,node,max,msg.allsticky,msg.sound or "digilines")
end
end
},