api with hooks for harvesting
parent
612730f9c2
commit
8ce1d40e57
|
@ -128,7 +128,8 @@ end
|
||||||
|
|
||||||
-- function for digging crops
|
-- function for digging crops
|
||||||
-- if dug with scythe by change you harvest more
|
-- if dug with scythe by change you harvest more
|
||||||
farming.dig_harvest = function(pos, node, digger)
|
--farming.dig_harvest = function(pos, node, digger)
|
||||||
|
farming.register_on_harvest(function(pos, node, digger)
|
||||||
local starttime=os.clock()
|
local starttime=os.clock()
|
||||||
|
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
@ -145,7 +146,7 @@ farming.dig_harvest = function(pos, node, digger)
|
||||||
-- print(dump(def.drop))
|
-- print(dump(def.drop))
|
||||||
minetest.node_dig(pos,node,digger)
|
minetest.node_dig(pos,node,digger)
|
||||||
--table.insert(farming.time_digharvest,1000*(os.clock()-starttime))
|
--table.insert(farming.time_digharvest,1000*(os.clock()-starttime))
|
||||||
end
|
end)
|
||||||
|
|
||||||
-- timer function for infected plants
|
-- timer function for infected plants
|
||||||
-- the step of plant is reduced till zero then the plant dies
|
-- the step of plant is reduced till zero then the plant dies
|
||||||
|
|
16
api.lua
16
api.lua
|
@ -1,3 +1,19 @@
|
||||||
farming.add_soil=function(soil2add)
|
farming.add_soil=function(soil2add)
|
||||||
table.insert(farming.change_soil,soil2add)
|
table.insert(farming.change_soil,soil2add)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function farming.register_on_harvest(spec)
|
||||||
|
-- Add function
|
||||||
|
if #farming.registered_on_harvest == 0 then
|
||||||
|
farming.registered_on_harvest=spec
|
||||||
|
else
|
||||||
|
table.insert(farming.registered_on_harvest,1,spec)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function farming.on_harvest(pos,node,digger)
|
||||||
|
for _, func in ipairs(farming.registered_on_harvest) do
|
||||||
|
itemstack = func(pos,node,digger) or itemstack
|
||||||
|
end
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
|
@ -28,6 +28,7 @@ farming.health_threshold = tonumber(minetest.settings:get("farming.health_thres
|
||||||
farming.factor_regrow = tonumber(minetest.settings:get("farming.factor_regrow")) or 2
|
farming.factor_regrow = tonumber(minetest.settings:get("farming.factor_regrow")) or 2
|
||||||
farming.abm_planting = tonumber(minetest.settings:get("farming.abm_planting")) or 30
|
farming.abm_planting = tonumber(minetest.settings:get("farming.abm_planting")) or 30
|
||||||
farming.abm_planting_change = tonumber(minetest.settings:get("farming.abm_planting_change")) or 750
|
farming.abm_planting_change = tonumber(minetest.settings:get("farming.abm_planting_change")) or 750
|
||||||
|
farming.registered_on_harvest={}
|
||||||
|
|
||||||
-- node type, where grain can be randomly found
|
-- node type, where grain can be randomly found
|
||||||
farming.change_soil = {}
|
farming.change_soil = {}
|
||||||
|
|
2
mod.conf
2
mod.conf
|
@ -2,7 +2,7 @@ name = farming
|
||||||
title = Farming
|
title = Farming
|
||||||
author = ademant
|
author = ademant
|
||||||
description = An enhanced farming mod with spreding crops which wilt if not harvested.
|
description = An enhanced farming mod with spreding crops which wilt if not harvested.
|
||||||
optional_depends = intllib,default,wool,vessels,bucket,thirsty
|
optional_depends = intllib,default,wool,vessels,bucket,thirsty,ethereal
|
||||||
depends = basic_functions
|
depends = basic_functions
|
||||||
license = MIT
|
license = MIT
|
||||||
version = 1.0.0
|
version = 1.0.0
|
||||||
|
|
Loading…
Reference in New Issue