tools.lua 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. -- mods/default/tools.lua
  2. local place_tool = function(itemstack, direction, meta1, meta2, pt, tool)
  3. -- minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:" .. tool .. "_deco", param2=direction})
  4. -- meta1:set_int("wear", itemstack:get_wear())
  5. -- meta2:set_int("wear", itemstack:get_wear())
  6. -- itemstack:take_item()
  7. return itemstack
  8. end
  9. -- The hand
  10. minetest.register_item(":", {
  11. type = "none",
  12. wield_image = "wieldhand.png",
  13. wield_scale = {x=1,y=1,z=2.5},
  14. tool_capabilities = {
  15. full_punch_interval = 0.9,
  16. max_drop_level = 0,
  17. groupcaps = {
  18. crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
  19. snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
  20. oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.70}, uses=0}
  21. },
  22. damage_groups = {fleshy=1},
  23. }
  24. })
  25. --
  26. -- Picks
  27. --
  28. minetest.register_tool("default:pick_wood", {
  29. description = "Wooden Pickaxe",
  30. inventory_image = "default_tool_woodpick.png",
  31. tool_capabilities = {
  32. full_punch_interval = 1.2,
  33. max_drop_level=0,
  34. groupcaps={
  35. cracky = {times={[3]=1.60}, uses=10, maxlevel=1},
  36. },
  37. damage_groups = {fleshy=2},
  38. },
  39. sound = {breaks = "default_tool_breaks"},
  40. on_place = function(itemstack, placer, pointed_thing)
  41. local pt = pointed_thing
  42. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  43. local wear = itemstack:get_wear()
  44. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  45. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  46. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  47. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:pick_wood_deco", param2=direction})
  48. meta1:set_int("wear", wear)
  49. meta2:set_int("wear", wear)
  50. itemstack:take_item()
  51. return itemstack
  52. end
  53. end,
  54. })
  55. minetest.register_tool("default:pick_stone", {
  56. description = "Stone Pickaxe",
  57. inventory_image = "default_tool_stonepick.png",
  58. tool_capabilities = {
  59. full_punch_interval = 1.3,
  60. max_drop_level=0,
  61. groupcaps={
  62. cracky = {times={[2]=2.0, [3]=1.00}, uses=20, maxlevel=1},
  63. },
  64. damage_groups = {fleshy=3},
  65. },
  66. sound = {breaks = "default_tool_breaks"},
  67. on_place = function(itemstack, placer, pointed_thing)
  68. local pt = pointed_thing
  69. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  70. local wear = itemstack:get_wear()
  71. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  72. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  73. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  74. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:pick_stone_deco", param2=direction})
  75. meta1:set_int("wear", wear)
  76. meta2:set_int("wear", wear)
  77. itemstack:take_item()
  78. return itemstack
  79. end
  80. end,
  81. })
  82. minetest.register_tool("default:pick_steel", {
  83. description = "Steel Pickaxe",
  84. inventory_image = "default_tool_steelpick.png",
  85. tool_capabilities = {
  86. full_punch_interval = 1.0,
  87. max_drop_level=1,
  88. groupcaps={
  89. cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=20, maxlevel=2},
  90. },
  91. damage_groups = {fleshy=4},
  92. },
  93. sound = {breaks = "default_tool_breaks"},
  94. on_place = function(itemstack, placer, pointed_thing)
  95. local pt = pointed_thing
  96. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  97. local wear = itemstack:get_wear()
  98. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  99. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  100. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  101. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:pick_steel_deco", param2=direction})
  102. meta1:set_int("wear", wear)
  103. meta2:set_int("wear", wear)
  104. itemstack:take_item()
  105. return itemstack
  106. end
  107. end,
  108. })
  109. minetest.register_tool("default:pick_bronze", {
  110. description = "Bronze Pickaxe",
  111. inventory_image = "default_tool_bronzepick.png",
  112. tool_capabilities = {
  113. full_punch_interval = 1.0,
  114. max_drop_level=1,
  115. groupcaps={
  116. cracky = {times={[1]=4.00, [2]=1.60, [3]=0.80}, uses=30, maxlevel=2},
  117. },
  118. damage_groups = {fleshy=4},
  119. },
  120. sound = {breaks = "default_tool_breaks"},
  121. on_place = function(itemstack, placer, pointed_thing)
  122. local pt = pointed_thing
  123. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  124. local wear = itemstack:get_wear()
  125. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  126. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  127. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  128. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:pick_bronze_deco", param2=direction})
  129. meta1:set_int("wear", wear)
  130. meta2:set_int("wear", wear)
  131. itemstack:take_item()
  132. return itemstack
  133. end
  134. end,
  135. })
  136. minetest.register_tool("default:pick_mese", {
  137. description = "Mese Pickaxe",
  138. inventory_image = "default_tool_mesepick.png",
  139. tool_capabilities = {
  140. full_punch_interval = 0.9,
  141. max_drop_level=3,
  142. groupcaps={
  143. cracky = {times={[1]=2.4, [2]=1.2, [3]=0.60}, uses=20, maxlevel=3},
  144. },
  145. damage_groups = {fleshy=5},
  146. },
  147. sound = {breaks = "default_tool_breaks"},
  148. on_place = function(itemstack, placer, pointed_thing)
  149. local pt = pointed_thing
  150. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  151. local wear = itemstack:get_wear()
  152. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  153. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  154. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  155. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:pick_mese_deco", param2=direction})
  156. meta1:set_int("wear", wear)
  157. meta2:set_int("wear", wear)
  158. itemstack:take_item()
  159. return itemstack
  160. end
  161. end,
  162. })
  163. minetest.register_tool("default:pick_diamond", {
  164. description = "Diamond Pickaxe",
  165. inventory_image = "default_tool_diamondpick.png",
  166. tool_capabilities = {
  167. full_punch_interval = 0.9,
  168. max_drop_level=3,
  169. groupcaps={
  170. cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50}, uses=30, maxlevel=3},
  171. },
  172. damage_groups = {fleshy=5},
  173. },
  174. sound = {breaks = "default_tool_breaks"},
  175. on_place = function(itemstack, placer, pointed_thing)
  176. local pt = pointed_thing
  177. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  178. local wear = itemstack:get_wear()
  179. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  180. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  181. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  182. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:pick_diamond_deco", param2=direction})
  183. meta1:set_int("wear", wear)
  184. meta2:set_int("wear", wear)
  185. itemstack:take_item()
  186. return itemstack
  187. end
  188. end,
  189. })
  190. --
  191. -- Shovels
  192. --
  193. minetest.register_tool("default:shovel_wood", {
  194. description = "Wooden Shovel",
  195. inventory_image = "default_tool_woodshovel.png",
  196. wield_image = "default_tool_woodshovel.png^[transformR90",
  197. tool_capabilities = {
  198. full_punch_interval = 1.2,
  199. max_drop_level=0,
  200. groupcaps={
  201. crumbly = {times={[1]=3.00, [2]=1.60, [3]=0.60}, uses=10, maxlevel=1},
  202. },
  203. damage_groups = {fleshy=2},
  204. },
  205. groups = {flammable = 2},
  206. sound = {breaks = "default_tool_breaks"},
  207. on_place = function(itemstack, placer, pointed_thing)
  208. local pt = pointed_thing
  209. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  210. local wear = itemstack:get_wear()
  211. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  212. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  213. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  214. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:shovel_wood_deco", param2=direction})
  215. meta1:set_int("wear", wear)
  216. meta2:set_int("wear", wear)
  217. itemstack:take_item()
  218. return itemstack
  219. end
  220. end,
  221. })
  222. minetest.register_tool("default:shovel_stone", {
  223. description = "Stone Shovel",
  224. inventory_image = "default_tool_stoneshovel.png",
  225. wield_image = "default_tool_stoneshovel.png^[transformR90",
  226. tool_capabilities = {
  227. full_punch_interval = 1.4,
  228. max_drop_level=0,
  229. groupcaps={
  230. crumbly = {times={[1]=1.80, [2]=1.20, [3]=0.50}, uses=20, maxlevel=1},
  231. },
  232. damage_groups = {fleshy=2},
  233. },
  234. sound = {breaks = "default_tool_breaks"},
  235. on_place = function(itemstack, placer, pointed_thing)
  236. local pt = pointed_thing
  237. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  238. local wear = itemstack:get_wear()
  239. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  240. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  241. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  242. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:shovel_stone_deco", param2=direction})
  243. meta1:set_int("wear", wear)
  244. meta2:set_int("wear", wear)
  245. itemstack:take_item()
  246. return itemstack
  247. end
  248. end,
  249. })
  250. minetest.register_tool("default:shovel_steel", {
  251. description = "Steel Shovel",
  252. inventory_image = "default_tool_steelshovel.png",
  253. wield_image = "default_tool_steelshovel.png^[transformR90",
  254. tool_capabilities = {
  255. full_punch_interval = 1.1,
  256. max_drop_level=1,
  257. groupcaps={
  258. crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=30, maxlevel=2},
  259. },
  260. damage_groups = {fleshy=3},
  261. },
  262. sound = {breaks = "default_tool_breaks"},
  263. on_place = function(itemstack, placer, pointed_thing)
  264. local pt = pointed_thing
  265. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  266. local wear = itemstack:get_wear()
  267. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  268. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  269. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  270. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:shovel_stone_deco", param2=direction})
  271. meta1:set_int("wear", wear)
  272. meta2:set_int("wear", wear)
  273. itemstack:take_item()
  274. return itemstack
  275. end
  276. end,
  277. on_place = function(itemstack, placer, pointed_thing)
  278. place_tool(itemstack, minetest.dir_to_facedir(placer:get_look_dir()),
  279. minetest.env:get_meta({x=pointed_thing.under.x, y=pointed_thing.under.y , z=pointed_thing.under.z}),
  280. minetest.env:get_meta({x=pointed_thing.under.x, y=pointed_thing.under.y+1, z=pointed_thing.under.z}),
  281. pointed_thing, "shovel_steel");
  282. end,
  283. })
  284. minetest.register_tool("default:shovel_bronze", {
  285. description = "Bronze Shovel",
  286. inventory_image = "default_tool_bronzeshovel.png",
  287. wield_image = "default_tool_bronzeshovel.png^[transformR90",
  288. tool_capabilities = {
  289. full_punch_interval = 1.1,
  290. max_drop_level=1,
  291. groupcaps={
  292. crumbly = {times={[1]=1.50, [2]=0.90, [3]=0.40}, uses=40, maxlevel=2},
  293. },
  294. damage_groups = {fleshy=3},
  295. },
  296. sound = {breaks = "default_tool_breaks"},
  297. on_place = function(itemstack, placer, pointed_thing)
  298. local pt = pointed_thing
  299. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  300. local wear = itemstack:get_wear()
  301. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  302. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  303. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  304. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:shovel_bronze_deco", param2=direction})
  305. meta1:set_int("wear", wear)
  306. meta2:set_int("wear", wear)
  307. itemstack:take_item()
  308. return itemstack
  309. end
  310. end,
  311. })
  312. minetest.register_tool("default:shovel_mese", {
  313. description = "Mese Shovel",
  314. inventory_image = "default_tool_meseshovel.png",
  315. wield_image = "default_tool_meseshovel.png^[transformR90",
  316. tool_capabilities = {
  317. full_punch_interval = 1.0,
  318. max_drop_level=3,
  319. groupcaps={
  320. crumbly = {times={[1]=1.20, [2]=0.60, [3]=0.30}, uses=20, maxlevel=3},
  321. },
  322. damage_groups = {fleshy=4},
  323. },
  324. sound = {breaks = "default_tool_breaks"},
  325. on_place = function(itemstack, placer, pointed_thing)
  326. local pt = pointed_thing
  327. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  328. local wear = itemstack:get_wear()
  329. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  330. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  331. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  332. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:shovel_mese_deco", param2=direction})
  333. meta1:set_int("wear", wear)
  334. meta2:set_int("wear", wear)
  335. itemstack:take_item()
  336. return itemstack
  337. end
  338. end,
  339. })
  340. minetest.register_tool("default:shovel_diamond", {
  341. description = "Diamond Shovel",
  342. inventory_image = "default_tool_diamondshovel.png",
  343. wield_image = "default_tool_diamondshovel.png^[transformR90",
  344. tool_capabilities = {
  345. full_punch_interval = 1.0,
  346. max_drop_level=1,
  347. groupcaps={
  348. crumbly = {times={[1]=1.10, [2]=0.50, [3]=0.30}, uses=30, maxlevel=3},
  349. },
  350. damage_groups = {fleshy=4},
  351. },
  352. sound = {breaks = "default_tool_breaks"},
  353. on_place = function(itemstack, placer, pointed_thing)
  354. local pt = pointed_thing
  355. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  356. local wear = itemstack:get_wear()
  357. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  358. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  359. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  360. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:shovel_diamond_deco", param2=direction})
  361. meta1:set_int("wear", wear)
  362. meta2:set_int("wear", wear)
  363. itemstack:take_item()
  364. return itemstack
  365. end
  366. end,
  367. })
  368. --
  369. -- Axes
  370. --
  371. minetest.register_tool("default:axe_wood", {
  372. description = "Wooden Axe",
  373. inventory_image = "default_tool_woodaxe.png",
  374. tool_capabilities = {
  375. full_punch_interval = 1.0,
  376. max_drop_level=0,
  377. groupcaps={
  378. choppy = {times={[2]=3.00, [3]=1.60}, uses=10, maxlevel=1},
  379. },
  380. damage_groups = {fleshy=2},
  381. },
  382. groups = {flammable = 2},
  383. sound = {breaks = "default_tool_breaks"},
  384. on_place = function(itemstack, placer, pointed_thing)
  385. local pt = pointed_thing
  386. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  387. local wear = itemstack:get_wear()
  388. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  389. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  390. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  391. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:axe_wood_deco", param2=direction})
  392. meta1:set_int("wear", wear)
  393. meta2:set_int("wear", wear)
  394. itemstack:take_item()
  395. return itemstack
  396. end
  397. end,
  398. })
  399. minetest.register_tool("default:axe_stone", {
  400. description = "Stone Axe",
  401. inventory_image = "default_tool_stoneaxe.png",
  402. tool_capabilities = {
  403. full_punch_interval = 1.2,
  404. max_drop_level=0,
  405. groupcaps={
  406. choppy={times={[1]=3.00, [2]=2.00, [3]=1.30}, uses=20, maxlevel=1},
  407. },
  408. damage_groups = {fleshy=3},
  409. },
  410. sound = {breaks = "default_tool_breaks"},
  411. on_place = function(itemstack, placer, pointed_thing)
  412. local pt = pointed_thing
  413. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  414. local wear = itemstack:get_wear()
  415. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  416. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  417. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  418. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:axe_stone_deco", param2=direction})
  419. meta1:set_int("wear", wear)
  420. meta2:set_int("wear", wear)
  421. itemstack:take_item()
  422. return itemstack
  423. end
  424. end,
  425. })
  426. minetest.register_tool("default:axe_steel", {
  427. description = "Steel Axe",
  428. inventory_image = "default_tool_steelaxe.png",
  429. tool_capabilities = {
  430. full_punch_interval = 1.0,
  431. max_drop_level=1,
  432. groupcaps={
  433. choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=20, maxlevel=2},
  434. },
  435. damage_groups = {fleshy=4},
  436. },
  437. sound = {breaks = "default_tool_breaks"},
  438. on_place = function(itemstack, placer, pointed_thing)
  439. local pt = pointed_thing
  440. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  441. local wear = itemstack:get_wear()
  442. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  443. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  444. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  445. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:axe_steel_deco", param2=direction})
  446. meta1:set_int("wear", wear)
  447. meta2:set_int("wear", wear)
  448. itemstack:take_item()
  449. return itemstack
  450. end
  451. end,
  452. })
  453. minetest.register_tool("default:axe_bronze", {
  454. description = "Bronze Axe",
  455. inventory_image = "default_tool_bronzeaxe.png",
  456. tool_capabilities = {
  457. full_punch_interval = 1.0,
  458. max_drop_level=1,
  459. groupcaps={
  460. choppy={times={[1]=2.50, [2]=1.40, [3]=1.00}, uses=30, maxlevel=2},
  461. },
  462. damage_groups = {fleshy=4},
  463. },
  464. sound = {breaks = "default_tool_breaks"},
  465. on_place = function(itemstack, placer, pointed_thing)
  466. local pt = pointed_thing
  467. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  468. local wear = itemstack:get_wear()
  469. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  470. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  471. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  472. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:axe_bronze_deco", param2=direction})
  473. meta1:set_int("wear", wear)
  474. meta2:set_int("wear", wear)
  475. itemstack:take_item()
  476. return itemstack
  477. end
  478. end,
  479. })
  480. minetest.register_tool("default:axe_mese", {
  481. description = "Mese Axe",
  482. inventory_image = "default_tool_meseaxe.png",
  483. tool_capabilities = {
  484. full_punch_interval = 0.9,
  485. max_drop_level=1,
  486. groupcaps={
  487. choppy={times={[1]=2.20, [2]=1.00, [3]=0.60}, uses=20, maxlevel=3},
  488. },
  489. damage_groups = {fleshy=6},
  490. },
  491. sound = {breaks = "default_tool_breaks"},
  492. on_place = function(itemstack, placer, pointed_thing)
  493. local pt = pointed_thing
  494. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  495. local wear = itemstack:get_wear()
  496. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  497. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  498. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  499. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:axe_mese_deco", param2=direction})
  500. meta1:set_int("wear", wear)
  501. meta2:set_int("wear", wear)
  502. itemstack:take_item()
  503. return itemstack
  504. end
  505. end,
  506. })
  507. minetest.register_tool("default:axe_diamond", {
  508. description = "Diamond Axe",
  509. inventory_image = "default_tool_diamondaxe.png",
  510. tool_capabilities = {
  511. full_punch_interval = 0.9,
  512. max_drop_level=1,
  513. groupcaps={
  514. choppy={times={[1]=2.10, [2]=0.90, [3]=0.50}, uses=30, maxlevel=3},
  515. },
  516. damage_groups = {fleshy=7},
  517. },
  518. sound = {breaks = "default_tool_breaks"},
  519. on_place = function(itemstack, placer, pointed_thing)
  520. local pt = pointed_thing
  521. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  522. local wear = itemstack:get_wear()
  523. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  524. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  525. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  526. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:axe_diamond_deco", param2=direction})
  527. meta1:set_int("wear", wear)
  528. meta2:set_int("wear", wear)
  529. itemstack:take_item()
  530. return itemstack
  531. end
  532. end,
  533. })
  534. --
  535. -- Swords
  536. --
  537. minetest.register_tool("default:sword_wood", {
  538. description = "Wooden Sword",
  539. inventory_image = "default_tool_woodsword.png",
  540. tool_capabilities = {
  541. full_punch_interval = 1,
  542. max_drop_level=0,
  543. groupcaps={
  544. snappy={times={[2]=1.6, [3]=0.40}, uses=10, maxlevel=1},
  545. },
  546. damage_groups = {fleshy=2},
  547. },
  548. groups = {flammable = 2},
  549. sound = {breaks = "default_tool_breaks"},
  550. on_place = function(itemstack, placer, pointed_thing)
  551. local pt = pointed_thing
  552. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  553. local wear = itemstack:get_wear()
  554. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  555. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  556. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  557. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:sword_wood_deco", param2=direction})
  558. meta1:set_int("wear", wear)
  559. meta2:set_int("wear", wear)
  560. itemstack:take_item()
  561. return itemstack
  562. end
  563. end,
  564. })
  565. minetest.register_tool("default:sword_stone", {
  566. description = "Stone Sword",
  567. inventory_image = "default_tool_stonesword.png",
  568. tool_capabilities = {
  569. full_punch_interval = 1.2,
  570. max_drop_level=0,
  571. groupcaps={
  572. snappy={times={[2]=1.4, [3]=0.40}, uses=20, maxlevel=1},
  573. },
  574. damage_groups = {fleshy=4},
  575. },
  576. sound = {breaks = "default_tool_breaks"},
  577. on_place = function(itemstack, placer, pointed_thing)
  578. local pt = pointed_thing
  579. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  580. local wear = itemstack:get_wear()
  581. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  582. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  583. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  584. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:sword_stone_deco", param2=direction})
  585. meta1:set_int("wear", wear)
  586. meta2:set_int("wear", wear)
  587. itemstack:take_item()
  588. return itemstack
  589. end
  590. end,
  591. })
  592. minetest.register_tool("default:sword_steel", {
  593. description = "Steel Sword",
  594. inventory_image = "default_tool_steelsword.png",
  595. tool_capabilities = {
  596. full_punch_interval = 0.8,
  597. max_drop_level=1,
  598. groupcaps={
  599. snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=30, maxlevel=2},
  600. },
  601. damage_groups = {fleshy=6},
  602. },
  603. sound = {breaks = "default_tool_breaks"},
  604. on_place = function(itemstack, placer, pointed_thing)
  605. local pt = pointed_thing
  606. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  607. local wear = itemstack:get_wear()
  608. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  609. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  610. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  611. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:sword_steel_deco", param2=direction})
  612. meta1:set_int("wear", wear)
  613. meta2:set_int("wear", wear)
  614. itemstack:take_item()
  615. return itemstack
  616. end
  617. end,
  618. })
  619. minetest.register_tool("default:sword_bronze", {
  620. description = "Bronze Sword",
  621. inventory_image = "default_tool_bronzesword.png",
  622. tool_capabilities = {
  623. full_punch_interval = 0.8,
  624. max_drop_level=1,
  625. groupcaps={
  626. snappy={times={[1]=2.5, [2]=1.20, [3]=0.35}, uses=40, maxlevel=2},
  627. },
  628. damage_groups = {fleshy=6},
  629. },
  630. sound = {breaks = "default_tool_breaks"},
  631. on_place = function(itemstack, placer, pointed_thing)
  632. local pt = pointed_thing
  633. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  634. local wear = itemstack:get_wear()
  635. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  636. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  637. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  638. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:sword_bronze_deco", param2=direction})
  639. meta1:set_int("wear", wear)
  640. meta2:set_int("wear", wear)
  641. itemstack:take_item()
  642. return itemstack
  643. end
  644. end,
  645. })
  646. minetest.register_tool("default:sword_mese", {
  647. description = "Mese Sword",
  648. inventory_image = "default_tool_mesesword.png",
  649. tool_capabilities = {
  650. full_punch_interval = 0.7,
  651. max_drop_level=1,
  652. groupcaps={
  653. snappy={times={[1]=2.0, [2]=1.00, [3]=0.35}, uses=30, maxlevel=3},
  654. },
  655. damage_groups = {fleshy=7},
  656. },
  657. sound = {breaks = "default_tool_breaks"},
  658. on_place = function(itemstack, placer, pointed_thing)
  659. local pt = pointed_thing
  660. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  661. local wear = itemstack:get_wear()
  662. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  663. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  664. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  665. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:sword_mese_deco", param2=direction})
  666. meta1:set_int("wear", wear)
  667. meta2:set_int("wear", wear)
  668. itemstack:take_item()
  669. return itemstack
  670. end
  671. end,
  672. })
  673. minetest.register_tool("default:sword_diamond", {
  674. description = "Diamond Sword",
  675. inventory_image = "default_tool_diamondsword.png",
  676. tool_capabilities = {
  677. full_punch_interval = 0.7,
  678. max_drop_level=1,
  679. groupcaps={
  680. snappy={times={[1]=1.90, [2]=0.90, [3]=0.30}, uses=40, maxlevel=3},
  681. },
  682. damage_groups = {fleshy=8},
  683. },
  684. sound = {breaks = "default_tool_breaks"},
  685. on_place = function(itemstack, placer, pointed_thing)
  686. local pt = pointed_thing
  687. if ( minetest.get_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}).name == "air" ) then
  688. local wear = itemstack:get_wear()
  689. local direction = minetest.dir_to_facedir(placer:get_look_dir())
  690. local meta1 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y , z=pt.under.z})
  691. local meta2 = minetest.env:get_meta({x=pt.under.x, y=pt.under.y+1, z=pt.under.z})
  692. minetest.set_node({x=pt.under.x, y=pt.under.y+1, z=pt.under.z}, {name="default:sword_diamond_deco", param2=direction})
  693. meta1:set_int("wear", wear)
  694. meta2:set_int("wear", wear)
  695. itemstack:take_item()
  696. return itemstack
  697. end
  698. end,
  699. })
  700. minetest.register_tool("default:key", {
  701. description = "Key",
  702. inventory_image = "default_key.png",
  703. groups = {key = 1, not_in_creative_inventory = 1},
  704. stack_max = 1,
  705. on_place = function(itemstack, placer, pointed_thing)
  706. local under = pointed_thing.under
  707. local node = minetest.get_node(under)
  708. local def = minetest.registered_nodes[node.name]
  709. if def and def.on_rightclick and
  710. not (placer and placer:get_player_control().sneak) then
  711. return def.on_rightclick(under, node, placer, itemstack,
  712. pointed_thing) or itemstack
  713. end
  714. if pointed_thing.type ~= "node" then
  715. return itemstack
  716. end
  717. local pos = pointed_thing.under
  718. node = minetest.get_node(pos)
  719. if not node or node.name == "ignore" then
  720. return itemstack
  721. end
  722. local ndef = minetest.registered_nodes[node.name]
  723. if not ndef then
  724. return itemstack
  725. end
  726. local on_key_use = ndef.on_key_use
  727. if on_key_use then
  728. on_key_use(pos, placer)
  729. end
  730. return nil
  731. end
  732. })
  733. local register_deco_block = function(tool_name, tool_tiles, tool_nodebox)
  734. minetest.register_node(tool_name.."_deco", {
  735. drawtype = "nodebox",
  736. paramtype = "light",
  737. paramtype2 = "facedir",
  738. tiles = tool_tiles,
  739. groups = {
  740. snappy=3,
  741. flammable=2,
  742. not_in_creative_inventory=1
  743. },
  744. node_box = {
  745. type = "fixed",
  746. fixed = tool_nodebox,
  747. },
  748. sounds = default.node_sound_wood_defaults(),
  749. on_dig = function(pos, node, digger)
  750. if digger:is_player() and digger:get_inventory() then
  751. local meta = minetest.env:get_meta(pos)
  752. local wear_out = meta:get_int("wear")
  753. digger:get_inventory():add_item("main", {name=tool_name, count=1, wear=wear_out, metadata=""})
  754. end
  755. minetest.remove_node(pos)
  756. end,
  757. })
  758. end
  759. local register_deco_block_materials = function(material, top)
  760. register_deco_block("default:pick_"..material, {top, "default_tool_"..material.."pick.png"}, {{-0.5/3, -1.5/3, -0.5/3, 0.5/3, 0.5/3, 0.5/3},{-0.5/3, 0.5/3, -1.5/3, 0.5/3, 1.5/3, 1.5/3}})
  761. register_deco_block("default:shovel_"..material, {top, "default_tool_"..material.."shovel.png"}, {{-0.5/3, -1.5/3, -0.5/3, 0.5/3, 1.5/3, 0.5/3}})
  762. register_deco_block("default:axe_"..material, {top, top, "default_tool_"..material.."axe.png^[transformFX", "default_tool_"..material.."axe.png", "default_tool_"..material.."axe.png^[combine:6x6:2,0=".."default_tool_"..material.."axe.png", "default_tool_"..material.."axe.png"}, {{-0.5/3, -1.5/3, -0.5/3, 0.5/3, 0.5/3, 0.5/3},{-0.5/3, 0.5/3, -0.5/3, 0.5/3, 1.5/3, 1.5/3},{-0.5/3, -0.5/3, 0.5/3, 0.5/3, 0.5/3, 1.5/3}})
  763. register_deco_block("default:sword_"..material, {top, "default_tool_"..material.."sword.png"}, {{-0.5/3, -1.5/3, -0.5/3, 0.5/3, 1.5/3, 0.5/3}})
  764. end
  765. register_deco_block_materials("stone", "default_cobble.png")
  766. register_deco_block_materials("wood", "default_wood.png")
  767. register_deco_block_materials("steel", "default_steel_block.png")
  768. register_deco_block_materials("bronze", "default_bronze_block.png")
  769. register_deco_block_materials("mese", "default_mese_block.png")
  770. register_deco_block_materials("diamond", "default_diamond_block.png")