mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Sound refactor and improvements (#12764)
This commit is contained in:
parent
8e1af25738
commit
edcbfa31c9
52 changed files with 2802 additions and 1211 deletions
|
@ -3,3 +3,4 @@ local path = minetest.get_modpath("soundstuff") .. "/"
|
|||
dofile(path .. "sound_event_items.lua")
|
||||
dofile(path .. "jukebox.lua")
|
||||
dofile(path .. "bigfoot.lua")
|
||||
dofile(path .. "racecar.lua")
|
||||
|
|
|
@ -14,6 +14,7 @@ local meta_keys = {
|
|||
"sparam.gain",
|
||||
"sparam.pitch",
|
||||
"sparam.fade",
|
||||
"sparam.start_time",
|
||||
"sparam.loop",
|
||||
"sparam.pos",
|
||||
"sparam.object",
|
||||
|
@ -39,6 +40,7 @@ local function get_all_metadata(meta)
|
|||
gain = meta:get_string("sparam.gain"),
|
||||
pitch = meta:get_string("sparam.pitch"),
|
||||
fade = meta:get_string("sparam.fade"),
|
||||
start_time = meta:get_string("sparam.start_time"),
|
||||
loop = meta:get_string("sparam.loop"),
|
||||
pos = meta:get_string("sparam.pos"),
|
||||
object = meta:get_string("sparam.object"),
|
||||
|
@ -86,7 +88,7 @@ local function show_formspec(pos, player)
|
|||
|
||||
fs_add([[
|
||||
formspec_version[6]
|
||||
size[14,11]
|
||||
size[14,12]
|
||||
]])
|
||||
|
||||
-- SimpleSoundSpec
|
||||
|
@ -110,23 +112,25 @@ local function show_formspec(pos, player)
|
|||
-- sound parameter table
|
||||
fs_add(string.format([[
|
||||
container[5.5,0.5]
|
||||
box[-0.1,-0.1;4.2,10.2;#EBEBEB20]
|
||||
box[-0.1,-0.1;4.2,10.7;#EBEBEB20]
|
||||
style[*;font=mono,bold]
|
||||
label[0,0.25;sound parameter table]
|
||||
style[*;font=mono]
|
||||
field[0.00,1;1,0.75;sparam.gain;gain;%s]
|
||||
field[1.25,1;1,0.75;sparam.pitch;pitch;%s]
|
||||
field[2.50,1;1,0.75;sparam.fade;fade;%s]
|
||||
field[0,2.25;4,0.75;sparam.loop;loop;%s]
|
||||
field[0,3.50;4,0.75;sparam.pos;pos;%s]
|
||||
field[0,4.75;4,0.75;sparam.object;object;%s]
|
||||
field[0,6.00;4,0.75;sparam.to_player;to_player;%s]
|
||||
field[0,7.25;4,0.75;sparam.exclude_player;exclude_player;%s]
|
||||
field[0,8.50;4,0.75;sparam.max_hear_distance;max_hear_distance;%s]
|
||||
field[0,2.25;4,0.75;sparam.start_time;start_time;%s]
|
||||
field[0,3.50;4,0.75;sparam.loop;loop;%s]
|
||||
field[0,4.75;4,0.75;sparam.pos;pos;%s]
|
||||
field[0,6.00;4,0.75;sparam.object;object;%s]
|
||||
field[0,7.25;4,0.75;sparam.to_player;to_player;%s]
|
||||
field[0,8.50;4,0.75;sparam.exclude_player;exclude_player;%s]
|
||||
field[0,9.75;4,0.75;sparam.max_hear_distance;max_hear_distance;%s]
|
||||
container_end[]
|
||||
field_close_on_enter[sparam.gain;false]
|
||||
field_close_on_enter[sparam.pitch;false]
|
||||
field_close_on_enter[sparam.fade;false]
|
||||
field_close_on_enter[sparam.start_time;false]
|
||||
field_close_on_enter[sparam.loop;false]
|
||||
field_close_on_enter[sparam.pos;false]
|
||||
field_close_on_enter[sparam.object;false]
|
||||
|
@ -134,9 +138,10 @@ local function show_formspec(pos, player)
|
|||
field_close_on_enter[sparam.exclude_player;false]
|
||||
field_close_on_enter[sparam.max_hear_distance;false]
|
||||
tooltip[sparam.object;Get a name with the Branding Iron.]
|
||||
]], F(md.sparam.gain), F(md.sparam.pitch), F(md.sparam.fade), F(md.sparam.loop),
|
||||
F(md.sparam.pos), F(md.sparam.object), F(md.sparam.to_player),
|
||||
F(md.sparam.exclude_player), F(md.sparam.max_hear_distance)))
|
||||
]], F(md.sparam.gain), F(md.sparam.pitch), F(md.sparam.fade),
|
||||
F(md.sparam.start_time), F(md.sparam.loop), F(md.sparam.pos),
|
||||
F(md.sparam.object), F(md.sparam.to_player), F(md.sparam.exclude_player),
|
||||
F(md.sparam.max_hear_distance)))
|
||||
|
||||
-- fade
|
||||
fs_add(string.format([[
|
||||
|
@ -187,7 +192,7 @@ local function show_formspec(pos, player)
|
|||
|
||||
-- save and quit button
|
||||
fs_add([[
|
||||
button_exit[10.75,10;3,0.75;btn_save_quit;Save & Quit]
|
||||
button_exit[10.75,11;3,0.75;btn_save_quit;Save & Quit]
|
||||
]])
|
||||
|
||||
minetest.show_formspec(player:get_player_name(), "soundstuff:jukebox@"..pos:to_string(),
|
||||
|
@ -210,6 +215,7 @@ minetest.register_node("soundstuff:jukebox", {
|
|||
meta:set_string("sparam.gain", "")
|
||||
meta:set_string("sparam.pitch", "")
|
||||
meta:set_string("sparam.fade", "")
|
||||
meta:set_string("sparam.start_time", "")
|
||||
meta:set_string("sparam.loop", "")
|
||||
meta:set_string("sparam.pos", pos:to_string())
|
||||
meta:set_string("sparam.object", "")
|
||||
|
@ -267,6 +273,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
gain = tonumber(md.sparam.gain),
|
||||
pitch = tonumber(md.sparam.pitch),
|
||||
fade = tonumber(md.sparam.fade),
|
||||
start_time = tonumber(md.sparam.start_time),
|
||||
loop = minetest.is_yes(md.sparam.loop),
|
||||
pos = vector.from_string(md.sparam.pos),
|
||||
object = testtools.get_branded_object(md.sparam.object),
|
||||
|
@ -280,10 +287,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
"[soundstuff:jukebox] Playing sound: minetest.sound_play(%s, %s, %s)",
|
||||
string.format("{name=\"%s\", gain=%s, pitch=%s, fade=%s}",
|
||||
sss.name, sss.gain, sss.pitch, sss.fade),
|
||||
string.format("{gain=%s, pitch=%s, fade=%s, loop=%s, pos=%s, "
|
||||
string.format("{gain=%s, pitch=%s, fade=%s, start_time=%s, loop=%s, pos=%s, "
|
||||
.."object=%s, to_player=\"%s\", exclude_player=\"%s\", max_hear_distance=%s}",
|
||||
sparam.gain, sparam.pitch, sparam.fade, sparam.loop, sparam.pos,
|
||||
sparam.object and "<objref>", sparam.to_player, sparam.exclude_player,
|
||||
sparam.gain, sparam.pitch, sparam.fade, sparam.start_time,
|
||||
sparam.loop, sparam.pos, sparam.object and "<objref>",
|
||||
sparam.to_player, sparam.exclude_player,
|
||||
sparam.max_hear_distance),
|
||||
tostring(ephemeral)))
|
||||
|
||||
|
|
31
games/devtest/mods/soundstuff/racecar.lua
Normal file
31
games/devtest/mods/soundstuff/racecar.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
local drive_speed = 20
|
||||
local drive_distance = 30
|
||||
|
||||
minetest.register_entity("soundstuff:racecar", {
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
selectionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "upright_sprite",
|
||||
visual_size = {x = 1, y = 1, z = 1},
|
||||
textures = {"soundstuff_racecar.png", "soundstuff_racecar.png^[transformFX"},
|
||||
static_save = false,
|
||||
},
|
||||
|
||||
on_activate = function(self, _staticdata, _dtime_s)
|
||||
self.min_x = self.object:get_pos().x - drive_distance * 0.5
|
||||
self.max_x = self.min_x + drive_distance
|
||||
self.vel = vector.new(drive_speed, 0, 0)
|
||||
end,
|
||||
|
||||
on_step = function(self, _dtime, _moveresult)
|
||||
local pos = self.object:get_pos()
|
||||
if pos.x < self.min_x then
|
||||
self.vel = vector.new(drive_speed, 0, 0)
|
||||
elseif pos.x > self.max_x then
|
||||
self.vel = vector.new(-drive_speed, 0, 0)
|
||||
end
|
||||
self.object:set_velocity(self.vel)
|
||||
end,
|
||||
})
|
BIN
games/devtest/mods/soundstuff/sounds/soundstuff_sinus.ogg
Normal file
BIN
games/devtest/mods/soundstuff/sounds/soundstuff_sinus.ogg
Normal file
Binary file not shown.
BIN
games/devtest/mods/soundstuff/textures/soundstuff_racecar.png
Normal file
BIN
games/devtest/mods/soundstuff/textures/soundstuff_racecar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 129 B |
Loading…
Add table
Add a link
Reference in a new issue