init.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. local MP = minetest.get_modpath("toolranks_extras")
  2. toolranks_extras = {}
  3. -- mod information
  4. toolranks_extras.mod = {version = "1.4.1", author = "Louis Royer"}
  5. -- settings
  6. toolranks_extras.settings = {
  7. enable_farming_tools = minetest.settings:get_bool("toolranks_extras.farming", true),
  8. enable_tool_types = minetest.settings:get_bool("toolranks_extras.tool_types", true),
  9. }
  10. -- XXX: when https://github.com/minetest/minetest/pull/7377
  11. -- is merged, we can remove this function
  12. -- and %s/toolranks_extras\.log/minetest\.log/g
  13. toolranks_extras.log = function(level, text)
  14. local prefix = "[toolranks_extra] "
  15. if text then
  16. minetest.log(level, prefix..text)
  17. else
  18. minetest.log(prefix..level)
  19. end
  20. end
  21. -- mods detection
  22. local use_farming = minetest.get_modpath("farming")
  23. -- farming redo (https://notabug.org/tenplus1/farming)
  24. -- already implements toolranks support
  25. local use_farming_redo = use_farming and (farming.mod == "redo") or false
  26. -- toolranks version
  27. if toolranks.add_tool == nil then
  28. toolranks_extras.log("error", "Please a more recent version of"
  29. .." toolranks (at least version 1.2).")
  30. end
  31. dofile(MP.."/tool_types.lua")
  32. if use_farming and (not use_farming_redo)
  33. and toolranks_extras.settings.enable_farming_tools then
  34. dofile(MP.."/hoe.lua")
  35. end