Added barley, tidied and tweaked code

This commit is contained in:
TenPlus1 2016-03-10 17:45:55 +00:00
parent a91b980797
commit daac92f398
30 changed files with 897 additions and 1734 deletions

View File

@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
Changelog: Changelog:
1.23 - Huge code tweak and tidy done and added barley seeds to be found in dry grass, barley can make flour for bread also.
1.22 - Added grape bushes at high climates which can be cultivated into grape vines using trellis (9 sticks). 1.22 - Added grape bushes at high climates which can be cultivated into grape vines using trellis (9 sticks).
1.21 - Added auto-refill code for planting crops (thanks crabman77), also fixed a few bugs 1.21 - Added auto-refill code for planting crops (thanks crabman77), also fixed a few bugs
1.20b- Tidied code, made api compatible with new 0.4.13 changes and changed to soil texture overlays 1.20b- Tidied code, made api compatible with new 0.4.13 changes and changed to soil texture overlays

96
barley.lua Normal file
View File

@ -0,0 +1,96 @@
-- barley seeds
minetest.register_node("farming:seed_barley", {
description = "Barley Seed",
tiles = {"farming_barley_seed.png"},
inventory_image = "farming_barley_seed.png",
wield_image = "farming_barley_seed.png",
drawtype = "signlike",
groups = {seed = 1, snappy = 3, attached_node = 1},
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
sunlight_propagates = true,
selection_box = farming.select,
on_place = function(itemstack, placer, pointed_thing)
return farming.place_seed(itemstack, placer, pointed_thing, "farming:barley_1")
end,
})
-- harvested barley
minetest.register_craftitem("farming:barley", {
description = "barley",
inventory_image = "farming_barley.png",
})
-- flour
minetest.register_craft({
type = "shapeless",
output = "farming:flour",
recipe = {"farming:barley", "farming:barley", "farming:barley", "farming:barley"}
})
-- barley definition
local crop_def = {
drawtype = "plantlike",
tiles = {"farming_barley_1.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults()
}
-- stage 1
minetest.register_node("farming:barley_1", table.copy(crop_def))
-- stage 2
crop_def.tiles = {"farming_barley_2.png"}
minetest.register_node("farming:barley_2", table.copy(crop_def))
-- stage 3
crop_def.tiles = {"farming_barley_3.png"}
minetest.register_node("farming:barley_3", table.copy(crop_def))
-- stage 4
crop_def.tiles = {"farming_barley_4.png"}
minetest.register_node("farming:barley_4", table.copy(crop_def))
-- stage 5
crop_def.tiles = {"farming_barley_5.png"}
crop_def.drop = {
items = {
{items = {'farming:barley'}, rarity = 2},
{items = {'farming:seed_barley'}, rarity = 2},
}
}
minetest.register_node("farming:barley_5", table.copy(crop_def))
-- stage 6
crop_def.tiles = {"farming_barley_6.png"}
crop_def.drop = {
items = {
{items = {'farming:barley'}, rarity = 2},
{items = {'farming:seed_barley'}, rarity = 1},
}
}
minetest.register_node("farming:barley_6", table.copy(crop_def))
-- stage 7 (final)
crop_def.tiles = {"farming_barley_7.png"}
crop_def.groups.growing = 0
crop_def.drop = {
items = {
{items = {'farming:barley'}, rarity = 1},
{items = {'farming:barley'}, rarity = 3},
{items = {'farming:seed_barley'}, rarity = 1},
{items = {'farming:seed_barley'}, rarity = 3},
}
}
minetest.register_node("farming:barley_7", table.copy(crop_def))

View File

@ -2,39 +2,49 @@
All textures by All textures by
(C) Auke Kok <sofar@foo-projects.org> (C) Auke Kok <sofar@foo-projects.org>
CC-BY-SA-3.0 CC-BY-SA-3.0
--]] ]]
-- beans
minetest.register_craftitem("farming:beans", { minetest.register_craftitem("farming:beans", {
description = "Green Beans", description = "Green Beans",
inventory_image = "farming_beans.png", inventory_image = "farming_beans.png",
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return return
end end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and nod.name == "farming:beanpole" then local nodename = minetest.get_node(pointed_thing.under).name
if nodename == "farming:beanpole" then
minetest.set_node(pointed_thing.under, {name="farming:beanpole_1"}) minetest.set_node(pointed_thing.under, {name="farming:beanpole_1"})
else else
return return
end end
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:take_item() itemstack:take_item()
-- check for refill -- check for refill
if itemstack:get_count() == 0 then if itemstack:get_count() == 0 then
minetest.after(0.20, minetest.after(0.20,
farming.refill_plant, farming.refill_plant,
placer, placer,
"farming:beans", "farming:beans",
placer:get_wield_index() placer:get_wield_index()
) )
end -- END refill end
end end
return itemstack return itemstack
end end
}) })
-- Beans can be used for green dye -- beans can be used for green dye
minetest.register_craft({ minetest.register_craft({
output = "dye:green", output = "dye:green",
recipe = { recipe = {
@ -42,8 +52,7 @@ minetest.register_craft({
} }
}) })
-- Beanpole -- beanpole
minetest.register_node("farming:beanpole", { minetest.register_node("farming:beanpole", {
description = "Bean Pole (place on soil before planting beans)", description = "Bean Pole (place on soil before planting beans)",
drawtype = "plantlike", drawtype = "plantlike",
@ -54,33 +63,41 @@ minetest.register_node("farming:beanpole", {
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
sunlight_propagates = true, sunlight_propagates = true,
drop = { drop = "farming:beanpole",
items = {
{items = {'farming:beanpole'}, rarity = 1},
}
},
selection_box = farming.select, selection_box = farming.select,
groups = {snappy = 3, flammable = 2, attached_node = 1}, groups = {snappy = 3, flammable = 2, attached_node = 1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return return
end end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and minetest.get_item_group(nod.name, "soil") < 2 then local nodename = minetest.get_node(pointed_thing.under).name
if minetest.get_item_group(nodename, "soil") < 2 then
return return
end end
local top = { local top = {
x = pointed_thing.above.x, x = pointed_thing.above.x,
y = pointed_thing.above.y + 1, y = pointed_thing.above.y + 1,
z = pointed_thing.above.z z = pointed_thing.above.z
} }
nod = minetest.get_node_or_nil(top)
if nod and nod.name ~= "air" then return end nodename = minetest.get_node(top).name
if nodename ~= "air" then
return
end
minetest.set_node(pointed_thing.above, {name = "farming:beanpole"}) minetest.set_node(pointed_thing.above, {name = "farming:beanpole"})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack
end end
}) })
@ -100,9 +117,8 @@ minetest.register_craft({
burntime = 10, burntime = 10,
}) })
-- Define Green Bean growth stages -- green bean definition
local crop_def = {
minetest.register_node("farming:beanpole_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_beanpole_1.png"}, tiles = {"farming_beanpole_1.png"},
visual_scale = 1.45, visual_scale = 1.45,
@ -120,101 +136,38 @@ minetest.register_node("farming:beanpole_1", {
snappy = 3, flammable = 3, not_in_creative_inventory = 1, snappy = 3, flammable = 3, not_in_creative_inventory = 1,
attached_node = 1, growing = 1 attached_node = 1, growing = 1
}, },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults()
}) }
minetest.register_node("farming:beanpole_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:beanpole_1", table.copy(crop_def))
tiles = {"farming_beanpole_2.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:beanpole'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:beanpole_3", { -- stage2
drawtype = "plantlike", crop_def.tiles = {"farming_beanpole_2.png"}
tiles = {"farming_beanpole_3.png"}, minetest.register_node("farming:beanpole_2", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:beanpole'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- stage 3
crop_def.tiles = {"farming_beanpole_3.png"}
minetest.register_node("farming:beanpole_3", table.copy(crop_def))
minetest.register_node("farming:beanpole_4", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_beanpole_4.png"}
tiles = {"farming_beanpole_4.png"}, minetest.register_node("farming:beanpole_4", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:beanpole'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 5 (final)
crop_def.tiles = {"farming_beanpole_5.png"}
minetest.register_node("farming:beanpole_5", { crop_def.groups.growing = 0
drawtype = "plantlike", crop_def.drop = {
tiles = {"farming_beanpole_5.png"}, items = {
visual_scale = 1.45, {items = {'farming:beanpole'}, rarity = 1},
paramtype = "light", {items = {'farming:beans 3'}, rarity = 1},
walkable = false, {items = {'farming:beans 2'}, rarity = 2},
buildable_to = true, {items = {'farming:beans 2'}, rarity = 3},
sunlight_propagates = true, }
drop = { }
items = { minetest.register_node("farming:beanpole_5", table.copy(crop_def))
{items = {'farming:beanpole'}, rarity = 1},
{items = {'farming:beans 3'}, rarity = 1},
{items = {'farming:beans 2'}, rarity = 2},
{items = {'farming:beans 2'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Wild Green Bean Bush (this is what you find on the map)
-- wild green bean bush (this is what you find on the map)
minetest.register_node("farming:beanbush", { minetest.register_node("farming:beanbush", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_beanbush.png"}, tiles = {"farming_beanbush.png"},
@ -236,4 +189,4 @@ minetest.register_node("farming:beanbush", {
not_in_creative_inventory=1 not_in_creative_inventory=1
}, },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
}) })

View File

@ -1,6 +1,5 @@
--= Blueberries -- blueberries
minetest.register_craftitem("farming:blueberries", { minetest.register_craftitem("farming:blueberries", {
description = "Blueberries", description = "Blueberries",
inventory_image = "farming_blueberries.png", inventory_image = "farming_blueberries.png",
@ -10,7 +9,7 @@ minetest.register_craftitem("farming:blueberries", {
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
}) })
-- Blueberry Muffin (Thanks to sosogirl123 for muffin image in deviantart.com) -- blueberry muffin (thanks to sosogirl123 @ deviantart.com for muffin image)
minetest.register_craftitem("farming:muffin_blueberry", { minetest.register_craftitem("farming:muffin_blueberry", {
description = "Blueberry Muffin", description = "Blueberry Muffin",
@ -25,9 +24,8 @@ minetest.register_craft({
} }
}) })
-- Define Blueberry growth stages -- blueberry definition
local crop_def = {
minetest.register_node("farming:blueberry_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_blueberry_1.png"}, tiles = {"farming_blueberry_1.png"},
paramtype = "light", paramtype = "light",
@ -40,64 +38,28 @@ minetest.register_node("farming:blueberry_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:blueberry_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:blueberry_1", table.copy(crop_def))
tiles = {"farming_blueberry_2.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:blueberry_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_blueberry_2.png"}
tiles = {"farming_blueberry_3.png"}, minetest.register_node("farming:blueberry_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 3
crop_def.tiles = {"farming_blueberry_3.png"}
minetest.register_node("farming:blueberry_3", table.copy(crop_def))
minetest.register_node("farming:blueberry_4", { -- stage 4 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_blueberry_4.png"}
tiles = {"farming_blueberry_4.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
sunlight_propagates = true, items = {
waving = 1, {items = {'farming:blueberries 2'}, rarity = 1},
walkable = false, {items = {'farming:blueberries'}, rarity = 2},
buildable_to = true, {items = {'farming:blueberries'}, rarity = 3},
drop = { }
items = { }
{items = {'farming:blueberries 2'}, rarity = 1}, minetest.register_node("farming:blueberry_4", table.copy(crop_def))
{items = {'farming:blueberries'}, rarity = 2},
{items = {'farming:blueberries'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory=1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -1,7 +1,10 @@
--= Carrot (Original textures from PixelBox texture pack) --[[
-- https://forum.minetest.net/viewtopic.php?id=4990 Original textures from PixelBox texture pack
https://forum.minetest.net/viewtopic.php?id=4990
]]
-- carrot
minetest.register_craftitem("farming:carrot", { minetest.register_craftitem("farming:carrot", {
description = "Carrot", description = "Carrot",
inventory_image = "farming_carrot.png", inventory_image = "farming_carrot.png",
@ -11,8 +14,7 @@ minetest.register_craftitem("farming:carrot", {
on_use = minetest.item_eat(4), on_use = minetest.item_eat(4),
}) })
-- Golden Carrot -- golden carrot
minetest.register_craftitem("farming:carrot_gold", { minetest.register_craftitem("farming:carrot_gold", {
description = "Golden Carrot", description = "Golden Carrot",
inventory_image = "farming_carrot_gold.png", inventory_image = "farming_carrot_gold.png",
@ -28,9 +30,8 @@ minetest.register_craft({
} }
}) })
-- Define Carrot growth stages -- carrot definition
local crop_def = {
minetest.register_node("farming:carrot_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_carrot_1.png"}, tiles = {"farming_carrot_1.png"},
paramtype = "light", paramtype = "light",
@ -43,133 +44,50 @@ minetest.register_node("farming:carrot_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:carrot_2", {
drawtype = "plantlike",
tiles = {"farming_carrot_2.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:carrot_3", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:carrot_1", table.copy(crop_def))
tiles = {"farming_carrot_3.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:carrot_4", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_carrot_2.png"}
tiles = {"farming_carrot_4.png"}, minetest.register_node("farming:carrot_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:carrot_5", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_carrot_3.png"}
tiles = {"farming_carrot_5.png"}, minetest.register_node("farming:carrot_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:carrot_6", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_carrot_4.png"}
tiles = {"farming_carrot_6.png"}, minetest.register_node("farming:carrot_4", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:carrot_7", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_carrot_5.png"}
tiles = {"farming_carrot_7.png"}, minetest.register_node("farming:carrot_5", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {'farming:carrot'}, rarity = 1},
{items = {'farming:carrot 2'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 6
crop_def.tiles = {"farming_carrot_6.png"}
minetest.register_node("farming:carrot_6", table.copy(crop_def))
minetest.register_node("farming:carrot_8", { -- stage 7
drawtype = "plantlike", crop_def.tiles = {"farming_carrot_7.png"}
tiles = {"farming_carrot_8.png"}, crop_def.drop = {
paramtype = "light", items = {
sunlight_propagates = true, {items = {'farming:carrot'}, rarity = 1},
waving = 1, {items = {'farming:carrot 2'}, rarity = 3},
walkable = false, }
buildable_to = true, }
drop = { minetest.register_node("farming:carrot_7", table.copy(crop_def))
items = {
{items = {'farming:carrot 2'}, rarity = 1}, -- stage 8 (final)
{items = {'farming:carrot 3'}, rarity = 2}, crop_def.tiles = {"farming_carrot_8.png"}
} crop_def.groups.growing = 0
}, crop_def.drop = {
selection_box = farming.select, items = {
groups = { {items = {'farming:carrot 2'}, rarity = 1},
snappy = 3, flammable = 2, plant = 1, attached_node = 1, {items = {'farming:carrot 3'}, rarity = 2},
not_in_creative_inventory = 1 }
}, }
sounds = default.node_sound_leaves_defaults(), minetest.register_node("farming:carrot_8", table.copy(crop_def))
})

134
cocoa.lua
View File

@ -1,17 +1,17 @@
-- Place Cocoa -- place cocoa
function place_cocoa(itemstack, placer, pointed_thing, plantname) function place_cocoa(itemstack, placer, pointed_thing, plantname)
local pt = pointed_thing local pt = pointed_thing
-- check if pointing at a node -- check if pointing at a node
if not pt and pt.type ~= "node" then if not pt or pt.type ~= "node" then
return return
end end
local under = minetest.get_node(pt.under) local under = minetest.get_node(pt.under)
-- return if any of the nodes is not registered -- return if any of the nodes are not registered
if not minetest.registered_nodes[under.name] then if not minetest.registered_nodes[under.name] then
return return
end end
@ -20,26 +20,30 @@ function place_cocoa(itemstack, placer, pointed_thing, plantname)
if under.name ~= "default:jungletree" then if under.name ~= "default:jungletree" then
return return
end end
-- add the node and remove 1 item from the itemstack -- add the node and remove 1 item from the itemstack
minetest.set_node(pt.above, {name = plantname}) minetest.set_node(pt.above, {name = plantname})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:take_item() itemstack:take_item()
-- check for refill -- check for refill
if itemstack:get_count() == 0 then if itemstack:get_count() == 0 then
minetest.after(0.20, minetest.after(0.20,
farming.refill_plant, farming.refill_plant,
placer, placer,
"farming:cocoa_beans", "farming:cocoa_beans",
placer:get_wield_index() placer:get_wield_index()
) )
end -- END refill end
end end
return itemstack return itemstack
end end
--= Cocoa -- cocoa beans
minetest.register_craftitem("farming:cocoa_beans", { minetest.register_craftitem("farming:cocoa_beans", {
description = "Cocoa Beans", description = "Cocoa Beans",
inventory_image = "farming_cocoa_beans.png", inventory_image = "farming_cocoa_beans.png",
@ -55,8 +59,7 @@ minetest.register_craft( {
} }
}) })
-- Cookie -- chocolate cookie
minetest.register_craftitem("farming:cookie", { minetest.register_craftitem("farming:cookie", {
description = "Cookie", description = "Cookie",
inventory_image = "farming_cookie.png", inventory_image = "farming_cookie.png",
@ -70,8 +73,7 @@ minetest.register_craft( {
} }
}) })
-- Bar of Dark Chocolate (Thanks to Ice Pandora for her deviantart.com chocolate tutorial) -- bar of dark chocolate (thanks to Ice Pandora for her deviantart.com chocolate tutorial)
minetest.register_craftitem("farming:chocolate_dark", { minetest.register_craftitem("farming:chocolate_dark", {
description = "Bar of Dark Chocolate", description = "Bar of Dark Chocolate",
inventory_image = "farming_chocolate_dark.png", inventory_image = "farming_chocolate_dark.png",
@ -85,9 +87,8 @@ minetest.register_craft( {
} }
}) })
-- Define Coffee growth stages -- cocoa definition
local crop_def = {
minetest.register_node("farming:cocoa_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_cocoa_1.png"}, tiles = {"farming_cocoa_1.png"},
paramtype = "light", paramtype = "light",
@ -105,81 +106,64 @@ minetest.register_node("farming:cocoa_1", {
snappy = 3, flammable = 2, plant = 1, growing = 1, snappy = 3, flammable = 2, plant = 1, growing = 1,
not_in_creative_inventory=1, leafdecay = 1, leafdecay_drop = 1 not_in_creative_inventory=1, leafdecay = 1, leafdecay_drop = 1
}, },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults()
}) }
minetest.register_node("farming:cocoa_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:cocoa_1", table.copy(crop_def))
tiles = {"farming_cocoa_2.png"},
paramtype = "light",
walkable = true,
drop = {
items = {
{items = {'farming:cocoa_beans 1'}, rarity = 1},
}
},
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
},
groups = {
snappy = 3, flammable = 2, plant = 1, growing = 1,
not_in_creative_inventory=1, leafdecay = 1, leafdecay_drop = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of Cocoa growth does not have growing=1 so abm never has to check these -- stage2
crop_def.tiles = {"farming_cocoa_2.png"}
crop_def.drop = {
items = {
{items = {'farming:cocoa_beans 1'}, rarity = 1},
}
}
minetest.register_node("farming:cocoa_2", table.copy(crop_def))
minetest.register_node("farming:cocoa_3", { -- stage 3 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_cocoa_3.png"}
tiles = {"farming_cocoa_3.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
walkable = true, items = {
drop = { {items = {'farming:cocoa_beans 2'}, rarity = 1},
items = { {items = {'farming:cocoa_beans 1'}, rarity = 2},
{items = {'farming:cocoa_beans 2'}, rarity = 1}, }
{items = {'farming:cocoa_beans 1'}, rarity = 2}, }
} minetest.register_node("farming:cocoa_3", table.copy(crop_def))
},
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
},
groups = {
snappy = 3, flammable = 2, plant = 1,
not_in_creative_inventory = 1, leafdecay = 1, leafdecay_drop = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Abm to add random Cocoa Pod to Jungle Tree trunks
-- add random cocoa pods to jungle tree trunks
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:jungletree"}, nodenames = {"default:jungletree"},
neighbors = {"default:jungleleaves", "moretrees:jungletree_leaves_green"}, neighbors = {"default:jungleleaves", "moretrees:jungletree_leaves_green"},
interval = 80, interval = 8,
chance = 20, chance = 80,
catch_up = false,
action = function(pos, node) action = function(pos, node)
local dir = math.random(1,50) local dir = math.random(1, 50)
if dir == 1 then pos.x = pos.x + 1 if dir == 1 then
elseif dir == 2 then pos.x = pos.x - 1 pos.x = pos.x + 1
elseif dir == 3 then pos.z = pos.z + 1 elseif dir == 2 then
elseif dir == 4 then pos.z = pos.z -1 pos.x = pos.x - 1
elseif dir == 3 then
pos.z = pos.z + 1
elseif dir == 4 then
pos.z = pos.z -1
else return else return
end end
local nod = minetest.get_node_or_nil(pos)
if nod then nod = nod.name else return end
if nod == "air" local nodename = minetest.get_node(pos).name
if nodename == "air"
and minetest.get_node_light(pos) > 12 then and minetest.get_node_light(pos) > 12 then
-- print ("COCOA", pos.x, pos.y, pos.z)
--print ("Cocoa Pod added at " .. minetest.pos_to_string(pos))
minetest.set_node(pos, { minetest.set_node(pos, {
name = "farming:cocoa_"..tostring(math.random(1, 3)) name = "farming:cocoa_" .. tostring(math.random(1, 3))
}) })
end end
end, end,
}) })

View File

@ -1,6 +1,5 @@
--= Coffee -- coffee
minetest.register_craftitem("farming:coffee_beans", { minetest.register_craftitem("farming:coffee_beans", {
description = "Coffee Beans", description = "Coffee Beans",
inventory_image = "farming_coffee_beans.png", inventory_image = "farming_coffee_beans.png",
@ -9,12 +8,8 @@ minetest.register_craftitem("farming:coffee_beans", {
end, end,
}) })
--= Glass Cup
--minetest.register_craftitem("farming:drinking_cup", {
-- description = "Drinking Cup",
-- inventory_image = "vessels_drinking_cup.png",
--})
-- drinking cup
minetest.register_node("farming:drinking_cup", { minetest.register_node("farming:drinking_cup", {
description = "Drinking Cup (empty)", description = "Drinking Cup (empty)",
drawtype = "plantlike", drawtype = "plantlike",
@ -39,15 +34,9 @@ minetest.register_craft( {
} }
}) })
--= Cold Cup of Coffee -- cold cup of coffee
--minetest.register_craftitem("farming:coffee_cup", {
-- description = "Cold Cup of Coffee",
-- inventory_image = "farming_coffee_cup.png",
-- on_use = minetest.item_eat(2, "farming:drinking_cup"),
--})
minetest.register_node("farming:coffee_cup", { minetest.register_node("farming:coffee_cup", {
description = "Cup of Coffee (cold)", description = "Cold Cup of Coffee",
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_coffee_cup.png"}, tiles = {"farming_coffee_cup.png"},
inventory_image = "farming_coffee_cup.png", inventory_image = "farming_coffee_cup.png",
@ -67,8 +56,6 @@ minetest.register_craft( {
output = "farming:coffee_cup", output = "farming:coffee_cup",
recipe = { recipe = {
{"farming:drinking_cup", "farming:coffee_beans","bucket:bucket_water"}, {"farming:drinking_cup", "farming:coffee_beans","bucket:bucket_water"},
{"","",""},
{"","",""}
}, },
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}} replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}}
}) })
@ -80,15 +67,9 @@ minetest.register_craft({
recipe = "farming:coffee_cup" recipe = "farming:coffee_cup"
}) })
--= Hot Cup of Coffee -- hot cup of coffee
--minetest.register_craftitem("farming:coffee_cup_hot", {
-- description = "Hot Cup of Coffee",
-- inventory_image = "farming_coffee_cup_hot.png",
-- on_use = minetest.item_eat(3, "farming:drinking_cup"),
--})
minetest.register_node("farming:coffee_cup_hot", { minetest.register_node("farming:coffee_cup_hot", {
description = "Cup of Coffee (hot)", description = "Hot Cup of Coffee",
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_coffee_cup_hot.png"}, tiles = {"farming_coffee_cup_hot.png"},
inventory_image = "farming_coffee_cup_hot.png", inventory_image = "farming_coffee_cup_hot.png",
@ -104,9 +85,8 @@ minetest.register_node("farming:coffee_cup_hot", {
sounds = default.node_sound_glass_defaults(), sounds = default.node_sound_glass_defaults(),
}) })
-- Define Coffee growth stages -- coffee definition
local crop_def = {
minetest.register_node("farming:coffee_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_coffee_1.png"}, tiles = {"farming_coffee_1.png"},
paramtype = "light", paramtype = "light",
@ -119,81 +99,32 @@ minetest.register_node("farming:coffee_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:coffee_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:coffee_1", table.copy(crop_def))
tiles = {"farming_coffee_2.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:coffee_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_coffee_2.png"}
tiles = {"farming_coffee_3.png"}, minetest.register_node("farming:coffee_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:coffee_4", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_coffee_3.png"}
tiles = {"farming_coffee_4.png"}, minetest.register_node("farming:coffee_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth doesn not have growing group so abm never checks these -- stage 4
crop_def.tiles = {"farming_coffee_4.png"}
minetest.register_node("farming:coffee_4", table.copy(crop_def))
minetest.register_node("farming:coffee_5", { -- stage 5 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_coffee_5.png"}
tiles = {"farming_coffee_5.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
sunlight_propagates = true, items = {
waving = 1, {items = {'farming:coffee_beans 2'}, rarity = 1},
walkable = false, {items = {'farming:coffee_beans 2'}, rarity = 2},
buildable_to = true, {items = {'farming:coffee_beans 2'}, rarity = 3},
drop = { }
items = { }
{items = {'farming:coffee_beans 2'}, rarity = 1}, minetest.register_node("farming:coffee_5", table.copy(crop_def))
{items = {'farming:coffee_beans 2'}, rarity = 2},
{items = {'farming:coffee_beans 2'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory=1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -94,4 +94,4 @@ minetest.register_alias("farming_plus:tomato_3", "farming:tomato_6")
minetest.register_alias("farming_plus:tomato", "farming:tomato_8") minetest.register_alias("farming_plus:tomato", "farming:tomato_8")
-- Weed -- Weed
minetest.register_alias("farming:weed", "default:grass_2") minetest.register_alias("farming:weed", "default:grass_2")

186
corn.lua
View File

@ -1,7 +1,10 @@
--= Corn (Original textures from GeMinecraft) --[[
-- http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1440575-1-2-5-generation-minecraft-beta-1-2-farming-and Original textures from GeMinecraft
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/1440575-1-2-5-generation-minecraft-beta-1-2-farming-and
]]
-- corn
minetest.register_craftitem("farming:corn", { minetest.register_craftitem("farming:corn", {
description = "Corn", description = "Corn",
inventory_image = "farming_corn.png", inventory_image = "farming_corn.png",
@ -11,8 +14,7 @@ minetest.register_craftitem("farming:corn", {
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
}) })
--= Corn on the Cob (Texture by TenPlus1) -- corn on the cob (texture by TenPlus1)
minetest.register_craftitem("farming:corn_cob", { minetest.register_craftitem("farming:corn_cob", {
description = "Corn on the Cob", description = "Corn on the Cob",
inventory_image = "farming_corn_cob.png", inventory_image = "farming_corn_cob.png",
@ -26,8 +28,7 @@ minetest.register_craft({
recipe = "farming:corn" recipe = "farming:corn"
}) })
--= Ethanol (Thanks to JKMurray for this idea) -- ethanol (thanks to JKMurray for this idea)
minetest.register_craftitem("farming:bottle_ethanol", { minetest.register_craftitem("farming:bottle_ethanol", {
description = "Bottle of Ethanol", description = "Bottle of Ethanol",
inventory_image = "farming_bottle_ethanol.png", inventory_image = "farming_bottle_ethanol.png",
@ -48,9 +49,8 @@ minetest.register_craft({
replacements = {{ "farming:bottle_ethanol", "vessels:glass_bottle"}} replacements = {{ "farming:bottle_ethanol", "vessels:glass_bottle"}}
}) })
-- Define Corn growth stages -- corn definition
local crop_def = {
minetest.register_node("farming:corn_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_corn_1.png"}, tiles = {"farming_corn_1.png"},
paramtype = "light", paramtype = "light",
@ -63,138 +63,52 @@ minetest.register_node("farming:corn_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:corn_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:corn_1", table.copy(crop_def))
tiles = {"farming_corn_2.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:corn_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_corn_2.png"}
tiles = {"farming_corn_3.png"}, minetest.register_node("farming:corn_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:corn_4", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_corn_3.png"}
tiles = {"farming_corn_4.png"}, minetest.register_node("farming:corn_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:corn_5", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_corn_4.png"}
tiles = {"farming_corn_5.png"}, minetest.register_node("farming:corn_4", table.copy(crop_def))
paramtype = "light",
waving = 1,
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:corn_6", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_corn_5.png"}
tiles = {"farming_corn_6.png"}, minetest.register_node("farming:corn_5", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
waving = 1,
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:corn_7", { -- stage 6
drawtype = "plantlike", crop_def.tiles = {"farming_corn_6.png"}
tiles = {"farming_corn_7.png"}, crop_def.visual_scale = 1.45
visual_scale = 1.45, minetest.register_node("farming:corn_6", table.copy(crop_def))
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {'farming:corn'}, rarity = 1},
{items = {'farming:corn'}, rarity = 2},
{items = {'farming:corn'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth doesn not have growing group so abm never checks these -- stage 7
crop_def.tiles = {"farming_corn_7.png"}
crop_def.drop = {
items = {
{items = {'farming:corn'}, rarity = 1},
{items = {'farming:corn'}, rarity = 2},
{items = {'farming:corn'}, rarity = 3},
}
}
minetest.register_node("farming:corn_7", table.copy(crop_def))
minetest.register_node("farming:corn_8", { -- stage 8 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_corn_8.png"}
tiles = {"farming_corn_8.png"}, crop_def.groups.growing = 0
visual_scale = 1.45, crop_def.drop = {
paramtype = "light", items = {
waving = 1, {items = {'farming:corn 2'}, rarity = 1},
walkable = false, {items = {'farming:corn 2'}, rarity = 2},
buildable_to = true, {items = {'farming:corn 2'}, rarity = 2},
drop = { }
items = { }
{items = {'farming:corn 2'}, rarity = 1}, minetest.register_node("farming:corn_8", table.copy(crop_def))
{items = {'farming:corn 2'}, rarity = 2},
{items = {'farming:corn 2'}, rarity = 2},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -1,13 +1,5 @@
-- Cotton Seed
--minetest.register_craftitem("farming:seed_cotton", {
-- description = "Cotton Seed",
-- inventory_image = "farming_cotton_seed.png",
-- on_place = function(itemstack, placer, pointed_thing)
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
-- end,
--})
-- cotton seeds
minetest.register_node("farming:seed_cotton", { minetest.register_node("farming:seed_cotton", {
description = "Cotton Seed", description = "Cotton Seed",
tiles = {"farming_cotton_seed.png"}, tiles = {"farming_cotton_seed.png"},
@ -25,7 +17,7 @@ minetest.register_node("farming:seed_cotton", {
end, end,
}) })
-- Cotton -- cotton / string
minetest.register_craftitem("farming:cotton", { minetest.register_craftitem("farming:cotton", {
description = "Cotton", description = "Cotton",
@ -34,8 +26,7 @@ minetest.register_craftitem("farming:cotton", {
minetest.register_alias("farming:string", "farming:cotton") minetest.register_alias("farming:string", "farming:cotton")
-- String to Wool -- cotton to wool
minetest.register_craft({ minetest.register_craft({
output = "wool:white", output = "wool:white",
recipe = { recipe = {
@ -44,9 +35,8 @@ minetest.register_craft({
} }
}) })
-- Define Cotton growth stages -- cotton definition
local crop_def = {
minetest.register_node("farming:cotton_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_cotton_1.png"}, tiles = {"farming_cotton_1.png"},
paramtype = "light", paramtype = "light",
@ -59,147 +49,66 @@ minetest.register_node("farming:cotton_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:cotton_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:cotton_1", table.copy(crop_def))
tiles = {"farming_cotton_2.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:cotton_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_cotton_2.png"}
tiles = {"farming_cotton_3.png"}, minetest.register_node("farming:cotton_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:cotton_4", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_cotton_3.png"}
tiles = {"farming_cotton_4.png"}, minetest.register_node("farming:cotton_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:cotton_5", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_cotton_4.png"}
tiles = {"farming_cotton_5.png"}, minetest.register_node("farming:cotton_4", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {"farming:seed_cotton"}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:cotton_6", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_cotton_5.png"}
tiles = {"farming_cotton_6.png"}, crop_def.drop = {
paramtype = "light", items = {
waving = 1, {items = {"farming:seed_cotton"}, rarity = 1},
walkable = false, }
buildable_to = true, }
drop = { minetest.register_node("farming:cotton_5", table.copy(crop_def))
items = {
{items = {"farming:cotton"}, rarity = 1},
{items = {"farming:cotton"}, rarity = 2},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:cotton_7", { -- stage 6
drawtype = "plantlike", crop_def.tiles = {"farming_cotton_6.png"}
tiles = {"farming_cotton_7.png"}, crop_def.drop = {
paramtype = "light", items = {
waving = 1, {items = {"farming:cotton"}, rarity = 1},
walkable = false, {items = {"farming:cotton"}, rarity = 2},
buildable_to = true, }
drop = { }
items = { minetest.register_node("farming:cotton_6", table.copy(crop_def))
{items = {"farming:cotton"}, rarity = 1},
{items = {"farming:cotton"}, rarity = 2},
{items = {"farming:seed_cotton"}, rarity = 1},
{items = {"farming:seed_cotton"}, rarity = 2},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 7
crop_def.tiles = {"farming_cotton_7.png"}
crop_def.drop = {
items = {
{items = {"farming:cotton"}, rarity = 1},
{items = {"farming:cotton"}, rarity = 2},
{items = {"farming:seed_cotton"}, rarity = 1},
{items = {"farming:seed_cotton"}, rarity = 2},
}
}
minetest.register_node("farming:cotton_7", table.copy(crop_def))
minetest.register_node("farming:cotton_8", { -- stage 8 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_cotton_8.png"}
tiles = {"farming_cotton_8.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
waving = 1, items = {
walkable = false, {items = {"farming:string"}, rarity = 1},
buildable_to = true, {items = {"farming:string"}, rarity = 2},
drop = { {items = {"farming:string"}, rarity = 3},
items = { {items = {"farming:seed_cotton"}, rarity = 1},
{items = {"farming:string"}, rarity = 1}, {items = {"farming:seed_cotton"}, rarity = 2},
{items = {"farming:string"}, rarity = 2}, {items = {"farming:seed_cotton"}, rarity = 3},
{items = {"farming:string"}, rarity = 3}, }
{items = {"farming:seed_cotton"}, rarity = 1}, }
{items = {"farming:seed_cotton"}, rarity = 2}, minetest.register_node("farming:cotton_8", table.copy(crop_def))
{items = {"farming:seed_cotton"}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -1,7 +1,10 @@
--= Cucumber (Original textures from DocFarming mod) --[[
-- https://forum.minetest.net/viewtopic.php?id=3948 Original textures from DocFarming mod
https://forum.minetest.net/viewtopic.php?id=3948
]]
-- cucumber
minetest.register_craftitem("farming:cucumber", { minetest.register_craftitem("farming:cucumber", {
description = "Cucumber", description = "Cucumber",
inventory_image = "farming_cucumber.png", inventory_image = "farming_cucumber.png",
@ -11,9 +14,8 @@ minetest.register_craftitem("farming:cucumber", {
on_use = minetest.item_eat(4), on_use = minetest.item_eat(4),
}) })
-- Define Cucumber growth stages -- cucumber definition
local crop_def = {
minetest.register_node("farming:cucumber_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_cucumber_1.png"}, tiles = {"farming_cucumber_1.png"},
paramtype = "light", paramtype = "light",
@ -25,60 +27,27 @@ minetest.register_node("farming:cucumber_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:cucumber_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:cucumber_1", table.copy(crop_def))
tiles = {"farming_cucumber_2.png"},
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:cucumber_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_cucumber_2.png"}
tiles = {"farming_cucumber_3.png"}, minetest.register_node("farming:cucumber_2", table.copy(crop_def))
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 3
crop_def.tiles = {"farming_cucumber_3.png"}
minetest.register_node("farming:cucumber_3", table.copy(crop_def))
minetest.register_node("farming:cucumber_4", { -- stage 4 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_cucumber_4.png"}
tiles = {"farming_cucumber_4.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
waving = 1, items = {
walkable = false, {items = {'farming:cucumber'}, rarity = 1},
buildable_to = true, {items = {'farming:cucumber 2'}, rarity = 2},
drop = { }
items = { }
{items = {'farming:cucumber'}, rarity = 1}, minetest.register_node("farming:cucumber_4", table.copy(crop_def))
{items = {'farming:cucumber 2'}, rarity = 2},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -1,36 +1,45 @@
-- Grapes
-- grapes
minetest.register_craftitem("farming:grapes", { minetest.register_craftitem("farming:grapes", {
description = "Grapes", description = "Grapes",
inventory_image = "farming_grapes.png", inventory_image = "farming_grapes.png",
on_use = minetest.item_eat(2), on_use = minetest.item_eat(2),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return return
end end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and nod.name == "farming:trellis" then local nodename = minetest.get_node(pointed_thing.under).name
if nodename == "farming:trellis" then
minetest.set_node(pointed_thing.under, {name="farming:grapes_1"}) minetest.set_node(pointed_thing.under, {name="farming:grapes_1"})
else else
return return
end end
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:take_item() itemstack:take_item()
-- check for refill -- check for refill
if itemstack:get_count() == 0 then if itemstack:get_count() == 0 then
minetest.after(0.20, minetest.after(0.20,
farming.refill_plant, farming.refill_plant,
placer, placer,
"farming:grapes", "farming:grapes",
placer:get_wield_index() placer:get_wield_index()
) )
end -- END refill end
end end
return itemstack return itemstack
end end
}) })
-- Grapes can be used for violet dye -- grapes can be used for violet dye
minetest.register_craft({ minetest.register_craft({
output = "dye:violet", output = "dye:violet",
recipe = { recipe = {
@ -38,8 +47,7 @@ minetest.register_craft({
} }
}) })
-- Trellis -- trellis
minetest.register_node("farming:trellis", { minetest.register_node("farming:trellis", {
description = "Trellis (place on soil before planting grapes)", description = "Trellis (place on soil before planting grapes)",
drawtype = "plantlike", drawtype = "plantlike",
@ -50,33 +58,41 @@ minetest.register_node("farming:trellis", {
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
sunlight_propagates = true, sunlight_propagates = true,
drop = { drop = "farming:trellis",
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select, selection_box = farming.select,
groups = {snappy = 3, flammable = 2, attached_node = 1}, groups = {snappy = 3, flammable = 2, attached_node = 1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return return
end end
local nod = minetest.get_node_or_nil(pointed_thing.under)
if nod and minetest.get_item_group(nod.name, "soil") < 2 then local nodename = minetest.get_node(pointed_thing.under).name
if minetest.get_item_group(nodename, "soil") < 2 then
return return
end end
local top = { local top = {
x = pointed_thing.above.x, x = pointed_thing.above.x,
y = pointed_thing.above.y + 1, y = pointed_thing.above.y + 1,
z = pointed_thing.above.z z = pointed_thing.above.z
} }
nod = minetest.get_node_or_nil(top)
if nod and nod.name ~= "air" then return end nodename = minetest.get_node(top).name
if nodename ~= "air" then
return
end
minetest.set_node(pointed_thing.above, {name = "farming:trellis"}) minetest.set_node(pointed_thing.above, {name = "farming:trellis"})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack
end end
}) })
@ -96,9 +112,8 @@ minetest.register_craft({
burntime = 15, burntime = 15,
}) })
-- Define Grapes growth stages -- grapes definition
local crop_def = {
minetest.register_node("farming:grapes_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_grapes_1.png"}, tiles = {"farming_grapes_1.png"},
visual_scale = 1.45, visual_scale = 1.45,
@ -116,163 +131,50 @@ minetest.register_node("farming:grapes_1", {
snappy = 3, flammable = 3, not_in_creative_inventory = 1, snappy = 3, flammable = 3, not_in_creative_inventory = 1,
attached_node = 1, growing = 1 attached_node = 1, growing = 1
}, },
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults()
}) }
minetest.register_node("farming:grapes_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:grapes_1", table.copy(crop_def))
tiles = {"farming_grapes_2.png"},
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_3", { -- stage2
drawtype = "plantlike", crop_def.tiles = {"farming_grapes_2.png"}
tiles = {"farming_grapes_3.png"}, minetest.register_node("farming:grapes_2", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_4", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_grapes_3.png"}
tiles = {"farming_grapes_4.png"}, minetest.register_node("farming:grapes_3", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_5", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_grapes_4.png"}
tiles = {"farming_grapes_5.png"}, minetest.register_node("farming:grapes_4", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_6", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_grapes_5.png"}
tiles = {"farming_grapes_6.png"}, minetest.register_node("farming:grapes_5", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:grapes_7", { -- stage 6
drawtype = "plantlike", crop_def.tiles = {"farming_grapes_6.png"}
tiles = {"farming_grapes_7.png"}, minetest.register_node("farming:grapes_6", table.copy(crop_def))
visual_scale = 1.45,
paramtype = "light",
walkable = false,
buildable_to = true,
sunlight_propagates = true,
drop = {
items = {
{items = {'farming:trellis'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 7
crop_def.tiles = {"farming_grapes_7.png"}
minetest.register_node("farming:grapes_7", table.copy(crop_def))
minetest.register_node("farming:grapes_8", { -- stage 8 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_grapes_8.png"}
tiles = {"farming_grapes_8.png"}, crop_def.groups.growing = 0
visual_scale = 1.45, crop_def.drop = {
paramtype = "light", items = {
walkable = false, {items = {'farming:trellis'}, rarity = 1},
buildable_to = true, {items = {'farming:grapes 3'}, rarity = 1},
sunlight_propagates = true, {items = {'farming:grapes 1'}, rarity = 2},
drop = { {items = {'farming:grapes 1'}, rarity = 3},
items = { }
{items = {'farming:trellis'}, rarity = 1}, }
{items = {'farming:grapes 3'}, rarity = 1}, minetest.register_node("farming:grapes_8", table.copy(crop_def))
{items = {'farming:grapes 1'}, rarity = 2},
{items = {'farming:grapes 1'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Wild Grape Vine (this is what you find on the map)
-- wild grape vine (this is what you find on the map)
minetest.register_node("farming:grapebush", { minetest.register_node("farming:grapebush", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_grapebush.png"}, tiles = {"farming_grapebush.png"},

View File

@ -1,7 +1,7 @@
-- Override default grass and have it drop Wheat Seeds for i = 3, 5 do
for i = 1, 5 do -- Override default grass and have it drop Wheat Seeds
minetest.override_item("default:grass_" .. i, { minetest.override_item("default:grass_" .. i, {
drop = { drop = {
@ -13,6 +13,20 @@ for i = 1, 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, {
drop = {
max_items = 1,
items = {
{items = {'farming:seed_barley'}, rarity = 6},
{items = {'default:dry_grass_1'}},
}
},
})
end
end end
-- Override default Jungle Grass and have it drop Cotton Seeds -- Override default Jungle Grass and have it drop Cotton Seeds
@ -25,4 +39,4 @@ minetest.override_item("default:junglegrass", {
{items = {'default:junglegrass'}}, {items = {'default:junglegrass'}},
} }
}, },
}) })

136
init.lua
View File

@ -1,5 +1,5 @@
--[[ --[[
Minetest Farming Redo Mod 1.22 (8th December 2015) Minetest Farming Redo Mod 1.22 (10th March 2016)
by TenPlus1 by TenPlus1
NEW growing routine by prestidigitator NEW growing routine by prestidigitator
auto-refill by crabman77 auto-refill by crabman77
@ -69,6 +69,7 @@ dofile(farming.path.."/blueberry.lua")
dofile(farming.path.."/rhubarb.lua") dofile(farming.path.."/rhubarb.lua")
dofile(farming.path.."/beanpole.lua") dofile(farming.path.."/beanpole.lua")
dofile(farming.path.."/grapes.lua") dofile(farming.path.."/grapes.lua")
dofile(farming.path.."/barley.lua")
dofile(farming.path.."/donut.lua") dofile(farming.path.."/donut.lua")
dofile(farming.path.."/mapgen.lua") dofile(farming.path.."/mapgen.lua")
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
@ -76,7 +77,7 @@ dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
-- Utility Functions -- Utility Functions
local time_speed = tonumber(minetest.setting_get("time_speed")) or 72 local time_speed = tonumber(minetest.setting_get("time_speed")) or 72
local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or 0 --nil local SECS_PER_CYCLE = (time_speed > 0 and 24 * 60 * 60 / time_speed) or 0
local function clamp(x, min, max) local function clamp(x, min, max)
return (x < min and min) or (x > max and max) or x return (x < min and min) or (x > max and max) or x
@ -180,7 +181,7 @@ local function plant_name_stage(node)
if type(node) == 'table' then if type(node) == 'table' then
if node.name then if node.name then
name = node.name name = node.name
elseif node.x and node.y and node.z then elseif node.x and node.y and node.z then
node = minetest.get_node_or_nil(node) node = minetest.get_node_or_nil(node)
name = node and node.name name = node and node.name
@ -189,7 +190,9 @@ local function plant_name_stage(node)
name = tostring(node) name = tostring(node)
end end
if not name or name == "ignore" then return nil end if not name or name == "ignore" then
return nil
end
local sep_pos = name:find("_[^_]+$") local sep_pos = name:find("_[^_]+$")
@ -205,8 +208,9 @@ local function plant_name_stage(node)
return name, 0 return name, 0
end end
--- Map from node name to -- Map from node name to
-- { plant_name = ..., name = ..., stage = n, stages_left = { node_name, ... } } -- { plant_name = ..., name = ..., stage = n, stages_left = { node_name, ... } }
local plant_stages = {} local plant_stages = {}
farming.plant_stages = plant_stages farming.plant_stages = plant_stages
@ -227,11 +231,15 @@ local function reg_plant_stages(plant_name, stage, force_last)
local node_name = plant_name and plant_name .. "_" .. stage local node_name = plant_name and plant_name .. "_" .. stage
local node_def = node_name and minetest.registered_nodes[node_name] local node_def = node_name and minetest.registered_nodes[node_name]
if not node_def then return nil end if not node_def then
return nil
end
local stages = plant_stages[node_name] local stages = plant_stages[node_name]
if stages then return stages end if stages then
return stages
end
if minetest.get_item_group(node_name, "growing") > 0 then if minetest.get_item_group(node_name, "growing") > 0 then
@ -253,13 +261,21 @@ local function reg_plant_stages(plant_name, stage, force_last)
minetest.override_item(node_name, minetest.override_item(node_name,
{ {
on_construct = function(pos) on_construct = function(pos)
if old_constr then old_constr(pos) end
if old_constr then
old_constr(pos)
end
farming.handle_growth(pos) farming.handle_growth(pos)
end, end,
on_destruct = function(pos) on_destruct = function(pos)
minetest.get_node_timer(pos):stop() minetest.get_node_timer(pos):stop()
if old_destr then old_destr(pos) end
if old_destr then
old_destr(pos)
end
end, end,
on_timer = function(pos, elapsed) on_timer = function(pos, elapsed)
@ -290,6 +306,7 @@ register_plant_node = function(node)
local plant_name, stage = plant_name_stage(node) local plant_name, stage = plant_name_stage(node)
if plant_name then if plant_name then
local stages = reg_plant_stages(plant_name, stage, false) local stages = reg_plant_stages(plant_name, stage, false)
return stages and #stages.stages_left return stages and #stages.stages_left
else else
@ -299,7 +316,9 @@ end
local function set_growing(pos, stages_left) local function set_growing(pos, stages_left)
if not stages_left then return end if not stages_left then
return
end
local timer = minetest.get_node_timer(pos) local timer = minetest.get_node_timer(pos)
@ -319,28 +338,33 @@ local function set_growing(pos, stages_left)
end end
end end
--- Detects a plant type node at the given position, starting or stopping the plant growth timer as appopriate -- Detects a plant type node at the given position, starting
-- -- or stopping the plant growth timer as appopriate
-- @param pos
-- The node's position. -- @param pos
-- @param node -- The node's position.
-- The cached node table if available, or nil. -- @param node
-- The cached node table if available, or nil.
function farming.handle_growth(pos, node) function farming.handle_growth(pos, node)
if not pos then return end if not pos then
return
end
local stages_left = register_plant_node(node or pos) local stages_left = register_plant_node(node or pos)
if stages_left then set_growing(pos, stages_left) end if stages_left then
set_growing(pos, stages_left)
end
end end
minetest.after(0, minetest.after(0, function()
function()
for _, node_def in pairs(minetest.registered_nodes) do for _, node_def in pairs(minetest.registered_nodes) do
register_plant_node(node_def) register_plant_node(node_def)
end end
end) end)
local abm_func = farming.handle_growth local abm_func = farming.handle_growth
@ -349,6 +373,7 @@ if farming.DEBUG then
local normal_abm_func = abm_func local normal_abm_func = abm_func
abm_func = function(...) abm_func = function(...)
local t0 = minetest.get_us_time() local t0 = minetest.get_us_time()
local r = { normal_abm_func(...) } local r = { normal_abm_func(...) }
local t1 = minetest.get_us_time() local t1 = minetest.get_us_time()
@ -362,73 +387,92 @@ end
-- Just in case a growing type or added node is missed (also catches existing -- Just in case a growing type or added node is missed (also catches existing
-- nodes added to map before timers were incorporated). -- nodes added to map before timers were incorporated).
minetest.register_abm({
minetest.register_abm({
nodenames = { "group:growing" }, nodenames = { "group:growing" },
interval = 300, interval = 300,
chance = 1, chance = 1,
action = abm_func action = abm_func
}) })
--- Plant timer function. -- Plant timer function.
-- -- Grows plants under the right conditions.
-- Grows plants under the right conditions.
function farming.plant_growth_timer(pos, elapsed, node_name) function farming.plant_growth_timer(pos, elapsed, node_name)
local stages = plant_stages[node_name] local stages = plant_stages[node_name]
if not stages then return false end if not stages then
return false
end
local max_growth = #stages.stages_left local max_growth = #stages.stages_left
if max_growth <= 0 then return false end if max_growth <= 0 then
return false
end
if stages.plant_name == "farming:cocoa" then if stages.plant_name == "farming:cocoa" then
if not minetest.find_node_near(pos, 1, { "default:jungletree", "moretrees:jungletree_leaves_green" }) then if not minetest.find_node_near(pos, 1,
{"default:jungletree", "moretrees:jungletree_leaves_green"}) then
return true return true
end end
else else
local under = minetest.get_node_or_nil({ x = pos.x, y = pos.y - 1, z = pos.z }) local under = minetest.get_node_or_nil({ x = pos.x, y = pos.y - 1, z = pos.z })
if not under or under.name ~= "farming:soil_wet" then return true end if not under or under.name ~= "farming:soil_wet" then
return true
end
end end
local growth local growth
local light_pos = { x = pos.x, y = pos.y, z = pos.z } local light_pos = {x = pos.x, y = pos.y, z = pos.z}
local lambda = elapsed / STAGE_LENGTH_AVG local lambda = elapsed / STAGE_LENGTH_AVG
if lambda < 0.1 then return true end if lambda < 0.1 then
return true
end
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) -- CHANGED local light = (minetest.get_node_light(light_pos) or 0)
--print ("light level:", light) --print ("light level:", light)
if not in_range(light, MIN_LIGHT, MAX_LIGHT) then return true end if not in_range(light, MIN_LIGHT, MAX_LIGHT) then
return true
end
growth = 1 growth = 1
else else
local night_light = (minetest.get_node_light(light_pos, 0) or 0) -- CHANGED local night_light = (minetest.get_node_light(light_pos, 0) or 0)
local day_light = (minetest.get_node_light(light_pos, 0.5) or 0) -- ChANGED local day_light = (minetest.get_node_light(light_pos, 0.5) or 0)
local night_growth = in_range(night_light, MIN_LIGHT, MAX_LIGHT) local night_growth = in_range(night_light, MIN_LIGHT, MAX_LIGHT)
local day_growth = in_range(day_light, MIN_LIGHT, MAX_LIGHT) local day_growth = in_range(day_light, MIN_LIGHT, MAX_LIGHT)
if not night_growth then if not night_growth then
if not day_growth then return true end
if not day_growth then
return true
end
lambda = day_time(elapsed) / STAGE_LENGTH_AVG lambda = day_time(elapsed) / STAGE_LENGTH_AVG
elseif not day_growth then elseif not day_growth then
lambda = night_time(elapsed) / STAGE_LENGTH_AVG lambda = night_time(elapsed) / STAGE_LENGTH_AVG
end end
growth = statistics.poisson(lambda, max_growth) growth = statistics.poisson(lambda, max_growth)
if growth < 1 then return true end if growth < 1 then
return true
end
end end
if minetest.registered_nodes[stages.stages_left[growth]] then if minetest.registered_nodes[stages.stages_left[growth]] then
minetest.swap_node(pos, { name = stages.stages_left[growth] }) minetest.swap_node(pos, {name = stages.stages_left[growth]})
else else
return true return true
end end
@ -479,7 +523,9 @@ function farming.refill_plant(player, plantname, index)
local inv = player:get_inventory() local inv = player:get_inventory()
local old_stack = inv:get_stack("main", index) local old_stack = inv:get_stack("main", index)
if old_stack:get_name() ~= "" then return end if old_stack:get_name() ~= "" then
return
end
for i, stack in pairs(inv:get_list("main")) do for i, stack in pairs(inv:get_list("main")) do
@ -492,7 +538,7 @@ function farming.refill_plant(player, plantname, index)
return return
end end
end end
end -- END refill end
-- Place Seeds on Soil -- Place Seeds on Soil
@ -646,4 +692,4 @@ farming.register_plant("farming:cotton", {
description = "Cotton2 seed", description = "Cotton2 seed",
inventory_image = "farming_cotton_seed.png", inventory_image = "farming_cotton_seed.png",
steps = 8, steps = 8,
})]] })]]

146
melon.lua
View File

@ -1,6 +1,5 @@
--= Melon -- melon
minetest.register_craftitem("farming:melon_slice", { minetest.register_craftitem("farming:melon_slice", {
description = "Melon Slice", description = "Melon Slice",
inventory_image = "farming_melon_slice.png", inventory_image = "farming_melon_slice.png",
@ -26,9 +25,8 @@ minetest.register_craft({
} }
}) })
-- Define Melon growth stages -- melon definition
local crop_def = {
minetest.register_node("farming:melon_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_melon_1.png"}, tiles = {"farming_melon_1.png"},
paramtype = "light", paramtype = "light",
@ -41,119 +39,41 @@ minetest.register_node("farming:melon_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:melon_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:melon_1", table.copy(crop_def))
tiles = {"farming_melon_2.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:melon_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_melon_2.png"}
tiles = {"farming_melon_3.png"}, minetest.register_node("farming:melon_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:melon_4", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_melon_3.png"}
tiles = {"farming_melon_4.png"}, minetest.register_node("farming:melon_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:melon_5", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_melon_4.png"}
tiles = {"farming_melon_5.png"}, minetest.register_node("farming:melon_4", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:melon_6", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_melon_5.png"}
tiles = {"farming_melon_6.png"}, minetest.register_node("farming:melon_5", table.copy(crop_def))
paramtype = "light",
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:melon_7", { -- stage 6
drawtype = "plantlike", crop_def.tiles = {"farming_melon_6.png"}
tiles = {"farming_melon_7.png"}, minetest.register_node("farming:melon_6", table.copy(crop_def))
paramtype = "light",
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 7
crop_def.tiles = {"farming_melon_7.png"}
minetest.register_node("farming:melon_7", table.copy(crop_def))
minetest.register_node("farming:melon_8", { -- stage 8 (final)
--drawtype = "nodebox", crop_def.drawtype = "nodebox"
description = "Melon", crop_def.description = "Melon"
tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"}, crop_def.tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"}
paramtype = "light", crop_def.selection_box = {-.5, -.5, -.5, .5, .5, .5}
walkable = true, crop_def.groups = {snappy = 1, oddly_breakable_by_hand = 1, flammable = 2, plant = 1}
drop = { crop_def.drop = "farming:melon_slice 9"
items = { minetest.register_node("farming:melon_8", table.copy(crop_def))
{items = {'farming:melon_slice 9'}, rarity = 1},
}
},
groups = {snappy = 1, oddly_breakable_by_hand = 1, flammable = 2, plant = 1},
sounds = default.node_sound_wood_defaults(),
})

View File

@ -1,7 +1,10 @@
--= Potato (Original textures from DocFarming mod) --[[
-- https://forum.minetest.net/viewtopic.php?id=3948 Original textures from DocFarming mod
https://forum.minetest.net/viewtopic.php?id=3948
]]
-- potato
minetest.register_craftitem("farming:potato", { minetest.register_craftitem("farming:potato", {
description = "Potato", description = "Potato",
inventory_image = "farming_potato.png", inventory_image = "farming_potato.png",
@ -11,6 +14,7 @@ minetest.register_craftitem("farming:potato", {
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
}) })
-- baked potato
minetest.register_craftitem("farming:baked_potato", { minetest.register_craftitem("farming:baked_potato", {
description = "Baked Potato", description = "Baked Potato",
inventory_image = "farming_baked_potato.png", inventory_image = "farming_baked_potato.png",
@ -24,9 +28,8 @@ minetest.register_craft({
recipe = "farming:potato" recipe = "farming:potato"
}) })
-- Define Potato growth stages -- potato definition
local crop_def = {
minetest.register_node("farming:potato_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_potato_1.png"}, tiles = {"farming_potato_1.png"},
paramtype = "light", paramtype = "light",
@ -40,68 +43,33 @@ minetest.register_node("farming:potato_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:potato_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:potato_1", table.copy(crop_def))
tiles = {"farming_potato_2.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:potato_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_potato_2.png"}
tiles = {"farming_potato_3.png"}, minetest.register_node("farming:potato_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {'farming:potato'}, rarity = 1},
{items = {'farming:potato'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 3
crop_def.tiles = {"farming_potato_3.png"}
crop_def.drop = {
items = {
{items = {'farming:potato'}, rarity = 1},
{items = {'farming:potato'}, rarity = 3},
}
}
minetest.register_node("farming:potato_3", table.copy(crop_def))
minetest.register_node("farming:potato_4", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_potato_4.png"}
tiles = {"farming_potato_4.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
sunlight_propagates = true, items = {
waving = 1, {items = {'farming:potato 2'}, rarity = 1},
walkable = false, {items = {'farming:potato 3'}, rarity = 2},
buildable_to = true, }
drop = { }
items = { minetest.register_node("farming:potato_4", table.copy(crop_def))
{items = {'farming:potato 2'}, rarity = 1},
{items = {'farming:potato 3'}, rarity = 2},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory=1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -1,6 +1,9 @@
--= Pumpkin (Big thanks to the PainterlyPack.net for Minecraft for allowing me to use these textures) --[[
Big thanks to PainterlyPack.net for allowing me to use these textures
]]
-- pumpkin
minetest.register_node("farming:pumpkin", { minetest.register_node("farming:pumpkin", {
description = "Pumpkin", description = "Pumpkin",
tiles = { tiles = {
@ -20,6 +23,7 @@ minetest.register_node("farming:pumpkin", {
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
-- pumpkin slice
minetest.register_craftitem("farming:pumpkin_slice", { minetest.register_craftitem("farming:pumpkin_slice", {
description = "Pumpkin Slice", description = "Pumpkin Slice",
inventory_image = "farming_pumpkin_slice.png", inventory_image = "farming_pumpkin_slice.png",
@ -45,7 +49,7 @@ minetest.register_craft({
} }
}) })
-- Jack 'O Lantern -- jack 'o lantern
minetest.register_node("farming:jackolantern", { minetest.register_node("farming:jackolantern", {
description = "Jack 'O Lantern", description = "Jack 'O Lantern",
tiles = { tiles = {
@ -95,7 +99,7 @@ minetest.register_craft({
} }
}) })
-- Pumpkin Bread -- pumpkin bread
minetest.register_craftitem("farming:pumpkin_bread", { minetest.register_craftitem("farming:pumpkin_bread", {
description = ("Pumpkin Bread"), description = ("Pumpkin Bread"),
inventory_image = "farming_pumpkin_bread.png", inventory_image = "farming_pumpkin_bread.png",
@ -120,9 +124,8 @@ minetest.register_craft({
cooktime = 10 cooktime = 10
}) })
-- Define Pumpkin growth stages -- pumpkin definition
local crop_def = {
minetest.register_node("farming:pumpkin_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_pumpkin_1.png"}, tiles = {"farming_pumpkin_1.png"},
paramtype = "light", paramtype = "light",
@ -136,125 +139,42 @@ minetest.register_node("farming:pumpkin_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:pumpkin_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:pumpkin_1", table.copy(crop_def))
tiles = {"farming_pumpkin_2.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory =1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:pumpkin_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_pumpkin_2.png"}
tiles = {"farming_pumpkin_3.png"}, minetest.register_node("farming:pumpkin_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:pumpkin_4", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_pumpkin_3.png"}
tiles = {"farming_pumpkin_4.png"}, minetest.register_node("farming:pumpkin_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:pumpkin_5", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_pumpkin_4.png"}
tiles = {"farming_pumpkin_5.png"}, minetest.register_node("farming:pumpkin_4", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:pumpkin_6", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_pumpkin_5.png"}
tiles = {"farming_pumpkin_6.png"}, minetest.register_node("farming:pumpkin_5", table.copy(crop_def))
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:pumpkin_7", { -- stage 6
drawtype = "plantlike", crop_def.tiles = {"farming_pumpkin_6.png"}
tiles = {"farming_pumpkin_7.png"}, minetest.register_node("farming:pumpkin_6", table.copy(crop_def))
paramtype = "light",
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 7
crop_def.tiles = {"farming_pumpkin_7.png"}
minetest.register_node("farming:pumpkin_7", table.copy(crop_def))
minetest.register_node("farming:pumpkin_8", { -- stage 8 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_pumpkin_8.png"}
tiles = {"farming_pumpkin_8.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
walkable = false, items = {
buildable_to = true, {items = {'farming:pumpkin_slice 9'}, rarity = 1},
drop = { }
items = { }
{items = {'farming:pumpkin_slice 9'}, rarity = 1}, minetest.register_node("farming:pumpkin_8", table.copy(crop_def))
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_defaults(),
})

View File

@ -1,6 +1,5 @@
--= Raspberries -- raspberries
minetest.register_craftitem("farming:raspberries", { minetest.register_craftitem("farming:raspberries", {
description = "Raspberries", description = "Raspberries",
inventory_image = "farming_raspberries.png", inventory_image = "farming_raspberries.png",
@ -10,8 +9,7 @@ minetest.register_craftitem("farming:raspberries", {
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
}) })
-- Raspberry Smoothie -- raspberry smoothie
minetest.register_craftitem("farming:smoothie_raspberry", { minetest.register_craftitem("farming:smoothie_raspberry", {
description = "Raspberry Smoothie", description = "Raspberry Smoothie",
inventory_image = "farming_raspberry_smoothie.png", inventory_image = "farming_raspberry_smoothie.png",
@ -27,9 +25,8 @@ minetest.register_craft({
} }
}) })
-- Define Raspberry growth stages -- raspberries definition
local crop_def = {
minetest.register_node("farming:raspberry_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_raspberry_1.png"}, tiles = {"farming_raspberry_1.png"},
paramtype = "light", paramtype = "light",
@ -42,64 +39,28 @@ minetest.register_node("farming:raspberry_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:raspberry_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:raspberry_1", table.copy(crop_def))
tiles = {"farming_raspberry_2.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:raspberry_3", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_raspberry_2.png"}
tiles = {"farming_raspberry_3.png"}, minetest.register_node("farming:raspberry_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 3
crop_def.tiles = {"farming_raspberry_3.png"}
minetest.register_node("farming:raspberry_3", table.copy(crop_def))
minetest.register_node("farming:raspberry_4", { -- stage 4 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_raspberry_4.png"}
tiles = {"farming_raspberry_4.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
sunlight_propagates = true, items = {
waving = 1, {items = {'farming:raspberries 2'}, rarity = 1},
walkable = false, {items = {'farming:raspberries'}, rarity = 2},
buildable_to = true, {items = {'farming:raspberries'}, rarity = 3},
drop = { }
items = { }
{items = {'farming:raspberries 2'}, rarity = 1}, minetest.register_node("farming:raspberry_4", table.copy(crop_def))
{items = {'farming:raspberries'}, rarity = 2},
{items = {'farming:raspberries'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})

View File

@ -1,6 +1,5 @@
--= Rhubarb -- rhubarb
minetest.register_craftitem("farming:rhubarb", { minetest.register_craftitem("farming:rhubarb", {
description = "Rhubarb", description = "Rhubarb",
inventory_image = "farming_rhubarb.png", inventory_image = "farming_rhubarb.png",
@ -10,6 +9,7 @@ minetest.register_craftitem("farming:rhubarb", {
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
}) })
-- rhubarb pie
minetest.register_craftitem("farming:rhubarb_pie", { minetest.register_craftitem("farming:rhubarb_pie", {
description = "Rhubarb Pie", description = "Rhubarb Pie",
inventory_image = "farming_rhubarb_pie.png", inventory_image = "farming_rhubarb_pie.png",
@ -25,9 +25,8 @@ minetest.register_craft({
} }
}) })
-- Define Rhubarb growth stages -- rhubarb definition
local crop_def = {
minetest.register_node("farming:rhubarb_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_rhubarb_1.png"}, tiles = {"farming_rhubarb_1.png"},
paramtype = "light", paramtype = "light",
@ -40,47 +39,24 @@ minetest.register_node("farming:rhubarb_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:rhubarb_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:rhubarb_1", table.copy(crop_def))
tiles = {"farming_rhubarb_2.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage2
crop_def.tiles = {"farming_rhubarb_2.png"}
minetest.register_node("farming:rhubarb_2", table.copy(crop_def))
minetest.register_node("farming:rhubarb_3", { -- stage 3 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_rhubarb_3.png"}
tiles = {"farming_rhubarb_3.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
sunlight_propagates = true, items = {
waving = 1, {items = {'farming:rhubarb 2'}, rarity = 1},
walkable = false, {items = {'farming:rhubarb'}, rarity = 2},
buildable_to = true, {items = {'farming:rhubarb'}, rarity = 3},
drop = { }
items = { }
{items = {'farming:rhubarb 2'}, rarity = 1}, minetest.register_node("farming:rhubarb_3", table.copy(crop_def))
{items = {'farming:rhubarb'}, rarity = 2},
{items = {'farming:rhubarb'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})

BIN
textures/farming_barley.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

View File

@ -1,7 +1,10 @@
--= Tomato (Original textures from link below) --[[
-- http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1288375-food-plus-mod-more-food-than-you-can-imagine-v2-9) Textures edited from:
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1288375-food-plus-mod-more-food-than-you-can-imagine-v2-9)
]]
-- tomato
minetest.register_craftitem("farming:tomato", { minetest.register_craftitem("farming:tomato", {
description = "Tomato", description = "Tomato",
inventory_image = "farming_tomato.png", inventory_image = "farming_tomato.png",
@ -11,9 +14,8 @@ minetest.register_craftitem("farming:tomato", {
on_use = minetest.item_eat(4), on_use = minetest.item_eat(4),
}) })
-- Define Tomato growth stages -- tomato definition
local crop_def = {
minetest.register_node("farming:tomato_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_tomato_1.png"}, tiles = {"farming_tomato_1.png"},
paramtype = "light", paramtype = "light",
@ -26,133 +28,49 @@ minetest.register_node("farming:tomato_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:tomato_2", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:tomato_1", table.copy(crop_def))
tiles = {"farming_tomato_2.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:tomato_3", { -- stage2
drawtype = "plantlike", crop_def.tiles = {"farming_tomato_2.png"}
tiles = {"farming_tomato_3.png"}, minetest.register_node("farming:tomato_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:tomato_4", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_tomato_3.png"}
tiles = {"farming_tomato_4.png"}, minetest.register_node("farming:tomato_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:tomato_5", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_tomato_4.png"}
tiles = {"farming_tomato_5.png"}, minetest.register_node("farming:tomato_4", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:tomato_6", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_tomato_5.png"}
tiles = {"farming_tomato_6.png"}, minetest.register_node("farming:tomato_5", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:tomato_7", { -- stage 6
drawtype = "plantlike", crop_def.tiles = {"farming_tomato_6.png"}
tiles = {"farming_tomato_7.png"}, minetest.register_node("farming:tomato_6", table.copy(crop_def))
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {'farming:tomato'}, rarity = 1},
{items = {'farming:tomato'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 7
crop_def.tiles = {"farming_tomato_7.png"}
crop_def.drop = {
items = {
{items = {'farming:tomato'}, rarity = 1},
{items = {'farming:tomato'}, rarity = 3},
}
}
minetest.register_node("farming:tomato_7", table.copy(crop_def))
minetest.register_node("farming:tomato_8", { -- stage 8 (final)
drawtype = "plantlike", crop_def.tiles = {"farming_tomato_8.png"}
tiles = {"farming_tomato_8.png"}, crop_def.groups.growing = 0
paramtype = "light", crop_def.drop = {
waving = 1, items = {
walkable = false, {items = {'farming:tomato 3'}, rarity = 1},
buildable_to = true, {items = {'farming:tomato 3'}, rarity = 2},
drop = { }
items = { }
{items = {'farming:tomato 3'}, rarity = 1}, minetest.register_node("farming:tomato_8", table.copy(crop_def))
{items = {'farming:tomato 3'}, rarity = 2},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1
},
sounds = default.node_sound_leaves_defaults(),
})

221
wheat.lua
View File

@ -1,16 +1,5 @@
--= Wheat -- wheat seeds
-- Wheat Seed
--minetest.register_craftitem("farming:seed_wheat", {
-- description = "Wheat Seed",
-- inventory_image = "farming_wheat_seed.png",
-- on_place = function(itemstack, placer, pointed_thing)
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:wheat_1")
-- end,
--})
minetest.register_node("farming:seed_wheat", { minetest.register_node("farming:seed_wheat", {
description = "Wheat Seed", description = "Wheat Seed",
tiles = {"farming_wheat_seed.png"}, tiles = {"farming_wheat_seed.png"},
@ -28,15 +17,13 @@ minetest.register_node("farming:seed_wheat", {
end, end,
}) })
-- Harvested Wheat -- harvested wheat
minetest.register_craftitem("farming:wheat", { minetest.register_craftitem("farming:wheat", {
description = "Wheat", description = "Wheat",
inventory_image = "farming_wheat.png", inventory_image = "farming_wheat.png",
}) })
-- Straw -- straw
minetest.register_node("farming:straw", { minetest.register_node("farming:straw", {
description = "Straw", description = "Straw",
tiles = {"farming_straw.png"}, tiles = {"farming_straw.png"},
@ -62,7 +49,6 @@ minetest.register_craft({
}) })
-- flour -- flour
minetest.register_craftitem("farming:flour", { minetest.register_craftitem("farming:flour", {
description = "Flour", description = "Flour",
inventory_image = "farming_flour.png", inventory_image = "farming_flour.png",
@ -74,8 +60,7 @@ minetest.register_craft({
recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"} recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"}
}) })
-- Bread -- bread
minetest.register_craftitem("farming:bread", { minetest.register_craftitem("farming:bread", {
description = "Bread", description = "Bread",
inventory_image = "farming_bread.png", inventory_image = "farming_bread.png",
@ -89,9 +74,8 @@ minetest.register_craft({
recipe = "farming:flour" recipe = "farming:flour"
}) })
-- Define Wheat growth stages -- wheat definition
local crop_def = {
minetest.register_node("farming:wheat_1", {
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"farming_wheat_1.png"}, tiles = {"farming_wheat_1.png"},
paramtype = "light", paramtype = "light",
@ -100,152 +84,69 @@ minetest.register_node("farming:wheat_1", {
buildable_to = true, buildable_to = true,
drop = "", drop = "",
selection_box = farming.select, selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing=1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:wheat_2", {
drawtype = "plantlike",
tiles = {"farming_wheat_2.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = { groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, snappy = 3, flammable = 2, 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()
}) }
minetest.register_node("farming:wheat_3", { -- stage 1
drawtype = "plantlike", minetest.register_node("farming:wheat_1", table.copy(crop_def))
tiles = {"farming_wheat_3.png"},
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:wheat_4", { -- stage 2
drawtype = "plantlike", crop_def.tiles = {"farming_wheat_2.png"}
tiles = {"farming_wheat_4.png"}, minetest.register_node("farming:wheat_2", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = "",
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:wheat_5", { -- stage 3
drawtype = "plantlike", crop_def.tiles = {"farming_wheat_3.png"}
tiles = {"farming_wheat_5.png"}, minetest.register_node("farming:wheat_3", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {'farming:wheat'}, rarity = 2},
{items = {'farming:seed_wheat'}, rarity = 2},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:wheat_6", { -- stage 4
drawtype = "plantlike", crop_def.tiles = {"farming_wheat_4.png"}
tiles = {"farming_wheat_6.png"}, minetest.register_node("farming:wheat_4", table.copy(crop_def))
paramtype = "light",
sunlight_propagates = true,
waving = 1,
walkable = false,
buildable_to = true,
drop = {
items = {
{items = {'farming:wheat'}, rarity = 2},
{items = {'farming:seed_wheat'}, rarity = 1},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node("farming:wheat_7", { -- stage 5
drawtype = "plantlike", crop_def.tiles = {"farming_wheat_5.png"}
tiles = {"farming_wheat_7.png"}, crop_def.drop = {
paramtype = "light", items = {
sunlight_propagates = true, {items = {'farming:wheat'}, rarity = 2},
waving = 1, {items = {'farming:seed_wheat'}, rarity = 2},
walkable = false, }
buildable_to = true, }
drop = { minetest.register_node("farming:wheat_5", table.copy(crop_def))
items = {
{items = {'farming:wheat'}, rarity = 1},
{items = {'farming:wheat'}, rarity = 3},
{items = {'farming:seed_wheat'}, rarity = 1},
{items = {'farming:seed_wheat'}, rarity = 3},
}
},
selection_box = farming.select,
groups = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1,
not_in_creative_inventory = 1, growing = 1
},
sounds = default.node_sound_leaves_defaults(),
})
-- Last stage of growth does not have growing group so abm never checks these -- stage 6
crop_def.tiles = {"farming_wheat_6.png"}
crop_def.drop = {
items = {
{items = {'farming:wheat'}, rarity = 2},
{items = {'farming:seed_wheat'}, rarity = 1},
}
}
minetest.register_node("farming:wheat_6", table.copy(crop_def))
minetest.register_node("farming:wheat_8", { -- stage 7
drawtype = "plantlike", crop_def.tiles = {"farming_wheat_7.png"}
tiles = {"farming_wheat_8.png"}, crop_def.drop = {
paramtype = "light", items = {
waving = 1, {items = {'farming:wheat'}, rarity = 1},
walkable = false, {items = {'farming:wheat'}, rarity = 3},
buildable_to = true, {items = {'farming:seed_wheat'}, rarity = 1},
drop = { {items = {'farming:seed_wheat'}, rarity = 3},
items = { }
{items = {'farming:wheat'}, rarity = 1}, }
{items = {'farming:wheat'}, rarity = 2}, minetest.register_node("farming:wheat_7", table.copy(crop_def))
{items = {'farming:seed_wheat'}, rarity = 1},
{items = {'farming:seed_wheat'}, rarity = 2}, -- stage 8 (final)
} crop_def.tiles = {"farming_wheat_8.png"}
}, crop_def.groups.growing = 0
selection_box = farming.select, crop_def.drop = {
groups = { items = {
snappy = 3, flammable = 2, plant = 1, attached_node = 1, {items = {'farming:wheat'}, rarity = 1},
not_in_creative_inventory = 1 {items = {'farming:wheat'}, rarity = 3},
}, {items = {'farming:seed_wheat'}, rarity = 1},
sounds = default.node_sound_leaves_defaults(), {items = {'farming:seed_wheat'}, rarity = 3},
}) }
}
minetest.register_node("farming:wheat_8", table.copy(crop_def))