forked from mtcontrib/farming
		
	added minlight maxlight to api and growing routine
This commit is contained in:
		| @@ -8,7 +8,7 @@ minetest.register_node("farming:seed_cotton", { | |||||||
| 	inventory_image = "farming_cotton_seed.png", | 	inventory_image = "farming_cotton_seed.png", | ||||||
| 	wield_image = "farming_cotton_seed.png", | 	wield_image = "farming_cotton_seed.png", | ||||||
| 	drawtype = "signlike", | 	drawtype = "signlike", | ||||||
| 	groups = {seed = 1, snappy = 3, attached_node = 1}, | 	groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4}, | ||||||
| 	paramtype = "light", | 	paramtype = "light", | ||||||
| 	paramtype2 = "wallmounted", | 	paramtype2 = "wallmounted", | ||||||
| 	walkable = false, | 	walkable = false, | ||||||
| @@ -75,7 +75,7 @@ local crop_def = { | |||||||
| 	drop =  "", | 	drop =  "", | ||||||
| 	selection_box = farming.select, | 	selection_box = farming.select, | ||||||
| 	groups = { | 	groups = { | ||||||
| 		snappy = 3, flammable = 2, plant = 1, attached_node = 1, | 		snappy = 3, flammable = 4, plant = 1, attached_node = 1, | ||||||
| 		not_in_creative_inventory = 1, growing = 1 | 		not_in_creative_inventory = 1, growing = 1 | ||||||
| 	}, | 	}, | ||||||
| 	sounds = default.node_sound_leaves_defaults() | 	sounds = default.node_sound_leaves_defaults() | ||||||
|   | |||||||
| @@ -14,6 +14,7 @@ for i = 3, 5 do | |||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
| 	-- Override default dry grass and have it drop Barley Seeds | 	-- Override default dry grass and have it drop Barley Seeds | ||||||
|  |  | ||||||
| 	if minetest.registered_nodes["default:dry_grass_1"] then | 	if minetest.registered_nodes["default:dry_grass_1"] then | ||||||
|  |  | ||||||
| 		minetest.override_item("default:dry_grass_" .. i, { | 		minetest.override_item("default:dry_grass_" .. i, { | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								hoes.lua
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								hoes.lua
									
									
									
									
									
								
							| @@ -130,6 +130,12 @@ farming.register_hoe(":farming:hoe_wood", { | |||||||
| 	material = "group:wood" | 	material = "group:wood" | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "fuel", | ||||||
|  | 	recipe = "farming:hoe_wood", | ||||||
|  | 	burntime = 5, | ||||||
|  | }) | ||||||
|  |  | ||||||
| farming.register_hoe(":farming:hoe_stone", { | farming.register_hoe(":farming:hoe_stone", { | ||||||
| 	description = S("Stone Hoe"), | 	description = S("Stone Hoe"), | ||||||
| 	inventory_image = "farming_tool_stonehoe.png", | 	inventory_image = "farming_tool_stonehoe.png", | ||||||
|   | |||||||
							
								
								
									
										29
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								init.lua
									
									
									
									
									
								
							| @@ -15,6 +15,13 @@ farming.select = { | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | local creative_mode_cache = minetest.setting_getbool("creative_mode") | ||||||
|  |  | ||||||
|  | function is_creative(name) | ||||||
|  | 	return creative_mode_cache or minetest.check_player_privs(name, {creative = true}) | ||||||
|  | end | ||||||
|  |  | ||||||
|  |  | ||||||
| local statistics = dofile(farming.path.."/statistics.lua") | local statistics = dofile(farming.path.."/statistics.lua") | ||||||
|  |  | ||||||
| -- Intllib | -- Intllib | ||||||
| @@ -110,8 +117,8 @@ end | |||||||
|  |  | ||||||
| local STAGE_LENGTH_AVG = 160.0 | local STAGE_LENGTH_AVG = 160.0 | ||||||
| local STAGE_LENGTH_DEV = STAGE_LENGTH_AVG / 6 | local STAGE_LENGTH_DEV = STAGE_LENGTH_AVG / 6 | ||||||
| local MIN_LIGHT = 13 | --local MIN_LIGHT = 13 | ||||||
| local MAX_LIGHT = 1000 | --local MAX_LIGHT = 1000 | ||||||
|  |  | ||||||
| --- Determines plant name and stage from node. | --- Determines plant name and stage from node. | ||||||
|  -- |  -- | ||||||
| @@ -346,7 +353,6 @@ function farming.plant_growth_timer(pos, elapsed, node_name) | |||||||
| 	if stages.plant_name == "farming:cocoa" then | 	if stages.plant_name == "farming:cocoa" then | ||||||
|  |  | ||||||
| 		if not minetest.find_node_near(pos, 1, {"default:jungletree"}) then | 		if not minetest.find_node_near(pos, 1, {"default:jungletree"}) then | ||||||
|  |  | ||||||
| 			return true | 			return true | ||||||
| 		end | 		end | ||||||
| 	else | 	else | ||||||
| @@ -365,6 +371,10 @@ function farming.plant_growth_timer(pos, elapsed, node_name) | |||||||
| 		return true | 		return true | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
|  | -------- | ||||||
|  | local MIN_LIGHT = minetest.registered_nodes[node_name].minlight or 13 | ||||||
|  | local MAX_LIGHT = minetest.registered_nodes[node_name].maxlight or 14 | ||||||
|  | --print ("---", MIN_LIGHT, MAX_LIGHT) | ||||||
| 	if max_growth == 1 or lambda < 2.0 then | 	if max_growth == 1 or lambda < 2.0 then | ||||||
|  |  | ||||||
| 		local light = (minetest.get_node_light(light_pos) or 0) | 		local light = (minetest.get_node_light(light_pos) or 0) | ||||||
| @@ -503,7 +513,8 @@ function farming.place_seed(itemstack, placer, pointed_thing, plantname) | |||||||
|  |  | ||||||
| 		minetest.sound_play("default_place_node", {pos = pt.above, gain = 1.0}) | 		minetest.sound_play("default_place_node", {pos = pt.above, gain = 1.0}) | ||||||
|  |  | ||||||
| 		if not minetest.setting_getbool("creative_mode") then | --		if not minetest.setting_getbool("creative_mode") then | ||||||
|  | 		if not is_creative(placer:get_player_name()) then | ||||||
|  |  | ||||||
| 			itemstack:take_item() | 			itemstack:take_item() | ||||||
|  |  | ||||||
| @@ -544,6 +555,14 @@ farming.register_plant = function(name, def) | |||||||
| 		return nil | 		return nil | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
|  | 	if not def.minlight then | ||||||
|  | 		def.minlight = 1 | ||||||
|  | 	end | ||||||
|  |  | ||||||
|  | 	if not def.maxlight then | ||||||
|  | 		def.maxlight = 14 | ||||||
|  | 	end | ||||||
|  |  | ||||||
| 	-- Register seed | 	-- Register seed | ||||||
| 	minetest.register_node(":" .. mname .. ":seed_" .. pname, { | 	minetest.register_node(":" .. mname .. ":seed_" .. pname, { | ||||||
|  |  | ||||||
| @@ -610,6 +629,8 @@ place_param2 = def.place_param2 or nil, | |||||||
| 			selection_box = farming.select, | 			selection_box = farming.select, | ||||||
| 			groups = g, | 			groups = g, | ||||||
| 			sounds = default.node_sound_leaves_defaults(), | 			sounds = default.node_sound_leaves_defaults(), | ||||||
|  | 			minlight = def.minlight, | ||||||
|  | 			maxlight = def.maxlight, | ||||||
| 		}) | 		}) | ||||||
|  |  | ||||||
| 		register_plant_node(node_name) | 		register_plant_node(node_name) | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								wheat.lua
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								wheat.lua
									
									
									
									
									
								
							| @@ -8,7 +8,7 @@ minetest.register_node("farming:seed_wheat", { | |||||||
| 	inventory_image = "farming_wheat_seed.png", | 	inventory_image = "farming_wheat_seed.png", | ||||||
| 	wield_image = "farming_wheat_seed.png", | 	wield_image = "farming_wheat_seed.png", | ||||||
| 	drawtype = "signlike", | 	drawtype = "signlike", | ||||||
| 	groups = {seed = 1, snappy = 3, attached_node = 1}, | 	groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4}, | ||||||
| 	paramtype = "light", | 	paramtype = "light", | ||||||
| 	paramtype2 = "wallmounted", | 	paramtype2 = "wallmounted", | ||||||
| 	walkable = false, | 	walkable = false, | ||||||
| @@ -23,6 +23,7 @@ minetest.register_node("farming:seed_wheat", { | |||||||
| minetest.register_craftitem("farming:wheat", { | minetest.register_craftitem("farming:wheat", { | ||||||
| 	description = S("Wheat"), | 	description = S("Wheat"), | ||||||
| 	inventory_image = "farming_wheat.png", | 	inventory_image = "farming_wheat.png", | ||||||
|  | 	groups = {flammable = 4}, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| -- straw | -- straw | ||||||
| @@ -30,7 +31,7 @@ minetest.register_node("farming:straw", { | |||||||
| 	description = S("Straw"), | 	description = S("Straw"), | ||||||
| 	tiles = {"farming_straw.png"}, | 	tiles = {"farming_straw.png"}, | ||||||
| 	is_ground_content = false, | 	is_ground_content = false, | ||||||
| 	groups = {snappy = 3, flammable = 4}, | 	groups = {snappy = 3, flammable = 4, fall_damage_add_percent = -30}, | ||||||
| 	sounds = default.node_sound_leaves_defaults(), | 	sounds = default.node_sound_leaves_defaults(), | ||||||
| }) | }) | ||||||
|  |  | ||||||
| @@ -54,6 +55,7 @@ minetest.register_craft({ | |||||||
| minetest.register_craftitem("farming:flour", { | minetest.register_craftitem("farming:flour", { | ||||||
| 	description = S("Flour"), | 	description = S("Flour"), | ||||||
| 	inventory_image = "farming_flour.png", | 	inventory_image = "farming_flour.png", | ||||||
|  | 	groups = {flammable = 1}, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| @@ -67,6 +69,7 @@ minetest.register_craftitem("farming:bread", { | |||||||
| 	description = S("Bread"), | 	description = S("Bread"), | ||||||
| 	inventory_image = "farming_bread.png", | 	inventory_image = "farming_bread.png", | ||||||
| 	on_use = minetest.item_eat(5), | 	on_use = minetest.item_eat(5), | ||||||
|  | 	groups = {flammable = 2}, | ||||||
| }) | }) | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| @@ -89,7 +92,7 @@ place_param2 = 3, | |||||||
| 	drop = "", | 	drop = "", | ||||||
| 	selection_box = farming.select, | 	selection_box = farming.select, | ||||||
| 	groups = { | 	groups = { | ||||||
| 		snappy = 3, flammable = 2, plant = 1, attached_node = 1, | 		snappy = 3, flammable = 4, plant = 1, attached_node = 1, | ||||||
| 		not_in_creative_inventory = 1, growing = 1 | 		not_in_creative_inventory = 1, growing = 1 | ||||||
| 	}, | 	}, | ||||||
| 	sounds = default.node_sound_leaves_defaults() | 	sounds = default.node_sound_leaves_defaults() | ||||||
| @@ -154,3 +157,16 @@ crop_def.drop = { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| minetest.register_node("farming:wheat_8", table.copy(crop_def)) | minetest.register_node("farming:wheat_8", table.copy(crop_def)) | ||||||
|  |  | ||||||
|  | -- fuels | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "fuel", | ||||||
|  | 	recipe = "farming:straw", | ||||||
|  | 	burntime = 3, | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | minetest.register_craft({ | ||||||
|  | 	type = "fuel", | ||||||
|  | 	recipe = "farming:wheat", | ||||||
|  | 	burntime = 1, | ||||||
|  | }) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user