mirror of
https://codeberg.org/tenplus1/farming.git
synced 2024-11-14 06:10:44 +01:00
73 lines
2.7 KiB
Plaintext
73 lines
2.7 KiB
Plaintext
Farming API
|
|
-----------
|
|
|
|
The farming API allows you to easily register plants and hoes.
|
|
|
|
`farming.register_hoe(name, hoe definition)`
|
|
* Register a new hoe, see [#hoe definition]
|
|
|
|
`farming.register_plant(name, Plant definition)`
|
|
* Register a new growing plant, see [#Plant definition]
|
|
|
|
`farming.registered_plants[name] = definition`
|
|
* Table of registered plants, indexed by plant name
|
|
'crop' holds name of growing crop node minus _step-number at end
|
|
'seed' has name of seed required to plant crop
|
|
'minlight' min light level needed to grow
|
|
'maxlight' max light level needed to grow
|
|
'steps' number of steps crop has in growth cycle
|
|
'trellis' name of trellis node (e.g. "farming:trellis"), default: nil
|
|
|
|
### Hoe Definition
|
|
|
|
|
|
{
|
|
description = "My Hoe", -- Description for tooltip
|
|
inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
|
|
max_uses = 30, -- Uses until destroyed
|
|
material = "", -- Material for recipes
|
|
recipe = { -- Craft recipe, if material isn't used
|
|
{"air", "air", "air"},
|
|
{"", "group:stick"},
|
|
{"", "group:stick"},
|
|
}
|
|
}
|
|
|
|
### Plant definition
|
|
|
|
{
|
|
description = "My Plant", -- Description of seed item
|
|
inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image
|
|
steps = 8, -- How many steps the plant has to grow, until it can be harvested
|
|
-- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
|
|
minlight = 13, -- Minimum light to grow
|
|
maxlight = minetest.LIGHT_MAX -- Maximum light to grow
|
|
}
|
|
|
|
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.
|
|
|
|
### Crop functions
|
|
|
|
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'.
|
|
|
|
growth_check = function(pos, node_name)
|
|
-- check surrounding for jungle tree
|
|
if minetest.find_node_near(pos, 1, {"default:jungletree"}) then
|
|
return true -- place next growth stage
|
|
end
|
|
return false -- condition not met, skip next growth stage until next check
|
|
end,
|
|
|
|
### Scythe items that will not drop
|
|
|
|
This is a function to add items to a list that scythes will not drop, e.g. farming:trellis or farming:beanpole.
|
|
|
|
farming.add_to_scythe_not_drops(item_name)
|
|
|
|
### Start timer function
|
|
|
|
A handy function that starts a crops timer with a randomly selected time set by using
|
|
stage_length setting. This is mostly used for special functions or 3rd party mods.
|
|
|
|
farming.start_seed_timer(pos)
|