tools.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. -- mods/default/tools.lua
  2. -- support for MT game translation.
  3. local S = default.get_translator
  4. -- The hand
  5. minetest.register_item(":", {
  6. type = "none",
  7. wield_image = "wieldhand.png",
  8. wield_scale = {x=1,y=1,z=2.5},
  9. tool_capabilities = {
  10. full_punch_interval = 0.9,
  11. max_drop_level = 0,
  12. groupcaps = {
  13. crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
  14. snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
  15. oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.70}, uses=0}
  16. },
  17. damage_groups = {fleshy=1},
  18. }
  19. })
  20. --
  21. -- Picks
  22. --
  23. minetest.register_tool("default:pick_wood", {
  24. description = S("Wooden Pickaxe"),
  25. inventory_image = "default_tool_woodpick.png",
  26. tool_capabilities = {
  27. full_punch_interval = 1.2,
  28. max_drop_level=0,
  29. groupcaps={
  30. cracky = {times={[3]=1.60}, uses=10, maxlevel=1},
  31. },
  32. damage_groups = {fleshy=2},
  33. },
  34. sound = {breaks = "default_tool_breaks"},
  35. groups = {pickaxe = 1, flammable = 2}
  36. })
  37. minetest.register_tool("default:pick_stone", {
  38. description = S("Stone Pickaxe"),
  39. inventory_image = "default_tool_stonepick.png",
  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. groups = {pickaxe = 1}
  50. })
  51. minetest.register_tool("default:pick_bronze", {
  52. description = S("Bronze Pickaxe"),
  53. inventory_image = "default_tool_bronzepick.png",
  54. tool_capabilities = {
  55. full_punch_interval = 1.0,
  56. max_drop_level=1,
  57. groupcaps={
  58. cracky = {times={[1]=4.50, [2]=1.80, [3]=0.90}, uses=20, maxlevel=2},
  59. },
  60. damage_groups = {fleshy=4},
  61. },
  62. sound = {breaks = "default_tool_breaks"},
  63. groups = {pickaxe = 1}
  64. })
  65. minetest.register_tool("default:pick_steel", {
  66. description = S("Steel Pickaxe"),
  67. inventory_image = "default_tool_steelpick.png",
  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=20, maxlevel=2},
  73. },
  74. damage_groups = {fleshy=4},
  75. },
  76. sound = {breaks = "default_tool_breaks"},
  77. groups = {pickaxe = 1}
  78. })
  79. minetest.register_tool("default:pick_mese", {
  80. description = S("Mese Pickaxe"),
  81. inventory_image = "default_tool_mesepick.png",
  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. groups = {pickaxe = 1}
  92. })
  93. minetest.register_tool("default:pick_diamond", {
  94. description = S("Diamond Pickaxe"),
  95. inventory_image = "default_tool_diamondpick.png",
  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. groups = {pickaxe = 1}
  106. })
  107. --
  108. -- Shovels
  109. --
  110. minetest.register_tool("default:shovel_wood", {
  111. description = S("Wooden Shovel"),
  112. inventory_image = "default_tool_woodshovel.png",
  113. wield_image = "default_tool_woodshovel.png^[transformR90",
  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. sound = {breaks = "default_tool_breaks"},
  123. groups = {shovel = 1, flammable = 2}
  124. })
  125. minetest.register_tool("default:shovel_stone", {
  126. description = S("Stone Shovel"),
  127. inventory_image = "default_tool_stoneshovel.png",
  128. wield_image = "default_tool_stoneshovel.png^[transformR90",
  129. tool_capabilities = {
  130. full_punch_interval = 1.4,
  131. max_drop_level=0,
  132. groupcaps={
  133. crumbly = {times={[1]=1.80, [2]=1.20, [3]=0.50}, uses=20, maxlevel=1},
  134. },
  135. damage_groups = {fleshy=2},
  136. },
  137. sound = {breaks = "default_tool_breaks"},
  138. groups = {shovel = 1}
  139. })
  140. minetest.register_tool("default:shovel_bronze", {
  141. description = S("Bronze Shovel"),
  142. inventory_image = "default_tool_bronzeshovel.png",
  143. wield_image = "default_tool_bronzeshovel.png^[transformR90",
  144. tool_capabilities = {
  145. full_punch_interval = 1.1,
  146. max_drop_level=1,
  147. groupcaps={
  148. crumbly = {times={[1]=1.65, [2]=1.05, [3]=0.45}, uses=25, maxlevel=2},
  149. },
  150. damage_groups = {fleshy=3},
  151. },
  152. sound = {breaks = "default_tool_breaks"},
  153. groups = {shovel = 1}
  154. })
  155. minetest.register_tool("default:shovel_steel", {
  156. description = S("Steel Shovel"),
  157. inventory_image = "default_tool_steelshovel.png",
  158. wield_image = "default_tool_steelshovel.png^[transformR90",
  159. tool_capabilities = {
  160. full_punch_interval = 1.1,
  161. max_drop_level=1,
  162. groupcaps={
  163. crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=30, maxlevel=2},
  164. },
  165. damage_groups = {fleshy=3},
  166. },
  167. sound = {breaks = "default_tool_breaks"},
  168. groups = {shovel = 1}
  169. })
  170. minetest.register_tool("default:shovel_mese", {
  171. description = S("Mese Shovel"),
  172. inventory_image = "default_tool_meseshovel.png",
  173. wield_image = "default_tool_meseshovel.png^[transformR90",
  174. tool_capabilities = {
  175. full_punch_interval = 1.0,
  176. max_drop_level=3,
  177. groupcaps={
  178. crumbly = {times={[1]=1.20, [2]=0.60, [3]=0.30}, uses=20, maxlevel=3},
  179. },
  180. damage_groups = {fleshy=4},
  181. },
  182. sound = {breaks = "default_tool_breaks"},
  183. groups = {shovel = 1}
  184. })
  185. minetest.register_tool("default:shovel_diamond", {
  186. description = S("Diamond Shovel"),
  187. inventory_image = "default_tool_diamondshovel.png",
  188. wield_image = "default_tool_diamondshovel.png^[transformR90",
  189. tool_capabilities = {
  190. full_punch_interval = 1.0,
  191. max_drop_level=1,
  192. groupcaps={
  193. crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30}, uses=30, maxlevel=3},
  194. },
  195. damage_groups = {fleshy=4},
  196. },
  197. sound = {breaks = "default_tool_breaks"},
  198. groups = {shovel = 1}
  199. })
  200. --
  201. -- Axes
  202. --
  203. minetest.register_tool("default:axe_wood", {
  204. description = S("Wooden Axe"),
  205. inventory_image = "default_tool_woodaxe.png",
  206. tool_capabilities = {
  207. full_punch_interval = 1.0,
  208. max_drop_level=0,
  209. groupcaps={
  210. choppy = {times={[2]=3.00, [3]=1.60}, uses=10, maxlevel=1},
  211. },
  212. damage_groups = {fleshy=2},
  213. },
  214. sound = {breaks = "default_tool_breaks"},
  215. groups = {axe = 1, flammable = 2}
  216. })
  217. minetest.register_tool("default:axe_stone", {
  218. description = S("Stone Axe"),
  219. inventory_image = "default_tool_stoneaxe.png",
  220. tool_capabilities = {
  221. full_punch_interval = 1.2,
  222. max_drop_level=0,
  223. groupcaps={
  224. choppy={times={[1]=3.00, [2]=2.00, [3]=1.30}, uses=20, maxlevel=1},
  225. },
  226. damage_groups = {fleshy=3},
  227. },
  228. sound = {breaks = "default_tool_breaks"},
  229. groups = {axe = 1}
  230. })
  231. minetest.register_tool("default:axe_bronze", {
  232. description = S("Bronze Axe"),
  233. inventory_image = "default_tool_bronzeaxe.png",
  234. tool_capabilities = {
  235. full_punch_interval = 1.0,
  236. max_drop_level=1,
  237. groupcaps={
  238. choppy={times={[1]=2.75, [2]=1.70, [3]=1.15}, uses=20, maxlevel=2},
  239. },
  240. damage_groups = {fleshy=4},
  241. },
  242. sound = {breaks = "default_tool_breaks"},
  243. groups = {axe = 1}
  244. })
  245. minetest.register_tool("default:axe_steel", {
  246. description = S("Steel Axe"),
  247. inventory_image = "default_tool_steelaxe.png",
  248. tool_capabilities = {
  249. full_punch_interval = 1.0,
  250. max_drop_level=1,
  251. groupcaps={
  252. choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=20, maxlevel=2},
  253. },
  254. damage_groups = {fleshy=4},
  255. },
  256. sound = {breaks = "default_tool_breaks"},
  257. groups = {axe = 1}
  258. })
  259. minetest.register_tool("default:axe_mese", {
  260. description = S("Mese Axe"),
  261. inventory_image = "default_tool_meseaxe.png",
  262. tool_capabilities = {
  263. full_punch_interval = 0.9,
  264. max_drop_level=1,
  265. groupcaps={
  266. choppy={times={[1]=2.20, [2]=1.00, [3]=0.60}, uses=20, maxlevel=3},
  267. },
  268. damage_groups = {fleshy=6},
  269. },
  270. sound = {breaks = "default_tool_breaks"},
  271. groups = {axe = 1}
  272. })
  273. minetest.register_tool("default:axe_diamond", {
  274. description = S("Diamond Axe"),
  275. inventory_image = "default_tool_diamondaxe.png",
  276. tool_capabilities = {
  277. full_punch_interval = 0.9,
  278. max_drop_level=1,
  279. groupcaps={
  280. choppy={times={[1]=2.10, [2]=0.90, [3]=0.50}, uses=30, maxlevel=3},
  281. },
  282. damage_groups = {fleshy=7},
  283. },
  284. sound = {breaks = "default_tool_breaks"},
  285. groups = {axe = 1}
  286. })
  287. --
  288. -- Swords
  289. --
  290. minetest.register_tool("default:sword_wood", {
  291. description = S("Wooden Sword"),
  292. inventory_image = "default_tool_woodsword.png",
  293. tool_capabilities = {
  294. full_punch_interval = 1,
  295. max_drop_level=0,
  296. groupcaps={
  297. snappy={times={[2]=1.6, [3]=0.40}, uses=10, maxlevel=1},
  298. },
  299. damage_groups = {fleshy=2},
  300. },
  301. sound = {breaks = "default_tool_breaks"},
  302. groups = {sword = 1, flammable = 2}
  303. })
  304. minetest.register_tool("default:sword_stone", {
  305. description = S("Stone Sword"),
  306. inventory_image = "default_tool_stonesword.png",
  307. tool_capabilities = {
  308. full_punch_interval = 1.2,
  309. max_drop_level=0,
  310. groupcaps={
  311. snappy={times={[2]=1.4, [3]=0.40}, uses=20, maxlevel=1},
  312. },
  313. damage_groups = {fleshy=4},
  314. },
  315. sound = {breaks = "default_tool_breaks"},
  316. groups = {sword = 1}
  317. })
  318. minetest.register_tool("default:sword_bronze", {
  319. description = S("Bronze Sword"),
  320. inventory_image = "default_tool_bronzesword.png",
  321. tool_capabilities = {
  322. full_punch_interval = 0.8,
  323. max_drop_level=1,
  324. groupcaps={
  325. snappy={times={[1]=2.75, [2]=1.30, [3]=0.375}, uses=25, maxlevel=2},
  326. },
  327. damage_groups = {fleshy=6},
  328. },
  329. sound = {breaks = "default_tool_breaks"},
  330. groups = {sword = 1}
  331. })
  332. minetest.register_tool("default:sword_steel", {
  333. description = S("Steel Sword"),
  334. inventory_image = "default_tool_steelsword.png",
  335. tool_capabilities = {
  336. full_punch_interval = 0.8,
  337. max_drop_level=1,
  338. groupcaps={
  339. snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=30, maxlevel=2},
  340. },
  341. damage_groups = {fleshy=6},
  342. },
  343. sound = {breaks = "default_tool_breaks"},
  344. groups = {sword = 1}
  345. })
  346. minetest.register_tool("default:sword_mese", {
  347. description = S("Mese Sword"),
  348. inventory_image = "default_tool_mesesword.png",
  349. tool_capabilities = {
  350. full_punch_interval = 0.7,
  351. max_drop_level=1,
  352. groupcaps={
  353. snappy={times={[1]=2.0, [2]=1.00, [3]=0.35}, uses=30, maxlevel=3},
  354. },
  355. damage_groups = {fleshy=7},
  356. },
  357. sound = {breaks = "default_tool_breaks"},
  358. groups = {sword = 1}
  359. })
  360. minetest.register_tool("default:sword_diamond", {
  361. description = S("Diamond Sword"),
  362. inventory_image = "default_tool_diamondsword.png",
  363. tool_capabilities = {
  364. full_punch_interval = 0.7,
  365. max_drop_level=1,
  366. groupcaps={
  367. snappy={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
  368. },
  369. damage_groups = {fleshy=8},
  370. },
  371. sound = {breaks = "default_tool_breaks"},
  372. groups = {sword = 1}
  373. })
  374. --
  375. -- Register Craft Recipies
  376. --
  377. local craft_ingreds = {
  378. wood = "group:wood",
  379. stone = "group:stone",
  380. steel = "default:steel_ingot",
  381. bronze = "default:bronze_ingot",
  382. mese = "default:mese_crystal",
  383. diamond = "default:diamond"
  384. }
  385. for name, mat in pairs(craft_ingreds) do
  386. minetest.register_craft({
  387. output = "default:pick_".. name,
  388. recipe = {
  389. {mat, mat, mat},
  390. {"", "group:stick", ""},
  391. {"", "group:stick", ""}
  392. }
  393. })
  394. minetest.register_craft({
  395. output = "default:shovel_".. name,
  396. recipe = {
  397. {mat},
  398. {"group:stick"},
  399. {"group:stick"}
  400. }
  401. })
  402. minetest.register_craft({
  403. output = "default:axe_".. name,
  404. recipe = {
  405. {mat, mat},
  406. {mat, "group:stick"},
  407. {"", "group:stick"}
  408. }
  409. })
  410. minetest.register_craft({
  411. output = "default:sword_".. name,
  412. recipe = {
  413. {mat},
  414. {mat},
  415. {"group:stick"}
  416. }
  417. })
  418. end
  419. minetest.register_tool("default:key", {
  420. description = S("Key"),
  421. inventory_image = "default_key.png",
  422. groups = {key = 1, not_in_creative_inventory = 1},
  423. stack_max = 1,
  424. on_place = function(itemstack, placer, pointed_thing)
  425. local under = pointed_thing.under
  426. local node = minetest.get_node(under)
  427. local def = minetest.registered_nodes[node.name]
  428. if def and def.on_rightclick and
  429. not (placer and placer:is_player() and
  430. placer:get_player_control().sneak) then
  431. return def.on_rightclick(under, node, placer, itemstack,
  432. pointed_thing) or itemstack
  433. end
  434. if pointed_thing.type ~= "node" then
  435. return itemstack
  436. end
  437. local pos = pointed_thing.under
  438. node = minetest.get_node(pos)
  439. if not node or node.name == "ignore" then
  440. return itemstack
  441. end
  442. local ndef = minetest.registered_nodes[node.name]
  443. if not ndef then
  444. return itemstack
  445. end
  446. local on_key_use = ndef.on_key_use
  447. if on_key_use then
  448. on_key_use(pos, placer)
  449. end
  450. return nil
  451. end
  452. })
  453. minetest.register_craft({
  454. type = "fuel",
  455. recipe = "default:pick_wood",
  456. burntime = 6,
  457. })
  458. minetest.register_craft({
  459. type = "fuel",
  460. recipe = "default:shovel_wood",
  461. burntime = 4,
  462. })
  463. minetest.register_craft({
  464. type = "fuel",
  465. recipe = "default:axe_wood",
  466. burntime = 6,
  467. })
  468. minetest.register_craft({
  469. type = "fuel",
  470. recipe = "default:sword_wood",
  471. burntime = 5,
  472. })