diff --git a/composter.lua b/composter.lua index d36ee8b..2f31298 100644 --- a/composter.lua +++ b/composter.lua @@ -135,11 +135,11 @@ function composter_on_timer(pos, elapsed) if (amount>0) then local timer = minetest.get_node_timer(pos); - timer:set(base_production_time*speed, 0); + timer:start(base_production_time*speed, 0); end composter_update_node(pos, node, meta); - return amount>0; + return false; -- timer:start force timer to continue, return true will erase new timer setting end local short_desc = S("Composter"); diff --git a/garden_soil.lua b/garden_soil.lua index 93ef362..8f2a400 100644 --- a/garden_soil.lua +++ b/garden_soil.lua @@ -1,8 +1,13 @@ local S = composting.translator local time_divider = composting.settings.soil_time_divider; +local time_const_base = 365*24*3600/256; +local wet_points = composting.settings.wet_points; composting.watering_cans = {} +composting.fertilize_items = { + ["composting:compost_clod"] = 127 +} if minetest.get_modpath("bucket") then -- bucket mod @@ -36,17 +41,26 @@ if minetest.get_modpath("wateringcan") then end composting.watering_cans["wateringcan:wateringcan_water"] = empty_wateringcan; + + if wateringcan and wateringcan.wettable_nodes then + wateringcan.wettable_nodes["composting:garden_soil"] = function(pos) + local node = minetest.get_node(pos); + node.name = "composting:garden_soil_wet"; + node.param1 = wet_points; + minetest.swap_node(pos, node); + end + end end -local garden_soil_tiles = {"composting_garden_soil.png"}; -local garden_soil_wet_tiles = {"composting_garden_soil_wet.png"}; +local garden_soil_tiles = nil; +local garden_soil_wet_tiles = nil; if minetest.get_modpath("farming") then - garden_soil_tiles = {"composting_garden_soil.png^farming_soil.png", "composting_garden_soil.png"}; - garden_soil_tiles = {"composting_garden_soil_wet.png^farming_soil_wet.png", "composting_garden_soil.png^farming_soil_wet_side.png"}; + garden_soil_tiles = {{name="farming_soil.png",color="white"}, ""}; + garden_soil_wet_tiles = {{name="farming_soil_wet.png",color="white"}, {name="farming_soil_wet_side.png",color="white"}}; end if minetest.get_modpath("hades_farming") then - garden_soil_tiles = {"composting_garden_soil.png^hades_farming_soil.png", "composting_garden_soil.png"}; - garden_soil_tiles = {"composting_garden_soil_wet.png^hades_farming_soil_wet.png", "composting_garden_soil.png^hades_farming_soil_wet_side.png"}; + garden_soil_tiles = {{name="hades_farming_soil.png",color="white"}, ""}; + garden_soil_wet_tiles = {{name="hades_farming_soil_wet.png",color="white"}, {name="hades_farming_soil_wet_side.png",color="white"}}; end -- garden soil @@ -83,29 +97,34 @@ minetest.register_node("composting:garden_soil", { short_description = short_desc, description = desc, _tt_help = tt_help, + paramtype2 = "color", + palette = "composting_garden_soil_palette.png", + color = "#6A4B31", tiles = {"composting_garden_soil.png"}, + overlay_tiles = garden_soil_tiles, -- soil have to be 2, because farming code detect wet soil via soil value groups = {crumbly = 3, soil = 2, grassland = 1}, drop = "default:dirt", sounds = node_sounds, on_construct = function(pos) local node = minetest.get_node(pos); - node.param1 = 255; + node.param2 = 255; minetest.swap_node(pos, node); local timer = minetest.get_node_timer(pos); - timer:start((3422/time_divider)/effect_of_flora(pos)); + timer:start((time_const_base/time_divider)/effect_of_flora(pos)); end, on_timer = function(pos, elapsed) - local node = minetest.get_node(pos); - if (node.param1>0) then - node.param1 = node.param1-1; + local node = minetest.get_node(pos); + if (node.param2>0) then + node.param2 = node.param2-1; if minetest.find_node_near(pos, 3, {"group:water"}) then node.name = "composting:garden_soil_wet"; end minetest.swap_node(pos, node); local timer = minetest.get_node_timer(pos); - timer:start((3422/time_divider)/effect_of_flora(pos)); - return true; + --print(dump(pos)..timer:get_timeout().." gt:"..minetest.get_gametime()) + timer:set((time_const_base/time_divider)/effect_of_flora(pos), 0); + return false; else minetest.set_node(pos, {name="farming:soil"}); end @@ -114,12 +133,25 @@ minetest.register_node("composting:garden_soil", { on_punch = function(pos, node, puncher) if puncher then local item = puncher:get_wielded_item(); - local watering_can = composting.watering_cans[item:get_name()]; + local item_name = item:get_name(); + local watering_can = composting.watering_cans[item_name]; if watering_can then node.name = "composting:garden_soil_wet" - node.param2 = 4; + node.param1 = wet_points; minetest.swap_node(pos, node); puncher:set_wielded_item(watering_can(puncher, item)); + return + end + local compost_clod = composting.fertilize_items[item_name]; + if compost_clod then + node.param2 = node.param2+127; + if (node.param2>255) then + node.param2 = 255; + end + minetest.swap_node(pos, node); + item:take_item(1) + puncher:set_wielded_item(item); + return end end end, @@ -135,39 +167,44 @@ minetest.register_node("composting:garden_soil_wet", { short_description = short_desc, description = desc, _tt_help = tt_help, + paramtype2 = "color", + palette = "composting_garden_soil_palette.png", + color = "$6A4B31", tiles = {"composting_garden_soil_wet.png"}, + overlay_tiles = garden_soil_wet_tiles, groups = {crumbly = 3, soil = 5, grassland = 1, wet = 1, not_in_creative_inventory = 1}, drop = "default:dirt", sounds = node_sounds, on_construct = function(pos) local node = minetest.get_node(pos); - node.param1 = 255; - node.param2 = 4; + node.param2 = 255; + node.param1 = wet_point; minetest.swap_node(pos, node); local timer = minetest.get_node_timer(pos); - timer:start((1711/time_divider)/effect_of_flora(pos)); + timer:start(((time_const_base/2)/time_divider)/effect_of_flora(pos)); end, on_timer = function(pos, elapsed) local node = minetest.get_node(pos); - if (node.param1>0) then - local timer_const = 3422; - node.param1 = node.param1-1; + if (node.param2>0) then + local timer_const = time_const_base/2; + node.param2 = node.param2-1; if minetest.find_node_near(pos, 3, {"group:water"}) then - node.param2 = 4; + node.param1 = wet_points; end - if (node.param2>0) then - node.param2 = node.param2-1; + if (node.param1>0) then + node.param1 = node.param1-1; else if not minetest.find_node_near(pos, 3, {"ignore"}) then node.name = "composting:garden_soil"; - timer_const = 1711; + timer_const = time_const_base; end end minetest.swap_node(pos, node); local timer = minetest.get_node_timer(pos); + --print(dump(pos)..timer:get_timeout().." gt:"..minetest.get_gametime()) timer:start((timer_const/time_divider)/effect_of_flora(pos)); - return true; - elseif (node.param2>0) then + return false; + elseif (node.param1>0) then minetest.set_node(pos, {name="farming:soil_wet"}); else minetest.set_node(pos, {name="farming:soil"}); @@ -177,14 +214,27 @@ minetest.register_node("composting:garden_soil_wet", { on_punch = function(pos, node, puncher) if puncher then local item = puncher:get_wielded_item(); - local watering_can = composting.watering_cans[item:get_name()]; + local item_name = item:get_name(); + local watering_can = composting.watering_cans[item_name]; if watering_can then - node.param2 = node.param2+4; - if (node.param2>5) then - node.param2 = 5; + node.param1 = node.param1+wet_points; + if (node.param1>wet_points) then + node.param1 = wet_points; end minetest.swap_node(pos, node); puncher:set_wielded_item(watering_can(puncher, item)); + return + end + local compost_clod = composting.fertilize_items[item_name]; + if compost_clod then + node.param2 = node.param2+127; + if (node.param2>255) then + node.param2 = 255; + end + minetest.swap_node(pos, node); + item:take_item(1); + puncher:set_wielded_item(item); + return end end end, diff --git a/scripts/palette.png b/scripts/composting_composter_palette.png similarity index 100% rename from scripts/palette.png rename to scripts/composting_composter_palette.png diff --git a/scripts/composting_garden_soil_palette.png b/scripts/composting_garden_soil_palette.png new file mode 100644 index 0000000..36ff22d Binary files /dev/null and b/scripts/composting_garden_soil_palette.png differ diff --git a/scripts/generatePalette.py b/scripts/generatePalette.py index 04fc190..87c9c61 100644 --- a/scripts/generatePalette.py +++ b/scripts/generatePalette.py @@ -23,4 +23,10 @@ palette = [] for i in range(16): add_pixels(palette, help_colors[i], (48,48,48,255), 16) img.putdata(palette) -img.save("palette.png") +img.save("composting_composter_palette.png") + +img = Image.new(mode="RGBA",size=(16,16),color=(0,0,0,255)); +palette = [] +add_pixels(palette, (106,75,49,255), (70,40,10,255), 256) +img.putdata(palette) +img.save("composting_garden_soil_palette.png") diff --git a/settings.lua b/settings.lua index 8e069c7..cd94cf3 100644 --- a/settings.lua +++ b/settings.lua @@ -11,9 +11,10 @@ end local settings = { amount_limit = settings_get_int("composting_amount_per_composter", 200), - clod_cost = settings_get_int("composting_clod_cost", 100), - composting_time_divider = settings_get_int("composting_time_divider", 72), - soil_time_divider = settings_get_int("composting_soil_time_divider", 72), + clod_cost = settings_get_int("composting_clod_cost", 25), + composting_time_divider = settings_get_int("composting_time_divider", 3600), + soil_time_divider = settings_get_int("composting_soil_time_divider", 720), + wet_points = settings_get_int("composting_soil_wet_points", 25), } composting.settings = settings; diff --git a/settingtypes.txt b/settingtypes.txt index a681ce5..0c5e322 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,9 +1,34 @@ composting_amount_per_composter (Maximum amount of biomase per composter) int 200 -composting_clod_cost (How much amount of compost cost compost clod) int 100 +# Compost clod cost +# +# If compost is optimally fulled, it takes around 20 minutes for one compost clod to be finished (time_divider set to 3600). +# +composting_clod_cost (How much amount of compost cost compost clod) int 25 -composting_time_divider (Time divider for composting speed) int 72 +# Basic composting speed is one year. +# Minetest use default day length 20 minutes, which means that time is divided by 72. +# time_divider 72 -> ideal composting time 122 hours. +# time_divider 720 -> ideal composting time 12 hours. +# time_divider 3600 -> ideal composting time 2.5 hours. +# time_divider 7200 -> ideal composting time 1.25 hours. +# +composting_time_divider (Time divider for composting speed) int 3600 -composting_soil_time_divider (Time divider for garden soil timer) int 72 +# Garden soil time divider set how long it take to garden soil be exhauset and changed into farming soil. +# +# soil_time_divider 72 -> change to dirt in 122 hours +# soil_time_divider 720 -> change to dirt in 12 hours +# soil_time_divider 3600 -> change to dirt in 2.5 hours +# soil_time_divider 7200 -> change to dirt in 1.25 hours +# +composting_soil_time_divider (Time divider for garden soil timer) int 720 + +# Wet points of garden soil +# +# Times is valid for soil_time_divider set to 720. +# soil_wet_points 25 -> get dry in 71 minutes +# +composting_soil_wet_points (Wet points of garden soil) int 25 diff --git a/textures/composting_garden_soil.png b/textures/composting_garden_soil.png index bc7ed8d..66a5e06 100644 Binary files a/textures/composting_garden_soil.png and b/textures/composting_garden_soil.png differ diff --git a/textures/composting_garden_soil_palette.png b/textures/composting_garden_soil_palette.png new file mode 100644 index 0000000..36ff22d Binary files /dev/null and b/textures/composting_garden_soil_palette.png differ diff --git a/textures/composting_garden_soil_wet.png b/textures/composting_garden_soil_wet.png index fae4325..886329d 100644 Binary files a/textures/composting_garden_soil_wet.png and b/textures/composting_garden_soil_wet.png differ