Merge remote-tracking branch 'origin/master' into testing

This commit is contained in:
kay27 2022-02-20 03:32:13 +04:00
commit 917f04e1f7
8 changed files with 30 additions and 26 deletions

View File

@ -18,8 +18,9 @@ local composter_usagehelp = S(
"Every time an item is put in the composter, there is a chance that the " ..
"composter adds another layer of compost. Some items have a bigger chance " ..
"of adding an extra layer than other items. After filling up with 7 layers " ..
"of compost, the composter is full and bone meal can be retrieved from it. " ..
"Taking out the bone meal empties the composter."
"of compost, the composter is full. After a delay of approximately one " ..
"second the composter becomes ready and bone meal can be retrieved from it. " ..
"Right-clicking the composter takes out the bone meal empties the composter."
)
minetest.register_craft({
@ -69,7 +70,7 @@ local compostability = {
["mcl_flowers:rose_bush"] = 65,
["mcl_flowers:sunflower"] = 65,
["mcl_flowers:waterlily"] = 65,
-- missing: melon block?
["mcl_farming:melon"] = 65,
-- missing: moss block?
-- mushroom aliases below?
["mcl_farming:mushroom_brown"] = 65,
@ -124,7 +125,7 @@ local compostability = {
["mcl_core:birchsapling"] = 30,
["mcl_core:darksapling"] = 30,
["mcl_core:junglesapling"] = 30,
["mcl_core:spruceapling"] = 30,
["mcl_core:sprucesapling"] = 30,
["mcl_ocean:seagrass"] = 30,
-- missing: small dripleaf
["mcl_sweet_berry:sweet_berry"] = 30,
@ -135,10 +136,11 @@ local compostability = {
local function composter_add_item(pos, node, player, itemstack, pointed_thing)
--
-- handle filling the composter when rightclicked
-- as an on_rightclick handles, it returns an itemstack
-- handler for filling the composter when rightclicked
--
if not player or player:get_player_control().sneak then
-- as an on_rightclick handler, it returns an itemstack
--
if not player or (player:get_player_control() and player:get_player_control().sneak) then
return itemstack
end
if not itemstack and itemstack:is_empty() then
@ -155,7 +157,7 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing)
if chance >= rand then
-- get current compost level
local node_defs = minetest.registered_nodes[node.name]
local level = node_defs["_compost_level"]
local level = node_defs["_mcl_compost_level"]
-- spawn green particles above new layer
mcl_dye.add_bone_meal_particle(vector.add(pos, {x=0, y=level/8, z=0}))
-- TODO: play some sounds
@ -180,8 +182,9 @@ end
local function composter_ready(pos)
--
-- update the composter block to ready for harvesting
-- this function is a callback on_timer.
-- this function is a node callback on_timer.
-- the timer is set in function 'composter_fill' when composter level is 7
--
-- returns false in order to cancel further activity of the timer
--
minetest.swap_node(pos, {name = "mcl_composters:composter_ready"})
@ -192,14 +195,14 @@ end
local function composter_harvest(pos, node, player, itemstack, pointed_thing)
--
-- handle harvesting bone meal from a ready composter when rightclicked
-- handler for harvesting bone meal from a ready composter when rightclicked
--
if not player or player:get_player_control().sneak then
if not player or (player:get_player_control() and player:get_player_control().sneak) then
return
end
-- reset composter to empty
-- reset ready type composter to empty type
minetest.swap_node(pos, {name="mcl_composters:composter"})
-- spawn bone meal item (wtf dye?! is this how the make white cocoa)
-- spawn bone meal item (wtf dye?! is this how they make white cocoa)
minetest.add_item(pos, "mcl_dye:white")
-- TODO play some sounds
@ -207,7 +210,7 @@ end
local function composter_get_nodeboxes(level)
--
-- Convenience function because the composter nodeboxes are very similar
-- Convenience function to construct the nodeboxes for varying levels of compost
--
local top_y_tbl = {[0]=-7, -5, -3, -1, 1, 3, 5, 7}
local top_y = top_y_tbl[level] / 16
@ -223,9 +226,8 @@ local function composter_get_nodeboxes(level)
}
end
local composter_wieldimg = minetest.inventorycube("mcl_composter_top.png", "mcl_composter_side.png", "mcl_composter_side.png")
--
-- Register empty composter
-- Register empty composter node
-- This is the base model that is craftable and can be placed in an inventory
--
minetest.register_node("mcl_composters:composter", {
@ -233,10 +235,6 @@ minetest.register_node("mcl_composters:composter", {
_tt_help = S("Converts organic items into bonemeal"),
_doc_items_longdesc = composter_longdesc,
_doc_items_usagehelp = composter_usagehelp,
-- FIXME: mcl_composter_side.png is fugly. maybe somehow use minetest.inventorycube(img1, img2, img3)
-- eeeww, that is also ugly and weird
inventory_image = composter_wieldimg,
--inventory_image = "mcl_composter_side.png",
paramtype = "light",
drawtype = "nodebox",
node_box = composter_get_nodeboxes(0),
@ -255,7 +253,7 @@ minetest.register_node("mcl_composters:composter", {
sounds = mcl_sounds.node_sound_wood_defaults(),
_mcl_hardness = 2,
_mcl_blast_resistance = 2,
_compost_level = 0,
_mcl_compost_level = 0,
on_rightclick = composter_add_item
})
@ -289,7 +287,7 @@ local function register_filled_composter(level)
drop = "mcl_composters:composter",
_mcl_hardness = 2,
_mcl_blast_resistance = 2,
_compost_level = level,
_mcl_compost_level = level,
on_rightclick = composter_add_item,
on_timer = composter_ready
})
@ -334,6 +332,12 @@ minetest.register_node("mcl_composters:composter_ready", {
drop = "mcl_composters:composter",
_mcl_hardness = 2,
_mcl_blast_resistance = 2,
_compost_level = 7,
_mcl_compost_level = 7,
on_rightclick = composter_harvest
})
-- Add entry aliases for the Help
if minetest.get_modpath("doc") then
doc.add_entry_alias("nodes", "mcl_composters:composter",
"nodes", "mcl_composters:composter_ready" )
end

View File

@ -1,7 +1,7 @@
# textdomain: mcl_composters
Composter=
Composters can convert various organic items into bonemeal.=
Use organic items on the composter to fill it with layers of compost. Every time an item is put in the composter, there is a chance that the composter adds another layer of compost. Some items have a bigger chance of adding an extra layer than other items. After filling up with 7 layers of compost, the composter is full and bone meal can be retrieved from it. Taking out the bone meal empties the composter.=
Use organic items on the composter to fill it with layers of compost. Every time an item is put in the composter, there is a chance that the composter adds another layer of compost. Some items have a bigger chance of adding an extra layer than other items. After filling up with 7 layers of compost, the composter is full. After a delay of approximately one second the composter becomes ready and bone meal can be retrieved from it. Right-clicking the composter takes out the bone meal empties the composter."=
filled=
ready for harvest=
Converts organic items into bonemeal=

View File

@ -1,5 +1,5 @@
name = mcl_composters
author = kabou
description = composters
depends = mcl_core, mcl_sounds
description = Composters can convert various organic items into bonemeal.
depends = mcl_core, mcl_sounds, mcl_dye
optional_depends = doc

Binary file not shown.

Before

Width:  |  Height:  |  Size: 395 B

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 223 B