api.txt 2.4 KB

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