experiments.lua 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. --------projectile ring wand------
  2. minetest.register_tool("minerdream:magic_wand2", {
  3. description = "".. core.colorize("#BFFFFF", "magic wand2 (testing)\n")..core.colorize("#A0A0A0", "tier: 2 (uncommon)\n")..core.colorize("#A0A0A0", "projectile speed: 15\n")..core.colorize("#A0A0A0", "projectile gravity: 10\n")..core.colorize("#A0A0A0", "ranged damage: 2\n")..core.colorize("#A0A0A0", "mana usage: 5"),
  4. inventory_image = "minerdream_magic_test.png",
  5. wield_scale = {x=0.9,y=0.9,z=0.9},
  6. on_use = function(itemstack, placer, pointed_thing)
  7. if mana.subtract(placer:get_player_name(), 5) then
  8. local dir = placer:get_look_dir();
  9. local playerpos = placer:getpos();
  10. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  11. local vec = {x=20,y=0,z=0}
  12. obj:setvelocity(vec)
  13. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  14. obj:setacceleration(acc)
  15. -----------------------
  16. local dir = placer:get_look_dir();
  17. local playerpos = placer:getpos();
  18. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  19. local vec = {x=-20,y=0,z=0}
  20. obj:setvelocity(vec)
  21. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  22. obj:setacceleration(acc)
  23. -----------------------
  24. local dir = placer:get_look_dir();
  25. local playerpos = placer:getpos();
  26. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  27. local vec = {x=0,y=0,z=20}
  28. obj:setvelocity(vec)
  29. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  30. obj:setacceleration(acc)
  31. -----------------------
  32. local dir = placer:get_look_dir();
  33. local playerpos = placer:getpos();
  34. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  35. local vec = {x=0,y=0,z=-20}
  36. obj:setvelocity(vec)
  37. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  38. obj:setacceleration(acc)
  39. -----------------------
  40. local dir = placer:get_look_dir();
  41. local playerpos = placer:getpos();
  42. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  43. local vec = {x=14,y=0,z=14}
  44. obj:setvelocity(vec)
  45. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  46. obj:setacceleration(acc)
  47. -----------------------
  48. local dir = placer:get_look_dir();
  49. local playerpos = placer:getpos();
  50. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  51. local vec = {x=-14,y=0,z=14}
  52. obj:setvelocity(vec)
  53. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  54. obj:setacceleration(acc)
  55. -----------------------
  56. local dir = placer:get_look_dir();
  57. local playerpos = placer:getpos();
  58. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  59. local vec = {x=14,y=0,z=-14}
  60. obj:setvelocity(vec)
  61. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  62. obj:setacceleration(acc)
  63. -----------------------
  64. local dir = placer:get_look_dir();
  65. local playerpos = placer:getpos();
  66. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  67. local vec = {x=-14,y=0,z=-14}
  68. obj:setvelocity(vec)
  69. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  70. obj:setacceleration(acc)
  71. -----------------------
  72. local dir = placer:get_look_dir();
  73. local playerpos = placer:getpos();
  74. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  75. local vec = {x=18,y=0,z=6}
  76. obj:setvelocity(vec)
  77. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  78. obj:setacceleration(acc)
  79. -----------------------
  80. local dir = placer:get_look_dir();
  81. local playerpos = placer:getpos();
  82. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  83. local vec = {x=6,y=0,z=18}
  84. obj:setvelocity(vec)
  85. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  86. obj:setacceleration(acc)
  87. -----------------------
  88. local dir = placer:get_look_dir();
  89. local playerpos = placer:getpos();
  90. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  91. local vec = {x=-18,y=0,z=6}
  92. obj:setvelocity(vec)
  93. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  94. obj:setacceleration(acc)
  95. -----------------------
  96. local dir = placer:get_look_dir();
  97. local playerpos = placer:getpos();
  98. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  99. local vec = {x=-6,y=0,z=18}
  100. obj:setvelocity(vec)
  101. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  102. obj:setacceleration(acc)
  103. -----------------------
  104. local dir = placer:get_look_dir();
  105. local playerpos = placer:getpos();
  106. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  107. local vec = {x=18,y=0,z=-6}
  108. obj:setvelocity(vec)
  109. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  110. obj:setacceleration(acc)
  111. -----------------------
  112. local dir = placer:get_look_dir();
  113. local playerpos = placer:getpos();
  114. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  115. local vec = {x=6,y=0,z=-18}
  116. obj:setvelocity(vec)
  117. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  118. obj:setacceleration(acc)
  119. -----------------------
  120. local dir = placer:get_look_dir();
  121. local playerpos = placer:getpos();
  122. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  123. local vec = {x=-18,y=0,z=-6}
  124. obj:setvelocity(vec)
  125. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  126. obj:setacceleration(acc)
  127. -----------------------
  128. local dir = placer:get_look_dir();
  129. local playerpos = placer:getpos();
  130. local obj = minetest.env:add_entity({x=playerpos.x+0+dir.x,y=playerpos.y+1.4+dir.y,z=playerpos.z+0+dir.z}, "minerdream:magicring")
  131. local vec = {x=-6,y=0,z=-18}
  132. obj:setvelocity(vec)
  133. local acc = {x=dir.x*0,y=dir.y*0,z=dir.z*0}
  134. obj:setacceleration(acc)
  135. end
  136. return itemstack
  137. end,
  138. })
  139. local minerdream_magicring = {
  140. physical = false,
  141. timer = 0,
  142. visual = "sprite",
  143. visual_size = {x=1.5, y=1.5,},
  144. textures = {'minerdream_magic_ring.png'},
  145. lastpos= {},
  146. collisionbox = {0, 0, 0, 0, 0, 0},
  147. }
  148. minerdream_magicring.on_step = function(self, dtime)
  149. self.timer = self.timer + dtime
  150. local pos = self.object:getpos()
  151. local node = minetest.get_node(pos)
  152. if self.timer > 0.15 then
  153. local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y, z = pos.z}, 1.5)
  154. for k, obj in pairs(objs) do
  155. if obj:get_luaentity() ~= nil then
  156. if obj:get_luaentity().name ~= "minerdream:magicring" and obj:get_luaentity().name ~= "__builtin:item" then
  157. local damage = 2
  158. obj:punch(self.object, 1.0, {
  159. full_punch_interval = 1.0,
  160. damage_groups= {fleshy = damage},
  161. }, nil)
  162. minetest.sound_play("default_dig_cracky", {pos = self.lastpos, gain = 0.8})
  163. end
  164. else
  165. local damage = 2
  166. obj:punch(self.object, 1.0, {
  167. full_punch_interval = 1.0,
  168. damage_groups= {fleshy = damage},
  169. }, nil)
  170. minetest.sound_play("default_dig_cracky", {pos = self.lastpos, gain = 0.8})
  171. end
  172. end
  173. end
  174. if self.lastpos.x ~= nil then
  175. if minetest.registered_nodes[node.name].walkable then
  176. if not minetest.setting_getbool("creative_mode") then
  177. minetest.add_item(self.lastpos, "")
  178. end
  179. minetest.sound_play("default_dig_cracky", {pos = self.lastpos, gain = 0.8})
  180. self.object:remove()
  181. end
  182. end
  183. self.lastpos= {x = pos.x, y = pos.y, z = pos.z}
  184. end
  185. minetest.register_entity("minerdream:magicring", minerdream_magicring )