From 7283d2495f561375e3094390ba1117558ffb49c1 Mon Sep 17 00:00:00 2001 From: Desour Date: Wed, 14 Sep 2022 18:07:50 +0200 Subject: [PATCH] Devtest: Add bigfoot for footstep sounds --- LICENSE.txt | 1 + games/devtest/mods/soundstuff/bigfoot.lua | 48 ++++++++++++++++++ games/devtest/mods/soundstuff/init.lua | 1 + .../textures/soundstuff_bigfoot.png | Bin 0 -> 169 bytes 4 files changed, 50 insertions(+) create mode 100644 games/devtest/mods/soundstuff/bigfoot.lua create mode 100644 games/devtest/mods/soundstuff/textures/soundstuff_bigfoot.png diff --git a/LICENSE.txt b/LICENSE.txt index 8c69546a0..bc64ad7f1 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -79,6 +79,7 @@ SmallJoker: textures/base/pack/server_favorite_delete.png (based on server_favorite.png) DS: + games/devtest/mods/soundstuff/textures/soundstuff_bigfoot.png games/devtest/mods/soundstuff/textures/soundstuff_jukebox.png games/devtest/mods/testtools/textures/testtools_branding_iron.png diff --git a/games/devtest/mods/soundstuff/bigfoot.lua b/games/devtest/mods/soundstuff/bigfoot.lua new file mode 100644 index 000000000..40677793f --- /dev/null +++ b/games/devtest/mods/soundstuff/bigfoot.lua @@ -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, +}) diff --git a/games/devtest/mods/soundstuff/init.lua b/games/devtest/mods/soundstuff/init.lua index 07458aea9..b878f82a0 100644 --- a/games/devtest/mods/soundstuff/init.lua +++ b/games/devtest/mods/soundstuff/init.lua @@ -2,3 +2,4 @@ local path = minetest.get_modpath("soundstuff") .. "/" dofile(path .. "sound_event_items.lua") dofile(path .. "jukebox.lua") +dofile(path .. "bigfoot.lua") diff --git a/games/devtest/mods/soundstuff/textures/soundstuff_bigfoot.png b/games/devtest/mods/soundstuff/textures/soundstuff_bigfoot.png new file mode 100644 index 0000000000000000000000000000000000000000..6770b3f599128e166480188e2cfb67fa35f45b0a GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnH3?%tPCZz)@o&cW^S0D`ppAO`IIy-U2f8A6d zhp{BcFPOpM*^M+H$J^7zF+}2WasmU>vC!2r5^UDVOj^ykS68VfxQR?*oWf`vargkw zwSWajR)uOyKB-^ZWbi89Q8IFMfzgq$w6!c*F^3LFC`mDyC^IlCo* J%Q~loCIDGHG0p%0 literal 0 HcmV?d00001