Update hades_seeds documentation

master
Wuzzy 2021-07-20 09:00:34 +02:00
parent 7c6210e7a5
commit 8924cb564b
4 changed files with 52 additions and 24 deletions

View File

@ -41,14 +41,6 @@ Created by Gambit (License: MIT License):
farming_cotton_seed.png
farming_wheat_seed.png
Created by Wuzzy, based on sound by wyronroberth (License: MIT License):
Original sound source: https://freesound.org/people/wyronroberth/sounds/516249/
hades_farming_seed_dig.ogg
hades_farming_seed_dug.1.ogg
hades_farming_seed_dug.2.ogg
hades_farming_seed_place.1.ogg
hades_farming_seed_place.2.ogg
Created by Wuzzy (License: MIT License):
hades_farming_wet_soil_footstep.1.ogg
hades_farming_wet_soil_footstep.2.ogg

20
mods/hades_seeds/API.md Normal file
View File

@ -0,0 +1,20 @@
# Hades Seeds API
You can register seeds and that's it. Seeds do now grow on their own, you are
supposed to implement that yourselves, e.g. with ABMs.
## `hades_seeds.register_seed(name, def)`
Register a seed node.
* `name`: Full itemstring of seed node
* `def`: Definition table:
* `description`: Same as for normal node def
* `inventory_image`: Same as for normal node def
* `place_param2`: Same as for normal node def
* `surface_check`: Function that takes the node on which the seed is
placed as argument, must return true if seed is allowed
to be placed here and false otherwise
* `_tt_help`: Tooltip extension (for 'tt' mod)
* `fertilty`: internal argument required for `hades_farming` plants only
ignore this otherwise

View File

@ -0,0 +1,23 @@
# Hades Seeds
This mod is only an API mod which allows mods to register seed nodes.
It doesn't do anything on its own.
Seeds can be placed on the ground and that's it. This mod does not
deal with plant growth, this must be added by other mods.
(since different seeds might grow differently).
For programmers, see `API.md` to learn how to add seed nodes.
Mod license: MIT License
Media licenses:
Created by Wuzzy, based on sound by wyronroberth (License: MIT License):
Original sound source: https://freesound.org/people/wyronroberth/sounds/516249/
hades_farming_seed_dig.ogg
hades_farming_seed_dug.1.ogg
hades_farming_seed_dug.2.ogg
hades_farming_seed_place.1.ogg
hades_farming_seed_place.2.ogg

View File

@ -5,12 +5,13 @@ local DEFAULT_MAXLIGHT = minetest.LIGHT_MAX
hades_seeds = {}
-- Seed placement
-- * itemstack, placer, pointed_thing: Same as node's on_place function
-- * nodename: Name of seed node to place
-- * surface_check: Function that takes the node on which the seed is placed as argument,
-- must return true if seed is allowed to be placed here
hades_seeds.place_seed = function(itemstack, placer, pointed_thing, nodename, surface_check)
--[[ Seed placement.
* `itemstack`, `placer`, `pointed_thing`: Same as node's `on_place` function
* `nodename`: Name of seed node to place
* `surface_check`: Function that takes the node on which the seed is placed as argument,
must return true if seed is allowed to be placed here
]]
local place_seed = function(itemstack, placer, pointed_thing, nodename, surface_check)
local pt = pointed_thing
-- check if pointing at a node
if not pt then
@ -65,14 +66,6 @@ hades_seeds.place_seed = function(itemstack, placer, pointed_thing, nodename, su
end
-- Register seed node.
-- name: itemstring
-- def: Definition table:
-- * description: Same as for normal node def
-- * inventory_image: Same as for normal node def
-- * place_param2: Same as for normal node def
-- * surface_check: Same as for hades_seeds.place_seed
-- * _tt_help: Tooltip extension (for 'tt' mod)
-- * fertilty: internal argument required for hades_farming plants only
hades_seeds.register_seed = function(name, def)
local placename = name
if string.sub(name, 1, 1) == ":" then
@ -118,10 +111,10 @@ hades_seeds.register_seed = function(name, def)
sounds = {
dig = { name = "hades_seeds_seed_dig", gain = 0.1 },
dug = { name = "hades_seeds_seed_dug", gain = 0.5 },
-- place sound is done in hades_seeds.place_seed
-- place sound is done in place_seed
},
on_place = function(itemstack, placer, pointed_thing)
return hades_seeds.place_seed(itemstack, placer, pointed_thing, placename, def.surface_check)
return place_seed(itemstack, placer, pointed_thing, placename, def.surface_check)
end
})