tools.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. -- mods/default/tools.lua
  2. -- The hand
  3. minetest.register_item(":", {
  4. type = "none",
  5. wield_image = "wieldhand.png",
  6. wield_scale = {x=1,y=1,z=2.5},
  7. tool_capabilities = {
  8. full_punch_interval = 0.9,
  9. max_drop_level = 0,
  10. groupcaps = {
  11. crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
  12. snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
  13. oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.70}, uses=0}
  14. },
  15. damage_groups = {fleshy=1},
  16. }
  17. })
  18. --
  19. -- Picks
  20. --
  21. minetest.register_tool("default:pick_wood", {
  22. description = "Wooden Pickaxe",
  23. inventory_image = "default_tool_woodpick.png",
  24. stack_max = 1,
  25. tool_capabilities = {
  26. full_punch_interval = 1.2,
  27. max_drop_level=0,
  28. groupcaps={
  29. cracky = {times={[3]=1.60}, uses=10, maxlevel=1},
  30. },
  31. damage_groups = {fleshy=2},
  32. },
  33. groups = {flammable = 2},
  34. sound = {breaks = "default_tool_breaks"},
  35. })
  36. minetest.register_tool("default:pick_stone", {
  37. description = "Stone Pickaxe",
  38. inventory_image = "default_tool_stonepick.png",
  39. stack_max = 1,
  40. tool_capabilities = {
  41. full_punch_interval = 1.3,
  42. max_drop_level=0,
  43. groupcaps={
  44. cracky = {times={[2]=2.0, [3]=1.00}, uses=20, maxlevel=1},
  45. },
  46. damage_groups = {fleshy=3},
  47. },
  48. sound = {breaks = "default_tool_breaks"},
  49. })
  50. minetest.register_tool("default:pick_steel", {
  51. description = "Steel Pickaxe",
  52. inventory_image = "default_tool_steelpick.png",
  53. stack_max = 1,
  54. tool_capabilities = {
  55. full_punch_interval = 1.0,
  56. max_drop_level=1,
  57. groupcaps={
  58. cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=20, maxlevel=2},
  59. },
  60. damage_groups = {fleshy=4},
  61. },
  62. sound = {breaks = "default_tool_breaks"},
  63. })
  64. minetest.register_tool("default:pick_bronze", {
  65. description = "Bronze Pickaxe",
  66. inventory_image = "default_tool_bronzepick.png",
  67. stack_max = 1,
  68. tool_capabilities = {
  69. full_punch_interval = 1.0,
  70. max_drop_level=1,
  71. groupcaps={
  72. cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=30, maxlevel=2},
  73. },
  74. damage_groups = {fleshy=4},
  75. },
  76. sound = {breaks = "default_tool_breaks"},
  77. })
  78. minetest.register_tool("default:pick_mese", {
  79. description = "Mese Pickaxe",
  80. inventory_image = "default_tool_mesepick.png",
  81. stack_max = 1,
  82. tool_capabilities = {
  83. full_punch_interval = 0.9,
  84. max_drop_level=3,
  85. groupcaps={
  86. cracky = {times={[1]=2.4, [2]=1.2, [3]=0.60}, uses=20, maxlevel=3},
  87. },
  88. damage_groups = {fleshy=5},
  89. },
  90. sound = {breaks = "default_tool_breaks"},
  91. })
  92. minetest.register_tool("default:pick_diamond", {
  93. description = "Diamond Pickaxe",
  94. inventory_image = "default_tool_diamondpick.png",
  95. stack_max = 1,
  96. tool_capabilities = {
  97. full_punch_interval = 0.9,
  98. max_drop_level=3,
  99. groupcaps={
  100. cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50}, uses=30, maxlevel=3},
  101. },
  102. damage_groups = {fleshy=5},
  103. },
  104. sound = {breaks = "default_tool_breaks"},
  105. })
  106. --
  107. -- Shovels
  108. --
  109. minetest.register_tool("default:shovel_wood", {
  110. description = "Wooden Shovel",
  111. inventory_image = "default_tool_woodshovel.png",
  112. wield_image = "default_tool_woodshovel.png^[transformR90",
  113. stack_max = 1,
  114. tool_capabilities = {
  115. full_punch_interval = 1.2,
  116. max_drop_level=0,
  117. groupcaps={
  118. crumbly = {times={[1]=3.00, [2]=1.60, [3]=0.60}, uses=10, maxlevel=1},
  119. },
  120. damage_groups = {fleshy=2},
  121. },
  122. groups = {flammable = 2},
  123. sound = {breaks = "default_tool_breaks"},
  124. })
  125. minetest.register_tool("default:shovel_stone", {
  126. description = "Stone Shovel",
  127. inventory_image = "default_tool_stoneshovel.png",
  128. wield_image = "default_tool_stoneshovel.png^[transformR90",
  129. stack_max = 1,
  130. tool_capabilities = {
  131. full_punch_interval = 1.4,
  132. max_drop_level=0,
  133. groupcaps={
  134. crumbly = {times={[1]=1.80, [2]=1.20, [3]=0.50}, uses=20, maxlevel=1},
  135. },
  136. damage_groups = {fleshy=2},
  137. },
  138. sound = {breaks = "default_tool_breaks"},
  139. })
  140. minetest.register_tool("default:shovel_steel", {
  141. description = "Steel Shovel",
  142. inventory_image = "default_tool_steelshovel.png",
  143. wield_image = "default_tool_steelshovel.png^[transformR90",
  144. stack_max = 1,
  145. tool_capabilities = {
  146. full_punch_interval = 1.1,
  147. max_drop_level=1,
  148. groupcaps={
  149. crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=30, maxlevel=2},
  150. },
  151. damage_groups = {fleshy=3},
  152. },
  153. sound = {breaks = "default_tool_breaks"},
  154. })
  155. minetest.register_tool("default:shovel_bronze", {
  156. description = "Bronze Shovel",
  157. inventory_image = "default_tool_bronzeshovel.png",
  158. wield_image = "default_tool_bronzeshovel.png^[transformR90",
  159. stack_max = 1,
  160. tool_capabilities = {
  161. full_punch_interval = 1.1,
  162. max_drop_level=1,
  163. groupcaps={
  164. crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=40, maxlevel=2},
  165. },
  166. damage_groups = {fleshy=3},
  167. },
  168. sound = {breaks = "default_tool_breaks"},
  169. })
  170. minetest.register_tool("default:shovel_mese", {
  171. description = "Mese Shovel",
  172. inventory_image = "default_tool_meseshovel.png",
  173. wield_image = "default_tool_meseshovel.png^[transformR90",
  174. stack_max = 1,
  175. tool_capabilities = {
  176. full_punch_interval = 1.0,
  177. max_drop_level=3,
  178. groupcaps={
  179. crumbly = {times={[1]=1.20, [2]=0.60, [3]=0.30}, uses=20, maxlevel=3},
  180. },
  181. damage_groups = {fleshy=4},
  182. },
  183. sound = {breaks = "default_tool_breaks"},
  184. })
  185. minetest.register_tool("default:shovel_diamond", {
  186. description = "Diamond Shovel",
  187. inventory_image = "default_tool_diamondshovel.png",
  188. wield_image = "default_tool_diamondshovel.png^[transformR90",
  189. stack_max = 1,
  190. tool_capabilities = {
  191. full_punch_interval = 1.0,
  192. max_drop_level=1,
  193. groupcaps={
  194. crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30}, uses=30, maxlevel=3},
  195. },
  196. damage_groups = {fleshy=4},
  197. },
  198. sound = {breaks = "default_tool_breaks"},
  199. })
  200. --
  201. -- Axes
  202. --
  203. minetest.register_tool("default:axe_wood", {
  204. description = "Wooden Axe",
  205. inventory_image = "default_tool_woodaxe.png",
  206. stack_max = 1,
  207. tool_capabilities = {
  208. full_punch_interval = 1.0,
  209. max_drop_level=0,
  210. groupcaps={
  211. choppy = {times={[2]=3.00, [3]=1.60}, uses=10, maxlevel=1},
  212. },
  213. damage_groups = {fleshy=2},
  214. },
  215. groups = {flammable = 2},
  216. sound = {breaks = "default_tool_breaks"},
  217. })
  218. minetest.register_tool("default:axe_stone", {
  219. description = "Stone Axe",
  220. inventory_image = "default_tool_stoneaxe.png",
  221. stack_max = 1,
  222. tool_capabilities = {
  223. full_punch_interval = 1.2,
  224. max_drop_level=0,
  225. groupcaps={
  226. choppy={times={[1]=3.00, [2]=2.00, [3]=1.30}, uses=20, maxlevel=1},
  227. },
  228. damage_groups = {fleshy=3},
  229. },
  230. sound = {breaks = "default_tool_breaks"},
  231. })
  232. minetest.register_tool("default:axe_steel", {
  233. description = "Steel Axe",
  234. inventory_image = "default_tool_steelaxe.png",
  235. stack_max = 1,
  236. tool_capabilities = {
  237. full_punch_interval = 1.0,
  238. max_drop_level=1,
  239. groupcaps={
  240. choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=20, maxlevel=2},
  241. },
  242. damage_groups = {fleshy=4},
  243. },
  244. sound = {breaks = "default_tool_breaks"},
  245. })
  246. minetest.register_tool("default:axe_bronze", {
  247. description = "Bronze Axe",
  248. inventory_image = "default_tool_bronzeaxe.png",
  249. stack_max = 1,
  250. tool_capabilities = {
  251. full_punch_interval = 1.0,
  252. max_drop_level=1,
  253. groupcaps={
  254. choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=30, maxlevel=2},
  255. },
  256. damage_groups = {fleshy=4},
  257. },
  258. sound = {breaks = "default_tool_breaks"},
  259. })
  260. minetest.register_tool("default:axe_mese", {
  261. description = "Mese Axe",
  262. inventory_image = "default_tool_meseaxe.png",
  263. stack_max = 1,
  264. tool_capabilities = {
  265. full_punch_interval = 0.9,
  266. max_drop_level=1,
  267. groupcaps={
  268. choppy={times={[1]=2.20, [2]=1.00, [3]=0.60}, uses=20, maxlevel=3},
  269. },
  270. damage_groups = {fleshy=6},
  271. },
  272. sound = {breaks = "default_tool_breaks"},
  273. })
  274. minetest.register_tool("default:axe_diamond", {
  275. description = "Diamond Axe",
  276. inventory_image = "default_tool_diamondaxe.png",
  277. stack_max = 1,
  278. tool_capabilities = {
  279. full_punch_interval = 0.9,
  280. max_drop_level=1,
  281. groupcaps={
  282. choppy={times={[1]=2.10, [2]=0.90, [3]=0.50}, uses=30, maxlevel=3},
  283. },
  284. damage_groups = {fleshy=7},
  285. },
  286. sound = {breaks = "default_tool_breaks"},
  287. })
  288. --
  289. -- Swords
  290. --
  291. minetest.register_tool("default:sword_wood", {
  292. description = "Wooden Sword",
  293. inventory_image = "default_tool_woodsword.png",
  294. stack_max = 1,
  295. tool_capabilities = {
  296. full_punch_interval = 1,
  297. max_drop_level=0,
  298. groupcaps={
  299. snappy={times={[2]=1.6, [3]=0.40}, uses=10, maxlevel=1},
  300. },
  301. damage_groups = {fleshy=2},
  302. },
  303. groups = {flammable = 2},
  304. sound = {breaks = "default_tool_breaks"},
  305. })
  306. minetest.register_tool("default:sword_stone", {
  307. description = "Stone Sword",
  308. inventory_image = "default_tool_stonesword.png",
  309. stack_max = 1,
  310. tool_capabilities = {
  311. full_punch_interval = 1.2,
  312. max_drop_level=0,
  313. groupcaps={
  314. snappy={times={[2]=1.4, [3]=0.40}, uses=20, maxlevel=1},
  315. },
  316. damage_groups = {fleshy=4},
  317. },
  318. sound = {breaks = "default_tool_breaks"},
  319. })
  320. minetest.register_tool("default:sword_steel", {
  321. description = "Steel Sword",
  322. inventory_image = "default_tool_steelsword.png",
  323. stack_max = 1,
  324. tool_capabilities = {
  325. full_punch_interval = 0.8,
  326. max_drop_level=1,
  327. groupcaps={
  328. snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=30, maxlevel=2},
  329. },
  330. damage_groups = {fleshy=6},
  331. },
  332. sound = {breaks = "default_tool_breaks"},
  333. })
  334. minetest.register_tool("default:sword_bronze", {
  335. description = "Bronze Sword",
  336. inventory_image = "default_tool_bronzesword.png",
  337. stack_max = 1,
  338. tool_capabilities = {
  339. full_punch_interval = 0.8,
  340. max_drop_level=1,
  341. groupcaps={
  342. snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=40, maxlevel=2},
  343. },
  344. damage_groups = {fleshy=6},
  345. },
  346. sound = {breaks = "default_tool_breaks"},
  347. })
  348. minetest.register_tool("default:sword_mese", {
  349. description = "Mese Sword",
  350. inventory_image = "default_tool_mesesword.png",
  351. stack_max = 1,
  352. tool_capabilities = {
  353. full_punch_interval = 0.7,
  354. max_drop_level=1,
  355. groupcaps={
  356. snappy={times={[1]=2.0, [2]=1.00, [3]=0.35}, uses=30, maxlevel=3},
  357. },
  358. damage_groups = {fleshy=7},
  359. },
  360. sound = {breaks = "default_tool_breaks"},
  361. })
  362. minetest.register_tool("default:sword_diamond", {
  363. description = "Diamond Sword",
  364. inventory_image = "default_tool_diamondsword.png",
  365. stack_max = 1,
  366. tool_capabilities = {
  367. full_punch_interval = 0.7,
  368. max_drop_level=1,
  369. groupcaps={
  370. snappy={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
  371. },
  372. damage_groups = {fleshy=8},
  373. },
  374. sound = {breaks = "default_tool_breaks"},
  375. })
  376. minetest.register_tool("default:key", {
  377. description = "Key",
  378. inventory_image = "default_key.png",
  379. groups = {key = 1, not_in_creative_inventory = 1},
  380. stack_max = 1,
  381. on_place = function(itemstack, placer, pointed_thing)
  382. local under = pointed_thing.under
  383. local node = minetest.get_node(under)
  384. local def = minetest.registered_nodes[node.name]
  385. if def and def.on_rightclick and
  386. not (placer and placer:is_player() and
  387. placer:get_player_control().sneak) then
  388. return def.on_rightclick(under, node, placer, itemstack,
  389. pointed_thing) or itemstack
  390. end
  391. if pointed_thing.type ~= "node" then
  392. return itemstack
  393. end
  394. local pos = pointed_thing.under
  395. node = minetest.get_node(pos)
  396. if not node or node.name == "ignore" then
  397. return itemstack
  398. end
  399. local ndef = minetest.registered_nodes[node.name]
  400. if not ndef then
  401. return itemstack
  402. end
  403. local on_key_use = ndef.on_key_use
  404. if on_key_use then
  405. on_key_use(pos, placer)
  406. end
  407. return nil
  408. end
  409. })