forked from mtcontrib/farming
add api.txt and tidy code
This commit is contained in:
parent
82104e68a7
commit
6e52f96703
41
api.txt
Normal file
41
api.txt
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
### Hoe Definition
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
description = "", -- 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 = "", -- 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 = default.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.
|
4
init.lua
4
init.lua
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
farming = {}
|
farming = {}
|
||||||
farming.mod = "redo"
|
farming.mod = "redo"
|
||||||
farming.version = "1.33"
|
farming.version = "20180506"
|
||||||
farming.path = minetest.get_modpath("farming")
|
farming.path = minetest.get_modpath("farming")
|
||||||
farming.select = {
|
farming.select = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
@ -31,7 +31,7 @@ farming.intllib = S
|
|||||||
|
|
||||||
-- Utility Function
|
-- Utility Function
|
||||||
local time_speed = tonumber(minetest.settings:get("time_speed")) or 72
|
local time_speed = tonumber(minetest.settings:get("time_speed")) or 72
|
||||||
local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or 0
|
local SECS_PER_CYCLE = (time_speed > 0 and (24 * 60 * 60) / time_speed) or 0
|
||||||
local function clamp(x, min, max)
|
local function clamp(x, min, max)
|
||||||
return (x < min and min) or (x > max and max) or x
|
return (x < min and min) or (x > max and max) or x
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user