build_arrow.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. minetest.register_craftitem("throwing:arrow_build", {
  2. description = "Build Arrow",
  3. inventory_image = "throwing_arrow_build.png",
  4. })
  5. minetest.register_node("throwing:arrow_build_box", {
  6. drawtype = "nodebox",
  7. node_box = {
  8. type = "fixed",
  9. fixed = {
  10. -- Shaft
  11. {-6.5/17, -1.5/17, -1.5/17, 6.5/17, 1.5/17, 1.5/17},
  12. --Spitze
  13. {-4.5/17, 2.5/17, 2.5/17, -3.5/17, -2.5/17, -2.5/17},
  14. {-8.5/17, 0.5/17, 0.5/17, -6.5/17, -0.5/17, -0.5/17},
  15. --Federn
  16. {6.5/17, 1.5/17, 1.5/17, 7.5/17, 2.5/17, 2.5/17},
  17. {7.5/17, -2.5/17, 2.5/17, 6.5/17, -1.5/17, 1.5/17},
  18. {7.5/17, 2.5/17, -2.5/17, 6.5/17, 1.5/17, -1.5/17},
  19. {6.5/17, -1.5/17, -1.5/17, 7.5/17, -2.5/17, -2.5/17},
  20. {7.5/17, 2.5/17, 2.5/17, 8.5/17, 3.5/17, 3.5/17},
  21. {8.5/17, -3.5/17, 3.5/17, 7.5/17, -2.5/17, 2.5/17},
  22. {8.5/17, 3.5/17, -3.5/17, 7.5/17, 2.5/17, -2.5/17},
  23. {7.5/17, -2.5/17, -2.5/17, 8.5/17, -3.5/17, -3.5/17},
  24. }
  25. },
  26. tiles = {"throwing_arrow_build.png", "throwing_arrow_build.png", "throwing_arrow_build_back.png", "throwing_arrow_build_front.png", "throwing_arrow_build_2.png", "throwing_arrow_build.png"},
  27. groups = {not_in_creative_inventory=1},
  28. })
  29. local THROWING_ARROW_ENTITY={
  30. physical = false,
  31. timer=0,
  32. visual = "wielditem",
  33. visual_size = {x=0.1, y=0.1},
  34. textures = {"throwing:arrow_build_box"},
  35. lastpos={},
  36. collisionbox = {0,0,0,0,0,0},
  37. node = "",
  38. }
  39. THROWING_ARROW_ENTITY.on_step = function(self, dtime)
  40. self.timer=self.timer+dtime
  41. local pos = self.object:getpos()
  42. local node = minetest.env:get_node(pos)
  43. if self.timer>0.2 then
  44. local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
  45. for k, obj in pairs(objs) do
  46. if obj:get_luaentity() ~= nil then
  47. if obj:get_luaentity().name ~= "throwing:arrow_build_entity" and obj:get_luaentity().name ~= "__builtin:item" then
  48. if self.node ~= "" then
  49. minetest.env:set_node(self.lastpos, {name=self.node})
  50. end
  51. self.object:remove()
  52. end
  53. else
  54. if self.node ~= "" then
  55. minetest.env:set_node(self.lastpos, {name=self.node})
  56. end
  57. self.object:remove()
  58. end
  59. end
  60. end
  61. if self.lastpos.x~=nil then
  62. if node.name ~= "air" then
  63. if self.node ~= "" then
  64. minetest.env:set_node(self.lastpos, {name=self.node})
  65. end
  66. self.object:remove()
  67. end
  68. end
  69. self.lastpos={x=pos.x, y=pos.y, z=pos.z}
  70. end
  71. minetest.register_entity("throwing:arrow_build_entity", THROWING_ARROW_ENTITY)
  72. minetest.register_craft({
  73. output = 'throwing:arrow_build',
  74. recipe = {
  75. {'default:stick', 'default:stick', 'default:shovel_steel'},
  76. }
  77. })