tools.lua 12 KB

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