1 local init
= os
.clock()
4 function farming
:add_plant(full_grown
, names
, interval
, chance
)
5 minetest
.register_abm({
9 action
= function(pos
, node
)
11 if minetest
.env
:get_node(pos
).name
~= "farming:soil_wet" and math
.random(0, 9) > 0 then
15 if not minetest
.env
:get_node_light(pos
) then
18 if minetest
.env
:get_node_light(pos
) < 10 then
22 for i
,name
in ipairs(names
) do
23 if name
== node
.name
then
31 local new_node
= {name
=names
[step
+1]}
32 if new_node
.name
== nil then
33 new_node
.name
= full_grown
35 minetest
.env
:set_node(pos
, new_node
)
41 function farming
:place_seed(itemstack
, placer
, pointed_thing
, plantname
)
42 local pt
= pointed_thing
46 if pt
.type ~= "node" then
50 local pos
= {x
=pt
.above
.x
, y
=pt
.above
.y
-1, z
=pt
.above
.z
}
51 local farmland
= minetest
.env
:get_node(pos
)
52 pos
= {x
=pt
.above
.x
, y
=pt
.above
.y
, z
=pt
.above
.z
}
53 local place_s
= minetest
.env
:get_node(pos
)
56 if string.find(farmland
.name
, "farming:soil") and string.find(place_s
.name
, "air") then
57 minetest
.env
:add_node(pos
, {name
=plantname
})
62 if not minetest
.setting_getbool("creative_mode") then
70 -- ========= SOIL =========
71 dofile(minetest
.get_modpath("farming").."/soil.lua")
73 -- ========= HOES =========
74 dofile(minetest
.get_modpath("farming").."/hoes.lua")
76 -- ========= WHEAT =========
77 dofile(minetest
.get_modpath("farming").."/wheat.lua")
79 -- ========= PUMPKIN =========
80 dofile(minetest
.get_modpath("farming").."/pumpkin.lua")
82 -- ========= MELON =========
83 dofile(minetest
.get_modpath("farming").."/melon.lua")
85 -- ========= CARROT =========
86 dofile(minetest
.get_modpath("farming").."/carrots.lua")
88 -- ========= POTATOES =========
89 dofile(minetest
.get_modpath("farming").."/potatoes.lua")
91 -- ========= MUSHROOMS =========
92 dofile(minetest
.get_modpath("farming").."/mushrooms.lua")
94 local time_to_load
= os
.clock() - init
95 print(string.format("[MOD] "..minetest
.get_current_modname().." loaded in %.4f s", time_to_load
))