tools.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. -- LUALOCALS < ---------------------------------------------------------
  2. local minetest, nodecore
  3. = minetest, nodecore
  4. -- LUALOCALS > ---------------------------------------------------------
  5. local modname = minetest.get_current_modname()
  6. local function toolhead(name, from, group, sticks)
  7. local n
  8. if name then
  9. n = modname .. ":toolhead_" .. name:lower()
  10. local t = n:gsub(":", "_") .. ".png"
  11. minetest.register_craftitem(n, {
  12. description = "Wooden " .. name .. " Head",
  13. inventory_image = t,
  14. stack_max = 1,
  15. groups = {
  16. choppy = 1,
  17. flammable = 2
  18. },
  19. tool_head_capabilities = nodecore.toolcaps({
  20. [group] = 2
  21. }),
  22. sounds = nodecore.sounds("nc_tree_woody")
  23. })
  24. local m = modname .. ":tool_" .. name:lower()
  25. local u = m:gsub(":", "_") .. ".png"
  26. minetest.register_tool(m, {
  27. description = "Wooden " .. name,
  28. inventory_image = u,
  29. groups = {
  30. flammable = 2
  31. },
  32. tool_capabilities = nodecore.toolcaps({
  33. [group] = 2
  34. }),
  35. sounds = nodecore.sounds("nc_tree_woody")
  36. })
  37. nodecore.register_craft({
  38. label = "assemble wood " .. name:lower(),
  39. normal = {y = 1},
  40. indexkeys = {n},
  41. nodes = {
  42. {match = n, replace = "air"},
  43. {y = -1, match = modname .. ":staff", replace = "air"},
  44. },
  45. items = {
  46. {y = -1, name = m},
  47. }
  48. })
  49. end
  50. nodecore.register_craft({
  51. label = "carve " .. from,
  52. action = "pummel",
  53. toolgroups = {choppy = 1},
  54. indexkeys = {from},
  55. nodes = {
  56. {match = from, replace = "air"}
  57. },
  58. items = {
  59. n and {name = n} or nil,
  60. sticks and {name = "nc_tree:stick",
  61. count = sticks, scatter = 5} or nil
  62. }
  63. })
  64. end
  65. toolhead("Mallet", modname .. ":plank",
  66. "thumpy", 2)
  67. toolhead("Spade", modname .. ":toolhead_mallet",
  68. "crumbly", 1)
  69. toolhead("Hatchet", modname .. ":toolhead_spade",
  70. "choppy", 1)
  71. toolhead("Pick", modname .. ":toolhead_hatchet",
  72. "cracky", 2)
  73. toolhead(nil, modname .. ":toolhead_pick",
  74. nil, 2)