tools.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. local S = farming.intllib
  2. farming.path = minetest.get_modpath("farming")
  3. local has_value = basic_functions.has_value
  4. local crop_cols={
  5. col_num={"max_uses","farming_change","max_level","damage","times"},
  6. groups_num={"snappy"}}
  7. local tool_definition = basic_functions.import_csv(farming.path.."/tools.txt",crop_cols)
  8. for i,line in pairs(tool_definition) do
  9. tool_def={description=S(line.name:gsub("_"," ")),
  10. inventory_image="farming_tool_"..line.name..".png",
  11. max_uses=line.max_uses,
  12. farming_change=line.farming_change,
  13. material = line.material,
  14. groups={flammable = 2},
  15. tool_capabilities = {
  16. full_punch_intervall = 1.0,
  17. max_drop_level = 4,
  18. groupcaps={
  19. snappy = {times={[1]=line.times,[2]=0.4*line.times,[3]=0.25*line.times},
  20. uses=line.max_uses,
  21. maxlevel=line.max_level,
  22. },},
  23. damage_groups = {fleshy = line.damage}
  24. }
  25. }
  26. local tooltype=line.name:split("_")[1]
  27. if tooltype=="billhook" then
  28. farming.register_billhook("farming:"..line.name,tool_def)
  29. elseif tooltype=="scythe" then
  30. farming.register_scythe("farming:"..line.name,tool_def)
  31. elseif tooltype=="hoe" then
  32. farming.register_hoe("farming:"..line.name,tool_def)
  33. end
  34. end
  35. -- Picker
  36. -- to extract seeds from crops, which usually give harvest, e.g. tea
  37. farming.register_tool("farming:picker", {
  38. description = S("Seed Picker"),
  39. inventory_image = "farming_tool_picker.png",
  40. groups = {farming_picker = 1, flammable = 2},
  41. max_uses=30,
  42. tool_capabilities = {
  43. full_punch_intervall = 1.0,
  44. max_drop_level = 2,
  45. groupcaps = {
  46. snappy = {times={[1]=5,[2]=2,[3]=1.4},},
  47. uses=30,
  48. maxlevel=3,
  49. },
  50. damage_groups = {fleshy = 1},
  51. },
  52. recipe= {
  53. {"", "", "group:stick"},
  54. {"", "group:stick", "group:wool"},
  55. {"group:stick", "", ""},
  56. },
  57. on_use = function(itemstack, user, pointed_thing)
  58. return farming.use_picker(itemstack, user, pointed_thing, 30)
  59. end
  60. })