bigfoot.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. local walk_speed = 2
  2. local walk_distance = 10
  3. core.register_entity("soundstuff:bigfoot", {
  4. initial_properties = {
  5. physical = false,
  6. collisionbox = {-1, -1, -1, 1, 1, 1},
  7. selectionbox = {-1, -1, -1, 1, 1, 1},
  8. visual = "upright_sprite",
  9. visual_size = {x = 2, y = 2, z = 2},
  10. textures = {"soundstuff_bigfoot.png", "soundstuff_bigfoot.png^[transformFX"},
  11. makes_footstep_sound = true,
  12. static_save = false,
  13. },
  14. on_activate = function(self, _staticdata, _dtime_s)
  15. self.min_x = self.object:get_pos().x - walk_distance * 0.5
  16. self.max_x = self.min_x + walk_distance
  17. self.vel = vector.new(walk_speed, 0, 0)
  18. end,
  19. on_step = function(self, _dtime, _moveresult)
  20. local pos = self.object:get_pos()
  21. if pos.x < self.min_x then
  22. self.vel = vector.new(walk_speed, 0, 0)
  23. elseif pos.x > self.max_x then
  24. self.vel = vector.new(-walk_speed, 0, 0)
  25. end
  26. self.object:set_velocity(self.vel)
  27. end,
  28. })
  29. core.register_chatcommand("spawn_bigfoot", {
  30. params = "",
  31. description = "Spawn a big foot object that makes footstep sounds",
  32. func = function(name, _param)
  33. local player = core.get_player_by_name(name)
  34. if not player then
  35. return false, "No player."
  36. end
  37. local pos = player:get_pos()
  38. pos.y = pos.y + player:get_properties().collisionbox[2]
  39. pos.y = pos.y - (-1) -- bigfoot collisionbox goes 1 down
  40. core.add_entity(pos, "soundstuff:bigfoot")
  41. return true
  42. end,
  43. })