summaryrefslogtreecommitdiff
path: root/noteblock.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2020-04-28 21:28:26 -0500
committercheapie <no-email-for-you@example.com>2020-04-28 21:28:26 -0500
commit69a9304751cfdf784696212fcf4834eba584c584 (patch)
treed3eee2101621ed46ac84c7a01d8e3b24885b8568 /noteblock.lua
parent8384563085d187534e2240325c648d1ce91ba8bc (diff)
downloaddigistuff-69a9304751cfdf784696212fcf4834eba584c584.tar
digistuff-69a9304751cfdf784696212fcf4834eba584c584.tar.gz
digistuff-69a9304751cfdf784696212fcf4834eba584c584.tar.bz2
digistuff-69a9304751cfdf784696212fcf4834eba584c584.tar.xz
digistuff-69a9304751cfdf784696212fcf4834eba584c584.zip
Miscellaneous touchscreen and noteblock work
* Noteblock sound list updated * Noteblocks now support pitch control * Touchscreens can now optionally use the "real coordinates" system
Diffstat (limited to 'noteblock.lua')
-rw-r--r--noteblock.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/noteblock.lua b/noteblock.lua
index 665c201..5bd0883 100644
--- a/noteblock.lua
+++ b/noteblock.lua
@@ -1,5 +1,5 @@
if not minetest.get_modpath("mesecons_noteblock") then
- minetest.log("error","mesecons_noteblock is not installed - digilines noteblock will not be available!")
+ minetest.log("warning","mesecons_noteblock is not installed - digilines noteblock will not be available!")
return
end
@@ -51,12 +51,23 @@ minetest.register_node("digistuff:noteblock", {
if sound then minetest.sound_play(sound,{pos=pos}) end
elseif type(msg) == "table" then
if type(msg.sound) ~= "string" then return end
+ for _,i in ipairs({"pitch","speed","volume","gain",}) do
+ if type(msg[i]) == "string" then
+ msg[i] = tonumber(msg[i])
+ end
+ end
local sound = validnbsounds[msg.sound]
+ if not msg.volume then msg.volume = msg.gain end
local volume = 1
if type(msg.volume) == "number" then
volume = math.max(0,math.min(1,msg.volume))
end
- if sound then minetest.sound_play({name=sound,gain=volume},{pos=pos}) end
+ if not msg.pitch then msg.pitch = msg.speed end
+ local pitch = 1
+ if type(msg.pitch) == "number" then
+ pitch = math.max(0.05,math.min(10,msg.pitch))
+ end
+ if sound then minetest.sound_play({name = sound,gain = volume,},{pos = pos,pitch = pitch,},true) end
end
end
},