mithril_bolt.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. minetest.register_craftitem("lottthrowing:bolt_mithril", {
  2. description = "Mithril Bolt",
  3. inventory_image = "lottthrowing_bolt_mithril.png",
  4. })
  5. minetest.register_node("lottthrowing:bolt_mithril_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 = {"lottthrowing_bolt_mithril.png", "lottthrowing_bolt_mithril.png", "lottthrowing_bolt_mithril_back.png", "lottthrowing_bolt_mithril_front.png", "lottthrowing_bolt_mithril_2.png", "lottthrowing_bolt_mithril.png"},
  27. groups = {not_in_creative_inventory=1},
  28. })
  29. local THROWING_BOLT_ENTITY={
  30. physical = false,
  31. timer=0,
  32. visual = "wielditem",
  33. visual_size = {x=0.1, y=0.1},
  34. textures = {"lottthrowing:bolt_mithril_box"},
  35. lastpos={},
  36. collisionbox = {0,0,0,0,0,0},
  37. player = nil,
  38. }
  39. THROWING_BOLT_ENTITY.on_step = function(self, dtime)
  40. self.timer=self.timer+dtime
  41. local pos = self.object:getpos()
  42. local node = minetest.get_node(pos)
  43. if self.timer>0.2 then
  44. local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 2)
  45. for k, obj in pairs(objs) do
  46. if obj:get_luaentity() ~= nil then
  47. if obj:get_luaentity().name ~= "lottthrowing:bolt_mithril_entity" and obj:get_luaentity().name ~= "__builtin:item" then
  48. local damage = 20
  49. obj:punch(self.player, 1.0, {
  50. full_punch_interval=1.0,
  51. damage_groups={fleshy=damage},
  52. }, nil)
  53. self.object:remove()
  54. end
  55. else
  56. local damage = 20
  57. obj:punch(self.player, 1.0, {
  58. full_punch_interval=1.0,
  59. damage_groups={fleshy=damage},
  60. }, nil)
  61. self.object:remove()
  62. end
  63. end
  64. end
  65. if self.lastpos.x~=nil then
  66. if node.name ~= "air" then
  67. minetest.add_item(self.lastpos, 'lottthrowing:bolt_mithril')
  68. self.object:remove()
  69. end
  70. end
  71. self.lastpos={x=pos.x, y=pos.y, z=pos.z}
  72. end
  73. minetest.register_entity("lottthrowing:bolt_mithril_entity", THROWING_BOLT_ENTITY)
  74. minetest.register_craft({
  75. output = 'lottthrowing:bolt_mithril 16',
  76. recipe = {
  77. {'default:steel_ingot', 'lottores:mithril_ingot'},
  78. }
  79. })