Corn.
Corn plants are 2 blocks high, and yield corn cobs. These can be cooked to corn-on-the-cob, or processed to make corn seed (corn kernels, basically). Digging a mature plant yields the corn cob. A harvested corn plant "wilts", and needs to be dug away to make the land usable, or can be left as ornamental 2-block plant. Digging either top or bottom block works in all cases, although I need to verify that I've covered every block combo.
271
corn.lua
Normal file
@ -0,0 +1,271 @@
|
||||
|
||||
--[[
|
||||
|
||||
Copyright (C) 2015 - Auke Kok <sofar@foo-projects.org>
|
||||
|
||||
"crops" is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1
|
||||
of the license, or (at your option) any later version.
|
||||
|
||||
--]]
|
||||
|
||||
local interval = 30
|
||||
local chance = 10
|
||||
|
||||
minetest.register_node("crops:corn", {
|
||||
description = "corn",
|
||||
inventory_image = "crops_corn.png",
|
||||
wield_image = "crops_corn.png",
|
||||
tiles = { "crops_corn_base_seed.png" },
|
||||
drawtype = "mesh",
|
||||
visual = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
sunlight_propagates = true,
|
||||
use_texture_alpha = true,
|
||||
walkable = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,attached_node=1 },
|
||||
drop = {},
|
||||
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local under = minetest.get_node(pointed_thing.under)
|
||||
if minetest.get_item_group(under.name, "soil") <= 1 then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pointed_thing.above, {name="crops:corn_base_seed"})
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craftitem("crops:corn_cob", {
|
||||
description = "Corn Cob",
|
||||
inventory_image = "crops_corn_cob.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "crops:corn",
|
||||
recipe = { "crops:corn_cob" }
|
||||
})
|
||||
|
||||
minetest.register_craftitem("crops:corn_on_the_cob", {
|
||||
description = "Corn on the Cob",
|
||||
inventory_image = "crops_corn_on_the_cob.png",
|
||||
on_use = minetest.item_eat(1)
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "crops:corn_on_the_cob",
|
||||
recipe = "crops:corn_cob"
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_base_seed", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_base_seed.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "crops:corn_base_seed" },
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.get_node_light(pos, nil) < 13 then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos, { name = "crops:corn_base_1" })
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_base_1", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_base_1.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "crops:corn_base_1" },
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.get_node_light(pos, nil) < 13 then
|
||||
return
|
||||
end
|
||||
if not minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air" then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos, { name = "crops:corn_base_2" })
|
||||
minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z} , { name = "crops:corn_top_1" })
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_base_2", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_base_2.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
on_dig = function(pos, node, digger)
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if not minetest.get_node(above) == "crops:corn_top_3" then
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
|
||||
local drops = {}
|
||||
for i = 1,math.random(2,4) do
|
||||
table.insert(drops, ('crops:corn_cob'))
|
||||
end
|
||||
minetest.set_node(pos, { name = "crops:corn_base_3" })
|
||||
minetest.set_node(above, { name = "crops:corn_top_4" })
|
||||
core.handle_node_drops(above, drops, digger)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_base_3", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_base_3.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
on_dig = function(pos, node, digger)
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if minetest.get_node(above).name == "crops:corn_top_4" then
|
||||
minetest.remove_node(above)
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_top_1", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_base_1.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "crops:corn_top_1" },
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.get_node_light(pos, nil) < 13 then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos, { name = "crops:corn_top_2" })
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_top_2", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_top_1.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "crops:corn_top_2" },
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
if minetest.get_node_light(pos, nil) < 13 then
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos, { name = "crops:corn_top_3" })
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_top_3", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_top_2.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
on_dig = function(pos, node, digger)
|
||||
local drops = {}
|
||||
for i = 1,math.random(2,4) do
|
||||
table.insert(drops, ('crops:corn_cob'))
|
||||
end
|
||||
minetest.set_node(pos, { name = "crops:corn_top_4" })
|
||||
minetest.set_node({x = pos.x, y = pos.y - 1, z = pos.z}, { name = "crops:corn_base_3" })
|
||||
core.handle_node_drops(pos, drops, digger)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("crops:corn_top_4", {
|
||||
visual = "mesh",
|
||||
description = "corn plant",
|
||||
drawtype = "mesh",
|
||||
mesh = "crops_orthogonal_plant.obj",
|
||||
tiles = { "crops_corn_top_3.png" },
|
||||
use_texture_alpha = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = { snappy=3,flammable=3,flora=1,not_in_creative_inventory=1 },
|
||||
drop = {},
|
||||
on_dig = function(pos, node, digger)
|
||||
local below = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
if minetest.get_node(below).name == "crops:corn_base_3" then
|
||||
minetest.remove_node(below)
|
||||
end
|
||||
minetest.remove_node(pos)
|
||||
end
|
||||
})
|
||||
|
1
init.lua
@ -11,5 +11,6 @@ of the license, or (at your option) any later version.
|
||||
--]]
|
||||
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/melon.lua")
|
||||
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/corn.lua")
|
||||
|
||||
minetest.log("action", "[crops] loaded.")
|
||||
|
33
models/crops_orthogonal_plant.obj
Normal file
@ -0,0 +1,33 @@
|
||||
# Blender v2.60 (sub 0) OBJ File: ''
|
||||
# www.blender.org
|
||||
mtllib crops_orthogonal_plant.mtl
|
||||
o Mesh_Mesh_Plant_Plant_.000
|
||||
v 0.500000 0.500000 0.300000
|
||||
v -0.500000 0.500000 0.300000
|
||||
v -0.500000 -0.500000 0.300000
|
||||
v 0.500000 -0.500000 0.300000
|
||||
v 0.500000 0.500000 -0.300000
|
||||
v -0.500000 0.500000 -0.300000
|
||||
v -0.500000 -0.500000 -0.300000
|
||||
v 0.500000 -0.500000 -0.300000
|
||||
v 0.300000 0.500000 0.500000
|
||||
v 0.300000 0.500000 -0.500000
|
||||
v 0.300000 -0.500000 -0.500000
|
||||
v 0.300000 -0.500000 0.500000
|
||||
v -0.300000 0.500000 0.500000
|
||||
v -0.300000 0.500000 -0.500000
|
||||
v -0.300000 -0.500000 -0.500000
|
||||
v -0.300000 -0.500000 0.500000
|
||||
vt 0.000000 1.000000
|
||||
vt 1.000000 1.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 0.000000 0.000000
|
||||
g Mesh_Mesh_Plant_Plant_.000_Material.002_crops_corn_base_1.000
|
||||
usemtl Material.002_crops_corn_base_1.000
|
||||
s off
|
||||
f 13/1 14/2 15/3 16/4
|
||||
g Mesh_Mesh_Plant_Plant_.000_Material.002_crops_corn_base_1.png
|
||||
usemtl Material.002_crops_corn_base_1.png
|
||||
f 1/2 2/1 3/4 4/3
|
||||
f 5/1 6/2 7/3 8/4
|
||||
f 9/2 10/1 11/4 12/3
|
BIN
textures/crops_corn.png
Normal file
After Width: | Height: | Size: 349 B |
BIN
textures/crops_corn_base_1.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
textures/crops_corn_base_2.png
Normal file
After Width: | Height: | Size: 515 B |
BIN
textures/crops_corn_base_3.png
Normal file
After Width: | Height: | Size: 548 B |
BIN
textures/crops_corn_base_seed.png
Normal file
After Width: | Height: | Size: 370 B |
BIN
textures/crops_corn_cob.png
Normal file
After Width: | Height: | Size: 557 B |
BIN
textures/crops_corn_on_the_cob.png
Normal file
After Width: | Height: | Size: 563 B |
BIN
textures/crops_corn_top_1.png
Normal file
After Width: | Height: | Size: 600 B |
BIN
textures/crops_corn_top_2.png
Normal file
After Width: | Height: | Size: 443 B |
BIN
textures/crops_corn_top_3.png
Normal file
After Width: | Height: | Size: 644 B |