api.txt 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. ### Hoe Definition
  11. {
  12. description = "", -- Description for tooltip
  13. inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
  14. max_uses = 30, -- Uses until destroyed
  15. material = "", -- Material for recipes
  16. recipe = { -- Craft recipe, if material isn't used
  17. {"air", "air", "air"},
  18. {"", "group:stick"},
  19. {"", "group:stick"},
  20. }
  21. }
  22. ### Plant definition
  23. {
  24. description = "", -- Description of seed item
  25. inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
  26. steps = 8, -- How many steps the plant has to grow, until it can be harvested
  27. -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
  28. minlight = 13, -- Minimum light to grow
  29. maxlight = default.LIGHT_MAX -- Maximum light to grow
  30. }
  31. 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.
  32. ### Crop functions
  33. 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'.
  34. growth_check = function(pos, node_name)
  35. -- check surrounding for jungle tree
  36. if minetest.find_node_near(pos, 1, {"default:jungletree"}) then
  37. return false -- place next growth stage
  38. end
  39. return true -- condition not met, skip next growth stage until next check
  40. end,