init.lua 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. if not minetest.global_exists("starpearl") then starpearl = {} end
  2. starpearl.modpath = minetest.get_modpath("starpearl")
  3. function starpearl.on_place(itemstack, placer, pt)
  4. if not placer or not placer:is_player() then return end
  5. if pt.type ~= "node" then return end
  6. local pname = placer:get_player_name()
  7. -- What are we pointing at?
  8. local nn = minetest.get_node(pt.under).name
  9. if string.find(nn, "obsidian") or string.find(nn, "grieferstone") then
  10. if obsidian_gateway.attempt_activation(pt.under, placer, "pearl") then
  11. itemstack:take_item()
  12. return itemstack
  13. end
  14. end
  15. if nn == "default:obsidian" then
  16. local result, pos = flameportal.find_gateway(pt.under)
  17. if result == true and pos then
  18. if flameportal.activate_gateway(pos) then
  19. itemstack:take_item()
  20. return itemstack
  21. end
  22. end
  23. end
  24. end
  25. if not starpearl.run_once then
  26. minetest.register_craftitem(":mobs:flame_bolt", {
  27. description = "Flame Bolt",
  28. inventory_image = "mobs_flame_bolt.png",
  29. groups = {flammable = 3},
  30. light_source = 14,
  31. on_place = function(...) return starpearl.on_place(...) end,
  32. })
  33. minetest.register_craftitem("starpearl:pearl", {
  34. description = "Star Pearl",
  35. inventory_image = "starpearl_pearl.png",
  36. light_source = 14,
  37. })
  38. local c = "starpearl:core"
  39. local f = starpearl.modpath .. "/init.lua"
  40. reload.register_file(c, f, false)
  41. starpearl.run_once = true
  42. end