Make cocoas grow
This commit is contained in:
parent
a50066a9b6
commit
02b6cc11f5
|
@ -1,7 +1,7 @@
|
||||||
mcl_cocoas = {}
|
mcl_cocoas = {}
|
||||||
|
|
||||||
-- place cocoa
|
-- Place cocoa
|
||||||
function mcl_cocoas.place_cocoa(itemstack, placer, pointed_thing, plantname)
|
function mcl_cocoas.place(itemstack, placer, pointed_thing, plantname)
|
||||||
|
|
||||||
local pt = pointed_thing
|
local pt = pointed_thing
|
||||||
|
|
||||||
|
@ -50,11 +50,25 @@ function mcl_cocoas.place_cocoa(itemstack, placer, pointed_thing, plantname)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Attempts to grow a cocoa at pos, returns true when grown, returns false if there's no cocoa
|
||||||
|
-- or it is already at full size
|
||||||
|
function mcl_cocoas.grow(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
if node.name == "mcl_cocoas:cocoa_1" then
|
||||||
|
minetest.set_node(pos, {name = "mcl_cocoas:cocoa_2", param2 = node.param2})
|
||||||
|
elseif node.name == "mcl_cocoas:cocoa_2" then
|
||||||
|
minetest.set_node(pos, {name = "mcl_cocoas:cocoa_3", param2 = node.param2})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Note: cocoa beans are implemented as mcl_dye:brown
|
-- Note: cocoa beans are implemented as mcl_dye:brown
|
||||||
|
|
||||||
-- Cocoa definition
|
-- Cocoa definition
|
||||||
|
-- 1st stage
|
||||||
local crop_def = {
|
local crop_def = {
|
||||||
description = "Cocoa (Stage 0)",
|
description = "Young Cocoa",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
"[combine:32x32:12,2=mcl_cocoas_cocoa_stage_0.png", "[combine:32x32:12,22=mcl_cocoas_cocoa_stage_0.png",
|
"[combine:32x32:12,2=mcl_cocoas_cocoa_stage_0.png", "[combine:32x32:12,22=mcl_cocoas_cocoa_stage_0.png",
|
||||||
|
@ -92,10 +106,10 @@ local crop_def = {
|
||||||
sounds = mcl_sounds.node_sound_wood_defaults()
|
sounds = mcl_sounds.node_sound_wood_defaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
-- stage 1
|
-- 2nd stage
|
||||||
minetest.register_node("mcl_cocoas:cocoa_1", table.copy(crop_def))
|
minetest.register_node("mcl_cocoas:cocoa_1", table.copy(crop_def))
|
||||||
|
|
||||||
crop_def.description = "Cocoa (Stage 1)"
|
crop_def.description = "Medium Cocoa"
|
||||||
crop_def.tiles = {
|
crop_def.tiles = {
|
||||||
"[combine:32x32:10,2=mcl_cocoas_cocoa_stage_1.png", "[combine:32x32:10,18=mcl_cocoas_cocoa_stage_1.png",
|
"[combine:32x32:10,2=mcl_cocoas_cocoa_stage_1.png", "[combine:32x32:10,18=mcl_cocoas_cocoa_stage_1.png",
|
||||||
"mcl_cocoas_cocoa_stage_1.png", "mcl_cocoas_cocoa_stage_1.png^[transformFX",
|
"mcl_cocoas_cocoa_stage_1.png", "mcl_cocoas_cocoa_stage_1.png^[transformFX",
|
||||||
|
@ -123,8 +137,8 @@ crop_def.selection_box = {
|
||||||
|
|
||||||
minetest.register_node("mcl_cocoas:cocoa_2", table.copy(crop_def))
|
minetest.register_node("mcl_cocoas:cocoa_2", table.copy(crop_def))
|
||||||
|
|
||||||
-- stage 2 (final)
|
-- Final stage
|
||||||
crop_def.description = "Cocoa (Stage 2)"
|
crop_def.description = "Mature Cocoa"
|
||||||
crop_def.tiles = {
|
crop_def.tiles = {
|
||||||
-- The following 2 textures were derived from the original because the size of the top/bottom is slightly different :-(
|
-- The following 2 textures were derived from the original because the size of the top/bottom is slightly different :-(
|
||||||
-- TODO: Find a way to *only* use the base texture
|
-- TODO: Find a way to *only* use the base texture
|
||||||
|
@ -200,3 +214,14 @@ minetest.register_on_generated(function(minp, maxp)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"mcl_cocoas:cocoa_1", "mcl_cocoas:cocoa_2"},
|
||||||
|
-- Same as potatoes
|
||||||
|
-- TODO: Tweak/balance the growth speed
|
||||||
|
interval = 50,
|
||||||
|
chance = 20,
|
||||||
|
action = function(pos, node)
|
||||||
|
mcl_cocoas.grow(pos)
|
||||||
|
end
|
||||||
|
} )
|
||||||
|
|
||||||
|
|
|
@ -180,11 +180,8 @@ mcl_dye.apply_bone_meal = function(pointed_thing)
|
||||||
minetest.add_node(pos, {name="mcl_farming:melontige_unconnect"})
|
minetest.add_node(pos, {name="mcl_farming:melontige_unconnect"})
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
elseif n.name == "mcl_cocoas:cocoa_1" then
|
elseif n.name == "mcl_cocoas:cocoa_1" or n.name == "mcl_cocoas:cocoa_2" then
|
||||||
minetest.set_node(pos, {name="mcl_cocoas:cocoa_2", param2 = n.param2})
|
mcl_cocoas.grow(pos)
|
||||||
return true
|
|
||||||
elseif n.name == "mcl_cocoas:cocoa_2" then
|
|
||||||
minetest.set_node(pos, {name="mcl_cocoas:cocoa_3", param2 = n.param2})
|
|
||||||
return true
|
return true
|
||||||
elseif n.name ~= "" and n.name == "mcl_core:junglesapling" then
|
elseif n.name ~= "" and n.name == "mcl_core:junglesapling" then
|
||||||
minetest.add_node(pos, {name="air"})
|
minetest.add_node(pos, {name="air"})
|
||||||
|
@ -233,7 +230,7 @@ minetest.register_craftitem("mcl_dye:brown", {
|
||||||
stack_max = 64,
|
stack_max = 64,
|
||||||
groups = dyelocal.dyes[4][3],
|
groups = dyelocal.dyes[4][3],
|
||||||
on_place = function(itemstack, user, pointed_thing)
|
on_place = function(itemstack, user, pointed_thing)
|
||||||
return mcl_cocoas.place_cocoa(itemstack, placer, pointed_thing, "mcl_cocoas:cocoa_1")
|
return mcl_cocoas.place(itemstack, placer, pointed_thing, "mcl_cocoas:cocoa_1")
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user