craftitems.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. -- mods/default/craftitems.lua
  2. default = default or {}
  3. function default.strike_protection(itemstack, user, pt)
  4. if not user or not user:is_player() then
  5. return
  6. end
  7. if pt.type ~= "node" then
  8. return
  9. end
  10. local pname = user:get_player_name()
  11. if minetest.test_protection(pt.under, pname) then
  12. ambiance.sound_play("default_metal_footstep", pt.under, 1.0, 20)
  13. else
  14. ambiance.sound_play("default_wood_footstep", pt.under, 1.0, 20)
  15. end
  16. -- Update names in infotext.
  17. local node = minetest.get_node(pt.under)
  18. local ndef = minetest.registered_items[node.name]
  19. if ndef and ndef._on_rename_check then
  20. ndef._on_rename_check(pt.under)
  21. end
  22. end
  23. minetest.register_craftitem("default:stick", {
  24. description = "Stick\n\nCan be used to test protection.\nAlso updates infotext names.",
  25. inventory_image = "default_stick.png",
  26. groups = {stick = 1, flammable = 2},
  27. on_use = default.strike_protection,
  28. })
  29. minetest.register_craftitem("default:paper", {
  30. description = "Paper",
  31. inventory_image = "default_paper.png",
  32. groups = {flammable = 3},
  33. })
  34. minetest.register_craftitem("default:padlock", {
  35. description = "Lock",
  36. inventory_image = "lock_item.png",
  37. })
  38. minetest.register_craftitem("default:coal_lump", {
  39. description = "Coal Lump",
  40. inventory_image = "default_coal_lump.png",
  41. groups = {coal = 1, flammable = 1}
  42. })
  43. minetest.register_craftitem("default:iron_lump", {
  44. description = "Iron Lump",
  45. inventory_image = "default_iron_lump.png",
  46. })
  47. minetest.register_craftitem("default:copper_lump", {
  48. description = "Copper Lump",
  49. inventory_image = "default_copper_lump.png",
  50. })
  51. minetest.register_craftitem("default:mese_crystal", {
  52. description = "Mese Crystal",
  53. inventory_image = "default_mese_crystal.png",
  54. })
  55. minetest.register_craftitem("default:gold_lump", {
  56. description = "Gold Lump",
  57. inventory_image = "default_gold_lump.png",
  58. })
  59. minetest.register_craftitem("default:diamond", {
  60. description = "Diamond",
  61. inventory_image = "default_diamond.png",
  62. groups = {gem = 1, crystal = 1},
  63. })
  64. minetest.register_craftitem("default:clay_lump", {
  65. description = "Clay Lump",
  66. inventory_image = "default_clay_lump.png",
  67. })
  68. minetest.register_craftitem("default:steel_ingot", {
  69. description = "Wrought Iron Ingot",
  70. inventory_image = "default_steel_ingot.png",
  71. groups = {ingot = 1},
  72. })
  73. minetest.register_craftitem("default:copper_ingot", {
  74. description = "Copper Ingot",
  75. inventory_image = "default_copper_ingot.png",
  76. groups = {ingot = 1},
  77. })
  78. minetest.register_craftitem("default:bronze_ingot", {
  79. description = "Bronze Ingot",
  80. inventory_image = "default_bronze_ingot.png",
  81. groups = {ingot = 1},
  82. })
  83. minetest.register_craftitem("default:gold_ingot", {
  84. description = "Gold Ingot",
  85. inventory_image = "default_gold_ingot.png",
  86. groups = {ingot = 1},
  87. })
  88. minetest.register_craftitem("default:mese_crystal_fragment", {
  89. description = "Mese Crystal Fragment",
  90. inventory_image = "default_mese_crystal_fragment.png",
  91. })
  92. minetest.register_craftitem("default:clay_brick", {
  93. description = "Clay Brick",
  94. inventory_image = "default_clay_brick.png",
  95. })
  96. minetest.register_craftitem("default:obsidian_shard", {
  97. description = "Obsidian Shard",
  98. inventory_image = "default_obsidian_shard.png",
  99. })
  100. minetest.register_craftitem("default:flint", {
  101. description = "Flint",
  102. inventory_image = "default_flint.png"
  103. })