craftitems.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. })
  63. minetest.register_craftitem("default:clay_lump", {
  64. description = "Clay Lump",
  65. inventory_image = "default_clay_lump.png",
  66. })
  67. minetest.register_craftitem("default:steel_ingot", {
  68. description = "Wrought Iron Ingot",
  69. inventory_image = "default_steel_ingot.png",
  70. groups = {ingot = 1},
  71. })
  72. minetest.register_craftitem("default:copper_ingot", {
  73. description = "Copper Ingot",
  74. inventory_image = "default_copper_ingot.png",
  75. groups = {ingot = 1},
  76. })
  77. minetest.register_craftitem("default:bronze_ingot", {
  78. description = "Bronze Ingot",
  79. inventory_image = "default_bronze_ingot.png",
  80. groups = {ingot = 1},
  81. })
  82. minetest.register_craftitem("default:gold_ingot", {
  83. description = "Gold Ingot",
  84. inventory_image = "default_gold_ingot.png",
  85. groups = {ingot = 1},
  86. })
  87. minetest.register_craftitem("default:mese_crystal_fragment", {
  88. description = "Mese Crystal Fragment",
  89. inventory_image = "default_mese_crystal_fragment.png",
  90. })
  91. minetest.register_craftitem("default:clay_brick", {
  92. description = "Clay Brick",
  93. inventory_image = "default_clay_brick.png",
  94. })
  95. minetest.register_craftitem("default:obsidian_shard", {
  96. description = "Obsidian Shard",
  97. inventory_image = "default_obsidian_shard.png",
  98. })
  99. minetest.register_craftitem("default:flint", {
  100. description = "Flint",
  101. inventory_image = "default_flint.png"
  102. })