Devtest: Add bigfoot for footstep sounds

This commit is contained in:
Desour 2022-09-14 18:07:50 +02:00 committed by rubenwardy
parent e139749b5c
commit 7283d2495f
4 changed files with 50 additions and 0 deletions

@ -79,6 +79,7 @@ SmallJoker:
textures/base/pack/server_favorite_delete.png (based on server_favorite.png) textures/base/pack/server_favorite_delete.png (based on server_favorite.png)
DS: DS:
games/devtest/mods/soundstuff/textures/soundstuff_bigfoot.png
games/devtest/mods/soundstuff/textures/soundstuff_jukebox.png games/devtest/mods/soundstuff/textures/soundstuff_jukebox.png
games/devtest/mods/testtools/textures/testtools_branding_iron.png games/devtest/mods/testtools/textures/testtools_branding_iron.png

@ -0,0 +1,48 @@
local walk_speed = 2
local walk_distance = 10
minetest.register_entity("soundstuff:bigfoot", {
initial_properties = {
physical = false,
collisionbox = {-1, -1, -1, 1, 1, 1},
selectionbox = {-1, -1, -1, 1, 1, 1},
visual = "upright_sprite",
visual_size = {x = 2, y = 2, z = 2},
textures = {"soundstuff_bigfoot.png", "soundstuff_bigfoot.png^[transformFX"},
makes_footstep_sound = true,
static_save = false,
},
on_activate = function(self, _staticdata, _dtime_s)
self.min_x = self.object:get_pos().x - walk_distance * 0.5
self.max_x = self.min_x + walk_distance
self.vel = vector.new(walk_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(walk_speed, 0, 0)
elseif pos.x > self.max_x then
self.vel = vector.new(-walk_speed, 0, 0)
end
self.object:set_velocity(self.vel)
end,
})
minetest.register_chatcommand("spawn_bigfoot", {
params = "",
description = "Spawn a big foot object that makes footstep sounds",
func = function(name, _param)
local player = minetest.get_player_by_name(name)
if not player then
return false, "No player."
end
local pos = player:get_pos()
pos.y = pos.y + player:get_properties().collisionbox[2]
pos.y = pos.y - (-1) -- bigfoot collisionbox goes 1 down
minetest.add_entity(pos, "soundstuff:bigfoot")
return true
end,
})

@ -2,3 +2,4 @@
local path = minetest.get_modpath("soundstuff") .. "/" local path = minetest.get_modpath("soundstuff") .. "/"
dofile(path .. "sound_event_items.lua") dofile(path .. "sound_event_items.lua")
dofile(path .. "jukebox.lua") dofile(path .. "jukebox.lua")
dofile(path .. "bigfoot.lua")

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B