Compare commits

...

7 Commits

Author SHA1 Message Date
ademant 8ce1d40e57 api with hooks for harvesting 2019-01-15 08:59:50 +01:00
ademant 612730f9c2 add group drinkable 2019-01-14 08:13:25 +01:00
ademant 2eeecc81bf compat for mt 0.4.17 2019-01-09 18:40:58 +01:00
ademant 45c8184ebe abm also set plant on grass area 2019-01-09 11:50:02 +01:00
ademant e435b3226e Merge branch 'master' of https://notabug.org/ademant/minetest_farming 2019-01-09 08:28:30 +01:00
A. Demant c0e4f01cae Merge branch 'master' of notabug.org:ademant/minetest_farming 2019-01-08 16:03:47 +01:00
A. Demant 237566b32b adjust wilt 2019-01-08 16:03:32 +01:00
9 changed files with 71 additions and 39 deletions

View File

@ -98,7 +98,9 @@ minetest.register_abm({
local ptabove={x=pos.x,y=pos.y+1,z=pos.z}
local above = minetest.get_node(ptabove)
if above.name ~= "air" then
return
if (minetest.get_item_group(above.name, "grass")==0) or (minetest.get_item_group(above.name, "dry_grass")==0) then
return
end
end
local ptlight=minetest.get_node_light(ptabove)
if ptlight < farming.min_light then

View File

@ -128,7 +128,8 @@ end
-- function for digging crops
-- 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 def = minetest.registered_nodes[node.name]
@ -145,7 +146,7 @@ farming.dig_harvest = function(pos, node, digger)
-- print(dump(def.drop))
minetest.node_dig(pos,node,digger)
--table.insert(farming.time_digharvest,1000*(os.clock()-starttime))
end
end)
-- timer function for infected plants
-- the step of plant is reduced till zero then the plant dies

16
api.lua
View File

@ -1,3 +1,19 @@
farming.add_soil=function(soil2add)
table.insert(farming.change_soil,soil2add)
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

View File

@ -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.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.registered_on_harvest={}
-- node type, where grain can be randomly found
farming.change_soil = {}

View File

@ -1,31 +1,31 @@
name,enabled,hijack,next_plant,rarety,rarety_grass_drop,rarety_junglegrass_drop,steps,harvest_max,eat_hp,to_culture,to_dig,has_harvest,on_soil,is_bush,punchable,wiltable,infectable,infection_defence,seed_extractable,no_seed,use_flail,use_trellis,for_coffee,seed_roastable,seed_grindable,for_flour,snappy,damage_per_second,liquid_viscosity,temperature_min,temperature_max,humidity_min,humidity_max,elevation_min,elevation_max,light_min,light_max,infect_rate_base,infect_rate_monoculture,spread_rate,grow_time_mean,wilt_time,straw,culture_rate,seed_drop,grind,roast
default,1,,,10,,,8,3,1,,,,,,,,,,,,,,,,,,3,,,15,80,10,80,-20,200,11,14,1000,90,1,60,1200,,,,,
barley,1,,,10,15,,7,,,,,1,1,,,2,1,,,,1,,1,3,,1,3,,2,25,,30,,,,,,,,,,,farming:straw,,,farming:flour,farming:grain_roasted
beetroot,1,,,10,,,5,,2,,1,,1,,,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
blackberry,1,,,10,,,4,,,,,,,1,1,1,,,,,,,,,,,3,1,4,,90,20,,,,9,,,,,,,,,,,
blueberry,1,,,10,,,4,,,,,,,1,1,1,,,,,,,,,,,3,,,45,90,40,90,,,9,,,,,,,,,,,
carrot,1,,,10,20,,8,,2,,1,,1,,,,,,,,,,,2,,,3,,,,,30,90,,,8,,,,,,,,,,,farming:carrot_gold
chili,1,,,20,,,8,,,,,,,,1,,,,,,,,,,,,3,,,55,90,,,20,1000,,,,,,,,,,,,
coffee,1,,,20,,,5,,,,,,,,1,,,,,,,,1,4,,,3,,,55,120,50,150,20,1000,12,,,,,,,,,,,
corn,1,,,10,,35,8,4,2,,,,1,,,2,1,,,,,,,4,1,,3,,2,35,90,30,,,,,,,,,,,,,,,farming:corn_cob
cotton,1,,,10,10,10,8,,,,,1,1,,,,1,,,,1,,,,,,3,,2,45,90,20,,,,12,,,,,,,,,,,
culturewheat,1,,,100,,,4,4,,1,,1,1,,,2,2,,,,1,,1,3,,1,3,,2,25,,40,,,,10,,700,75,,,100,farming:straw,,,farming:flour,farming:grain_roasted
flax,,,,10,,,7,,,,,1,1,,,,1,,,,1,,,,,,3,,2,25,,30,,,,,,,,,,,farming:flaw,,,,
garlic,,,,10,,,5,,,,1,,1,,,,,,,,,,,3,,,3,,,,,,,,,,,,,,,,,,,,
grapes,,,,10,,,8,,2,1,,,1,,1,,1,,,,,1,,,,,3,,3,,,,,,,,,,,,,,,,farming:wildgrapes_seed,,
hemp,1,,,10,,,8,,,,,1,,,,,,,,,1,,,,,,3,,2,,120,,,,,8,,,,1E-05,55,,farming:hemp_fibre,,,,
hop,1,,,10,,,7,,,1,,,1,,1,2,2,,,,,1,,4,,,3,,2,55,,,,,50,,,,,,,,,,farming:wildhop_seed,,
mustard,1,,,10,,,5,,,,,,,,,,1,,,,,,,,2,,3,,,,,,,,,,,,,,,,,,,,
potato,1,,,10,50,,4,4,2,,,,1,,,2,1,,,,,,,4,1,,3,,2,,,,60,,,,,550,75,,,,,,,,farming:potato_baked
raspberry,1,,,10,,,4,,,,,,,1,1,1,,,,,,,,,,,3,1,4,,,,,,,9,,,,,,,,,,,
rhubarb,1,,,10,,,3,,2,,1,,1,,,,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
spelt,1,,,10,15,,7,,,,,1,1,,,2,1,,,,1,,,3,,1,3,,2,,,,,,,,,,,,,,farming:straw,,,farming:flour,farming:grain_roasted
strawberry,1,ethereal:strawberry,,10,,,8,,,,,,,1,1,1,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
sugarbeet,1,,,10,,,5,,2,,1,,1,,,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
tea,1,,,20,,,8,,,,,,1,,1,,,,1,,,,,4,,,3,,2,30,70,30,70,20,1000,,,,,,,,,,farming:tea_leaves,,farming:tea_black
tobaco,1,,,10,,50,8,,,,,,1,,1,,,2,1,,,,,4,,,3,,,,,,,,1000,,,,,,,,,,farming:tobaco_leaves,,
tomato,,,,10,,,8,,,,,1,1,,1,1,1,,,,,1,,,,,3,,,,,,,,,,,,,,,,,,,,
nettle,1,,,10,,,5,,,,,1,,,1,3,,1,,,1,,,2,,,3,1,3,5,150,0,100,,2000,8,,,,0.1,50,,farming:nettle_fibre,,,,
wheat,1,,farming:culturewheat,10,10,,8,,,,,1,1,,,2,1,,,,1,,1,3,,1,3,,2,,,30,70,,,,,,,,70,100,farming:straw,10,,farming:flour,farming:grain_roasted
wildoat,1,,,10,,,7,,,,,1,1,,,2,1,,,,1,,1,3,,1,3,,2,,,30,70,,,,,,,,70,100,farming:straw,,,farming:flour,farming:grain_roasted
wildgrapes,,,,10,,,4,,,,,,,,,,,,,1,,,,,,,3,,,,,,,,,,,,,,,,,5,,,
name,enabled,hijack,next_plant,rarety,rarety_grass_drop,rarety_junglegrass_drop,steps,harvest_max,eat_hp,drink,to_culture,to_dig,has_harvest,on_soil,is_bush,punchable,wiltable,infectable,infection_defence,seed_extractable,no_seed,use_flail,use_trellis,for_coffee,seed_roastable,seed_grindable,for_flour,snappy,damage_per_second,liquid_viscosity,temperature_min,temperature_max,humidity_min,humidity_max,elevation_min,elevation_max,light_min,light_max,infect_rate_base,infect_rate_monoculture,spread_rate,grow_time_mean,wilt_time,straw,culture_rate,seed_drop,grind,roast
default,1,,,10,,,8,3,1,,,,,,,,,,,,,,,,,,,3,,,15,80,10,80,-20,200,11,14,1000,90,1,120,6400,,,,,
barley,1,,,10,15,,7,,,,,,1,1,,,2,1,,,,1,,1,3,,1,3,,2,25,,30,,,,,,,,,,,farming:straw,,,farming:flour,farming:grain_roasted
beetroot,1,,,10,,,5,,2,,,1,,1,,,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
blackberry,1,,,10,,,4,,,5,,,,,1,1,1,,,,,,,,,,,3,1,4,,90,20,,,,9,,,,,,,,,,,
blueberry,1,,,10,,,4,,,5,,,,,1,1,1,,,,,,,,,,,3,,,45,90,40,90,,,9,,,,,,,,,,,
carrot,1,,,10,20,,8,,2,2,,1,,1,,,,,,,,,,,2,,,3,,,,,30,90,,,8,,,,,,,,,,,farming:carrot_gold
chili,1,,,20,,,8,,,,,,,,,1,,,,,,,,,,,,3,,,55,90,,,20,1000,,,,,,,,,,,,
coffee,1,,,20,,,5,,,,,,,,,1,,,,,,,,1,4,,,3,,,55,120,50,150,20,1000,12,,,,,,,,,,,
corn,1,,,10,,35,8,4,2,,,,,1,,,2,1,,,,,,,4,1,,3,,2,35,90,30,,,,,,,,,,,,,,,farming:corn_cob
cotton,1,,,10,10,10,8,,,,,,1,1,,,,1,,,,1,,,,,,3,,2,45,90,20,,,,12,,,,,,,,,,,
culturewheat,1,,,100,,,4,4,,,1,,1,1,,,2,2,,,,1,,1,3,,1,3,,2,25,,40,,,,10,,700,75,,,100,farming:straw,,,farming:flour,farming:grain_roasted
flax,,,,10,,,7,,,,,,1,1,,,,1,,,,1,,,,,,3,,2,25,,30,,,,,,,,,,,farming:flaw,,,,
garlic,,,,10,,,5,,,,,1,,1,,,,,,,,,,,3,,,3,,,,,,,,,,,,,,,,,,,,
grapes,,,,10,,,8,,2,5,1,,,1,,1,,1,,,,,1,,,,,3,,3,,,,,,,,,,,,,,,,farming:wildgrapes_seed,,
hemp,1,,,10,,,8,,,,,,1,,,,,,,,,1,,,,,,3,,2,,120,,,,,8,,,,1E-05,55,,farming:hemp_fibre,,,,
hop,1,,,10,,,7,,,,1,,,1,,1,2,2,,,,,1,,4,,,3,,2,55,,,,,50,,,,,,,,,,farming:wildhop_seed,,
mustard,1,,,10,,,5,,,,,,,,,,,1,,,,,,,,2,,3,,,,,,,,,,,,,,,,,,,,
potato,1,,,10,50,,4,4,2,2,,,,1,,,2,1,,,,,,,4,1,,3,,2,,,,60,,,,,550,75,,,,,,,,farming:potato_baked
raspberry,1,,,10,,,4,,,5,,,,,1,1,1,,,,,,,,,,,3,1,4,,,,,,,9,,,,,,,,,,,
rhubarb,1,,,10,,,3,,2,4,,1,,1,,,,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
spelt,1,,,10,15,,7,,,,,,1,1,,,2,1,,,,1,,,3,,1,3,,2,,,,,,,,,,,,,,farming:straw,,,farming:flour,farming:grain_roasted
strawberry,1,ethereal:strawberry,,10,,,8,,,5,,,,,1,1,1,,,,,,,,,,,3,,,,,,,,,9,,,,,,,,,,,
sugarbeet,1,,,10,,,5,,2,,,1,,1,,,,,,,,,,,,,,3,,,35,,30,,,,9,,,,,,,,,,,
tea,1,,,20,,,8,,,,,,,1,,1,,,,1,,,,,4,,,3,,2,30,70,30,70,20,1000,,,,,,,,,,farming:tea_leaves,,farming:tea_black
tobaco,1,,,10,,50,8,,,,,,,1,,1,,,2,1,,,,,4,,,3,,,,,,,,1000,,,,,,,,,,farming:tobaco_leaves,,
tomato,,,,10,,,8,,,8,,,1,1,,1,1,1,,,,,1,,,,,3,,,,,,,,,,,,,,,,,,,,
nettle,1,,,10,,,5,,,,,,1,,,1,3,,1,,,1,,,2,,,3,1,3,5,150,0,100,,2000,8,,,,0.1,50,,farming:nettle_fibre,,,,
wheat,1,,farming:culturewheat,10,10,,8,,,,,,1,1,,,2,1,,,,1,,1,3,,1,3,,2,,,30,70,,,,,,,,70,100,farming:straw,10,,farming:flour,farming:grain_roasted
wildoat,1,,,10,,,7,,,,,,1,1,,,2,1,,,,1,,1,3,,1,3,,2,,,30,70,,,,,,,,70,100,farming:straw,,,farming:flour,farming:grain_roasted
wildgrapes,,,,10,,,4,,,5,,,,,,,,,,,1,,,,,,,3,,,,,,,,,,,,,,,,,5,,,

View File

@ -1,5 +1,7 @@
default
basic_functions
intllib?
wool?
bucket?
thirsty?
vessels?

View File

@ -2,7 +2,7 @@ name = farming
title = Farming
author = ademant
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
license = MIT
version = 1.0.0

View File

@ -86,6 +86,7 @@ farming.register_plant = function(def)
else
def.harvest_name = def.step_name
end
print(def.harvest_name)
farming.register_harvest(def)
else
def.harvest_name=def.seed_name
@ -297,9 +298,18 @@ farming.register_seed=function(sdef) --time optimised
end
end
if sdef.eat_hp then
seed_def.on_use=minetest.item_eat(sdef.eat_hp)
seed_def.groups["eatable"]=sdef.eat_hp
if sdef.eat_hp or sdef.drink then
local eat_hp=0
if sdef.eat_hp then
eat_hp=sdef.eat_hp
end
seed_def.on_use=minetest.item_eat(eat_hp)
if sdef.eat_hp then
seed_def.groups["eatable"]=sdef.eat_hp
end
if sdef.drink then
seed_def.groups["drinkable"]=sdef.drink
end
end
minetest.register_node(":" .. sdef.seed_name, seed_def)

View File

@ -3,7 +3,7 @@ farming.viscosity (Viscosity of walking through grain) int 1 1 10
farming.wait_min (Minimum waiting time for next growing step) int 60 5 500
farming.wait_max (Maximum waiting time for next growing step) int 70 6 510
farming.wilt_removal_time (Mean time to remove wilt crops) int 120 5 500
farming.wilt_time (Mean time for fullgrown crop to wilt) int 1200 5 5000
farming.wilt_time (Mean time for fullgrown crop to wilt) int 6400 5 5000
farming.min_light (Min light needed for crops to grow) int 10 1 14
farming.health_threshold (healthiness threshold) int 50 1 100
farming.factor_regrow (factor for regrow after punching) float 2