flintandsteel.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. local function strike_fire(user, pointed_thing)
  2. -- Fire priviledge
  3. local name = user:get_player_name()
  4. if not minetest.get_player_privs(name)["fire"] then
  5. minetest.chat_send_player(name, "You need the fire privilege.")
  6. return
  7. end
  8. -- Use tinder, place flame
  9. if pointed_thing.type == "node" then
  10. local n_pointed_above = minetest.get_node(pointed_thing.above)
  11. if not n_pointed_above.name == "air" then return end
  12. local tinder = user:get_inventory():get_stack("main", user:get_wield_index()+1):get_name()
  13. if tinder == "fire:tinder" then
  14. user:get_inventory():remove_item("main", "fire:tinder")
  15. minetest.add_node(pointed_thing.above, {name="fire:basic_flame"})
  16. return true
  17. else
  18. minetest.chat_send_player(name, "You need tinder right to the tool.")
  19. end
  20. end
  21. end
  22. minetest.register_craftitem("fire:tinder", {
  23. description = "Tinder",
  24. inventory_image = "flint_tinder.png",
  25. })
  26. minetest.register_tool("fire:flint_and_steel", {
  27. description = "Fire Striker",
  28. inventory_image = "flint_firestriker.png",
  29. range = 2.0,
  30. on_place = function(itemstack, user, pointed_thing)
  31. if strike_fire(user, pointed_thing) then
  32. itemstack:add_wear(65535/15)
  33. end
  34. return itemstack
  35. end
  36. })
  37. -- Craft
  38. minetest.register_craft({
  39. output = 'fire:flint_and_steel',
  40. recipe = {
  41. {'default:cobble', 'default:steel_ingot'},
  42. }
  43. })
  44. minetest.register_craft({
  45. output = 'fire:tinder',
  46. recipe = {
  47. {'farming:cotton'},
  48. }
  49. })
  50. minetest.register_craft({
  51. output = 'fire:tinder',
  52. recipe = {
  53. {'farming:wheat'},
  54. }
  55. })
  56. minetest.register_craft({
  57. output = 'fire:tinder',
  58. recipe = {
  59. {'default:paper'},
  60. }
  61. })