api.txt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Farming API
  2. -----------
  3. The farming API allows you to easily register plants and hoes.
  4. `farming.register_hoe(name, hoe definition)`
  5. * Register a new hoe, see [#hoe definition]
  6. `farming.register_plant(name, Plant definition)`
  7. * Register a new growing plant, see [#Plant definition]
  8. `farming.registered_plants[name] = definition`
  9. * Table of registered plants, indexed by plant name
  10. 'crop' holds name of growing crop node minus _step-number at end
  11. 'seed' has name of seed required to plant crop
  12. 'minlight' min light level needed to grow
  13. 'maxlight' max light level needed to grow
  14. 'steps' number of steps crop has in growth cycle
  15. 'trellis' name of trellis node (e.g. "farming:trellis"), default: nil
  16. ### Hoe Definition
  17. {
  18. description = "My Hoe", -- Description for tooltip
  19. inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
  20. max_uses = 30, -- Uses until destroyed
  21. material = "", -- Material for recipes
  22. recipe = { -- Craft recipe, if material isn't used
  23. {"air", "air", "air"},
  24. {"", "group:stick"},
  25. {"", "group:stick"},
  26. }
  27. }
  28. ### Plant definition
  29. {
  30. description = "My Plant", -- Description of seed item
  31. inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
  32. steps = 8, -- How many steps the plant has to grow, until it can be harvested
  33. -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
  34. minlight = 13, -- Minimum light to grow
  35. maxlight = default.LIGHT_MAX -- Maximum light to grow
  36. }
  37. Note: Any crops registered with the above function will use the new growing routines, also if crops are manually added with the {growing=1} group they will also grow.
  38. ### Crop functions
  39. If a mod registers nodes to be used as crops using the {growing=1} group then an additional function can be used for custom growth checks instead of the standard 'are we above wet soil'.
  40. growth_check = function(pos, node_name)
  41. -- check surrounding for jungle tree
  42. if minetest.find_node_near(pos, 1, {"default:jungletree"}) then
  43. return false -- place next growth stage
  44. end
  45. return true -- condition not met, skip next growth stage until next check
  46. end,
  47. ### Scythe items that will not drop
  48. This is a function to add items to a list that scythes will not drop, e.g. farming:trellis or farming:beanpole.
  49. farming.add_to_scythe_not_drops(item_name)