From df1aa7fad3e7af030ee6e260b6ec719af727ff0e Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Mon, 28 Aug 2017 12:33:25 +0100 Subject: [PATCH] added minlight maxlight to api and growing routine --- cotton.lua | 4 ++-- grass.lua | 1 + hoes.lua | 6 ++++++ init.lua | 29 +++++++++++++++++++++++++---- wheat.lua | 22 +++++++++++++++++++--- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/cotton.lua b/cotton.lua index 5241b2c..bf0412e 100644 --- a/cotton.lua +++ b/cotton.lua @@ -8,7 +8,7 @@ minetest.register_node("farming:seed_cotton", { inventory_image = "farming_cotton_seed.png", wield_image = "farming_cotton_seed.png", drawtype = "signlike", - groups = {seed = 1, snappy = 3, attached_node = 1}, + groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4}, paramtype = "light", paramtype2 = "wallmounted", walkable = false, @@ -75,7 +75,7 @@ local crop_def = { drop = "", selection_box = farming.select, 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 }, sounds = default.node_sound_leaves_defaults() diff --git a/grass.lua b/grass.lua index aacb220..f6f777b 100644 --- a/grass.lua +++ b/grass.lua @@ -14,6 +14,7 @@ for i = 3, 5 do }) -- Override default dry grass and have it drop Barley Seeds + if minetest.registered_nodes["default:dry_grass_1"] then minetest.override_item("default:dry_grass_" .. i, { diff --git a/hoes.lua b/hoes.lua index dd7a11c..c883e22 100644 --- a/hoes.lua +++ b/hoes.lua @@ -130,6 +130,12 @@ farming.register_hoe(":farming:hoe_wood", { material = "group:wood" }) +minetest.register_craft({ + type = "fuel", + recipe = "farming:hoe_wood", + burntime = 5, +}) + farming.register_hoe(":farming:hoe_stone", { description = S("Stone Hoe"), inventory_image = "farming_tool_stonehoe.png", diff --git a/init.lua b/init.lua index c2e9f1b..93fcd13 100644 --- a/init.lua +++ b/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") -- Intllib @@ -110,8 +117,8 @@ end local STAGE_LENGTH_AVG = 160.0 local STAGE_LENGTH_DEV = STAGE_LENGTH_AVG / 6 -local MIN_LIGHT = 13 -local MAX_LIGHT = 1000 +--local MIN_LIGHT = 13 +--local MAX_LIGHT = 1000 --- 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 not minetest.find_node_near(pos, 1, {"default:jungletree"}) then - return true end else @@ -365,6 +371,10 @@ function farming.plant_growth_timer(pos, elapsed, node_name) return true 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 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}) - 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() @@ -544,6 +555,14 @@ farming.register_plant = function(name, def) return nil end + if not def.minlight then + def.minlight = 1 + end + + if not def.maxlight then + def.maxlight = 14 + end + -- Register seed minetest.register_node(":" .. mname .. ":seed_" .. pname, { @@ -610,6 +629,8 @@ place_param2 = def.place_param2 or nil, selection_box = farming.select, groups = g, sounds = default.node_sound_leaves_defaults(), + minlight = def.minlight, + maxlight = def.maxlight, }) register_plant_node(node_name) diff --git a/wheat.lua b/wheat.lua index a8bec1f..7676c83 100644 --- a/wheat.lua +++ b/wheat.lua @@ -8,7 +8,7 @@ minetest.register_node("farming:seed_wheat", { inventory_image = "farming_wheat_seed.png", wield_image = "farming_wheat_seed.png", drawtype = "signlike", - groups = {seed = 1, snappy = 3, attached_node = 1}, + groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4}, paramtype = "light", paramtype2 = "wallmounted", walkable = false, @@ -23,6 +23,7 @@ minetest.register_node("farming:seed_wheat", { minetest.register_craftitem("farming:wheat", { description = S("Wheat"), inventory_image = "farming_wheat.png", + groups = {flammable = 4}, }) -- straw @@ -30,7 +31,7 @@ minetest.register_node("farming:straw", { description = S("Straw"), tiles = {"farming_straw.png"}, 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(), }) @@ -54,6 +55,7 @@ minetest.register_craft({ minetest.register_craftitem("farming:flour", { description = S("Flour"), inventory_image = "farming_flour.png", + groups = {flammable = 1}, }) minetest.register_craft({ @@ -67,6 +69,7 @@ minetest.register_craftitem("farming:bread", { description = S("Bread"), inventory_image = "farming_bread.png", on_use = minetest.item_eat(5), + groups = {flammable = 2}, }) minetest.register_craft({ @@ -89,7 +92,7 @@ place_param2 = 3, drop = "", selection_box = farming.select, 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 }, sounds = default.node_sound_leaves_defaults() @@ -154,3 +157,16 @@ crop_def.drop = { } } 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, +})