summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README11
-rw-r--r--init.lua1
-rw-r--r--pumpkin.lua258
-rw-r--r--textures/crops_pumpkin.pngbin0 -> 215 bytes
-rw-r--r--textures/crops_pumpkin_bottom.pngbin0 -> 212 bytes
-rw-r--r--textures/crops_pumpkin_inv.pngbin0 -> 1474 bytes
-rw-r--r--textures/crops_pumpkin_plant_1.pngbin0 -> 147 bytes
-rw-r--r--textures/crops_pumpkin_plant_2.pngbin0 -> 173 bytes
-rw-r--r--textures/crops_pumpkin_plant_3.pngbin0 -> 199 bytes
-rw-r--r--textures/crops_pumpkin_plant_4.pngbin0 -> 258 bytes
-rw-r--r--textures/crops_pumpkin_plant_5.pngbin0 -> 497 bytes
-rw-r--r--textures/crops_pumpkin_plant_6.pngbin0 -> 241 bytes
-rw-r--r--textures/crops_pumpkin_seed.pngbin0 -> 538 bytes
-rw-r--r--textures/crops_pumpkin_stem.pngbin0 -> 292 bytes
-rw-r--r--textures/crops_pumpkin_top.pngbin0 -> 276 bytes
-rw-r--r--textures/crops_roasted_pumpkin.pngbin0 -> 249 bytes
16 files changed, 269 insertions, 1 deletions
diff --git a/README b/README
index 33f6cff..9470c10 100644
--- a/README
+++ b/README
@@ -46,13 +46,19 @@ some will do better with less, so make sure you use a hydrometer to
measure plant humidity. Recipes for the watering can and hydrometer
are listed below.
-1. Melons
+1. Melons and pumpkins
Melon plants grow from melon seeds. Once a plant is mature (there
are 5 stages) it will spawn a melon block adjacent to the plant.
The melon block can be harvested by punching, and yields 3-5
melon slices. The melon slice can be crafted to a melon seed.
+Pumpkins grow from pumpkin seeds, and are harvested to yield a
+pumpkin block. Each block can be cooked to yield one or more
+roast pumpkin chunks, which can be eaten. You can also craft
+the blocks to seeds. A pumpkin plant will only yield limited amounts
+of pumpkins. After a while they automatically wither.
+
2. Corn.
Corn plants are 2 blocks high, and yield corn cobs. These can be
@@ -120,6 +126,9 @@ empty empty empty
clay_lump empty clay_lump
empty clay_lump empty
+Pumpkin blocks can be cooked whole, and yield roasted pumpkin. It's
+okay as food, but it takes a lot of work.
+
You can fill these bowls (or any group:food_bowl) with vegetables to
craft an uncooked vegetable stew:
diff --git a/init.lua b/init.lua
index 29c6828..a4f5f36 100644
--- a/init.lua
+++ b/init.lua
@@ -311,6 +311,7 @@ minetest.register_craft({
-- crop nodes, crafts, craftitems
dofile(modpath .. "/melon.lua")
+dofile(modpath .. "/pumpkin.lua")
dofile(modpath .. "/corn.lua")
dofile(modpath .. "/tomato.lua")
dofile(modpath .. "/potato.lua")
diff --git a/pumpkin.lua b/pumpkin.lua
new file mode 100644
index 0000000..743b6df
--- /dev/null
+++ b/pumpkin.lua
@@ -0,0 +1,258 @@
+
+--[[
+
+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 faces = {
+ [1] = { x = -1, z = 0, r = 3, o = 1, m = 14 },
+ [2] = { x = 1, z = 0, r = 1, o = 3, m = 16 },
+ [3] = { x = 0, z = -1, r = 2, o = 0, m = 5 },
+ [4] = { x = 0, z = 1, r = 0, o = 2, m = 11 }
+}
+
+minetest.register_node("crops:pumpkin_seed", {
+ description = "pumpkin seed",
+ inventory_image = "crops_pumpkin_seed.png",
+ wield_image = "crops_pumpkin_seed.png",
+ tiles = { "crops_pumpkin_plant_1.png" },
+ drawtype = "plantlike",
+ waving = 1,
+ sunlight_propagates = false,
+ use_texture_alpha = true,
+ walkable = false,
+ paramtype = "light",
+ groups = { snappy=3,flammable=3,flora=1,attached_node=1 },
+
+ 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
+ crops.plant(pointed_thing.above, {name="crops:pumpkin_plant_1"})
+ if not minetest.setting_getbool("creative_mode") then
+ itemstack:take_item()
+ end
+ return itemstack
+ end
+})
+
+for stage = 1, 6 do
+minetest.register_node("crops:pumpkin_plant_" .. stage , {
+ description = "pumpkin plant",
+ tiles = { "crops_pumpkin_plant_" .. stage .. ".png" },
+ drawtype = "plantlike",
+ waving = 1,
+ sunlight_propagates = true,
+ use_texture_alpha = true,
+ walkable = false,
+ paramtype = "light",
+ groups = { snappy=3, flammable=3, flora=1, attached_node=1, not_in_creative_inventory=1 },
+ drop = "crops:pumpkin_seed",
+ sounds = default.node_sound_leaves_defaults(),
+ selection_box = {
+ type = "fixed",
+ fixed = {-0.5, -0.5, -0.5, 0.5, -0.5 + (((math.min(stage, 4)) + 1) / 5), 0.5}
+ }
+})
+end
+
+minetest.register_node("crops:pumpkin_plant_5_attached", {
+ visual = "mesh",
+ mesh = "crops_plant_extra_face.obj",
+ description = "pumpkin plant",
+ tiles = { "crops_pumpkin_stem.png", "crops_pumpkin_plant_4.png" },
+ drawtype = "mesh",
+ paramtype2 = "facedir",
+ sunlight_propagates = true,
+ use_texture_alpha = true,
+ walkable = false,
+ paramtype = "light",
+ groups = { snappy=3, flammable=3, flora=1, attached_node=1, not_in_creative_inventory=1 },
+ drop = "crops:pumpkin_seed",
+ sounds = default.node_sound_leaves_defaults(),
+})
+
+
+minetest.register_craftitem("crops:roasted_pumpkin", {
+ description = "Roasted pumpkin",
+ inventory_image = "crops_roasted_pumpkin.png",
+ on_use = minetest.item_eat(2)
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "crops:pumpkin_seed",
+ recipe = { "crops:pumpkin" }
+})
+
+minetest.register_craft({
+ type = "cooking",
+ output = "crops:roasted_pumpkin",
+ recipe = "crops:pumpkin"
+})
+
+--
+-- the pumpkin "block"
+--
+minetest.register_node("crops:pumpkin", {
+ description = "Pumpkin",
+ inventory_image = "crops_pumpkin_inv.png",
+ tiles = { "crops_pumpkin_top.png", "crops_pumpkin_bottom.png", "crops_pumpkin.png", "crops_pumpkin.png", "crops_pumpkin.png", "crops_pumpkin.png" },
+ sunlight_propagates = false,
+ use_texture_alpha = false,
+ walkable = true,
+ groups = { snappy=3, flammable=3, oddly_breakable_by_hand=2 },
+ paramtype2 = "facedir",
+ drop = {'crops:pumpkin'},
+ sounds = default.node_sound_wood_defaults({
+ dig = { name = "default_dig_oddly_breakable_by_hand" },
+ dug = { name = "default_dig_choppy" }
+ }),
+ on_dig = function(pos, node, digger)
+ for face = 1, 4 do
+ local s = { x = pos.x + faces[face].x, y = pos.y, z = pos.z + faces[face].z }
+ local n = minetest.get_node(s)
+ if n.name == "crops:pumpkin_plant_5_attached" then
+ -- make sure it was actually attached to this stem
+ if n.param2 == faces[face].o then
+ minetest.swap_node(s, { name = "crops:pumpkin_plant_4" })
+ end
+ end
+ end
+ minetest.remove_node(pos)
+ end
+})
+
+--
+-- grows a plant to mature size
+--
+minetest.register_abm({
+ nodenames = { "crops:pumpkin_plant_1", "crops:pumpkin_plant_2", "crops:pumpkin_plant_3","crops:pumpkin_plant_4" },
+ neighbors = { "group:soil" },
+ interval = crops.settings.interval,
+ chance = crops.settings.chance,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ if not crops.can_grow(pos) then
+ return
+ end
+ local meta = minetest.get_meta(pos)
+ local n = string.gsub(node.name, "4", "5")
+ n = string.gsub(n, "3", "4")
+ n = string.gsub(n, "2", "3")
+ n = string.gsub(n, "1", "2")
+ minetest.swap_node(pos, { name = n })
+ end
+})
+
+--
+-- grows a pumpkin
+--
+minetest.register_abm({
+ nodenames = { "crops:pumpkin_plant_5" },
+ neighbors = { "group:soil" },
+ interval = crops.settings.interval,
+ chance = crops.settings.chance,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ if not crops.can_grow(pos) then
+ return
+ end
+ for face = 1, 4 do
+ local t = { x = pos.x + faces[face].x, y = pos.y, z = pos.z + faces[face].z }
+ if minetest.get_node(t).name == "crops:pumpkin" then
+ return
+ end
+ end
+ local r = math.random(1, 4)
+ local t = { x = pos.x + faces[r].x, y = pos.y, z = pos.z + faces[r].z }
+ local n = minetest.get_node(t)
+ if n.name == "ignore" then
+ return
+ end
+
+ if minetest.registered_nodes[minetest.get_node({ x = t.x, y = t.y - 1, z = t.z }).name].walkable == false then
+ return
+ end
+
+ if minetest.registered_nodes[n.name].drawtype == "plantlike" or
+ minetest.registered_nodes[n.name].groups.flora == 1 or
+ n.name == "air" then
+ minetest.set_node(t, {name = "crops:pumpkin", param2 = faces[r].m})
+
+ local meta = minetest.get_meta(pos)
+ local ttl = meta:get_int("crops_pumpkin_ttl")
+ local damage = meta:get_int("crops_damage")
+ if ttl == 0 then
+ -- damage 0 - regrows 3-4
+ -- damage 50 - drops 1-2
+ -- damage 100 - drops 0-1
+ ttl = math.random(3 - (3 * (damage / 100)), 4 - (3 * (damage / 100)))
+ end
+ if ttl > 1 then
+ minetest.swap_node(pos, {name = "crops:pumpkin_plant_5_attached", param2 = faces[r].r})
+ meta:set_int("crops_pumpkin_ttl", ttl - 1)
+ else
+ -- no luck, plant dead!
+ minetest.set_node(pos, { name = "crops:pumpkin_plant_6" })
+ end
+ local water = meta:get_int("crops_water")
+ -- growing a pumpkin costs 25 water!
+ meta:set_int("crops_water", math.max(0, water - 25))
+ end
+ end
+})
+
+--
+-- return a pumpkin to a normal one if there is no pumpkin attached, so it can
+-- grow a new pumpkin again
+--
+minetest.register_abm({
+ nodenames = { "crops:pumpkin_plant_5_attached" },
+ interval = crops.settings.interval,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ for face = 1, 4 do
+ local t = { x = pos.x + faces[face].x, y = pos.y, z = pos.z + faces[face].z }
+ if minetest.get_node(t).name == "crops:pumpkin" then
+ return
+ end
+ end
+ local meta = minetest.get_meta(pos)
+ local ttl = meta:get_int("crops_pumpkin_ttl")
+ if ttl > 1 then
+ minetest.swap_node(pos, { name = "crops:pumpkin_plant_4" })
+ meta:set_int("crops_pumpkin_ttl", ttl)
+ else
+ minetest.swap_node(pos, { name = "crops:pumpkin_plant_6"})
+ meta:set_int("crops_pumpkin_ttl", 0)
+ end
+ end
+})
+
+crops.pumpkin_die = function(pos)
+ minetest.set_node(pos, { name = "crops:pumpkin_plant_6" })
+end
+
+local properties = {
+ die = crops.pumpkin_die,
+ waterstart = 40,
+ wateruse = 1,
+ night = 5,
+ soak = 80,
+ soak_damage = 90,
+ wither = 10,
+ wither_damage = 5,
+}
+
+crops.register({ name = "crops:pumpkin_plant_1", properties = properties })
+crops.register({ name = "crops:pumpkin_plant_2", properties = properties })
+crops.register({ name = "crops:pumpkin_plant_3", properties = properties })
+crops.register({ name = "crops:pumpkin_plant_4", properties = properties })
+crops.register({ name = "crops:pumpkin_plant_5", properties = properties })
+crops.register({ name = "crops:pumpkin_plant_5_attached", properties = properties })
diff --git a/textures/crops_pumpkin.png b/textures/crops_pumpkin.png
new file mode 100644
index 0000000..87c635e
--- /dev/null
+++ b/textures/crops_pumpkin.png
Binary files differ
diff --git a/textures/crops_pumpkin_bottom.png b/textures/crops_pumpkin_bottom.png
new file mode 100644
index 0000000..f0037e3
--- /dev/null
+++ b/textures/crops_pumpkin_bottom.png
Binary files differ
diff --git a/textures/crops_pumpkin_inv.png b/textures/crops_pumpkin_inv.png
new file mode 100644
index 0000000..4f8a2d4
--- /dev/null
+++ b/textures/crops_pumpkin_inv.png
Binary files differ
diff --git a/textures/crops_pumpkin_plant_1.png b/textures/crops_pumpkin_plant_1.png
new file mode 100644
index 0000000..a9649fc
--- /dev/null
+++ b/textures/crops_pumpkin_plant_1.png
Binary files differ
diff --git a/textures/crops_pumpkin_plant_2.png b/textures/crops_pumpkin_plant_2.png
new file mode 100644
index 0000000..19c96a9
--- /dev/null
+++ b/textures/crops_pumpkin_plant_2.png
Binary files differ
diff --git a/textures/crops_pumpkin_plant_3.png b/textures/crops_pumpkin_plant_3.png
new file mode 100644
index 0000000..990130a
--- /dev/null
+++ b/textures/crops_pumpkin_plant_3.png
Binary files differ
diff --git a/textures/crops_pumpkin_plant_4.png b/textures/crops_pumpkin_plant_4.png
new file mode 100644
index 0000000..d515db9
--- /dev/null
+++ b/textures/crops_pumpkin_plant_4.png
Binary files differ
diff --git a/textures/crops_pumpkin_plant_5.png b/textures/crops_pumpkin_plant_5.png
new file mode 100644
index 0000000..8ad4519
--- /dev/null
+++ b/textures/crops_pumpkin_plant_5.png
Binary files differ
diff --git a/textures/crops_pumpkin_plant_6.png b/textures/crops_pumpkin_plant_6.png
new file mode 100644
index 0000000..af9664f
--- /dev/null
+++ b/textures/crops_pumpkin_plant_6.png
Binary files differ
diff --git a/textures/crops_pumpkin_seed.png b/textures/crops_pumpkin_seed.png
new file mode 100644
index 0000000..9bce649
--- /dev/null
+++ b/textures/crops_pumpkin_seed.png
Binary files differ
diff --git a/textures/crops_pumpkin_stem.png b/textures/crops_pumpkin_stem.png
new file mode 100644
index 0000000..fcc7ef3
--- /dev/null
+++ b/textures/crops_pumpkin_stem.png
Binary files differ
diff --git a/textures/crops_pumpkin_top.png b/textures/crops_pumpkin_top.png
new file mode 100644
index 0000000..5f5059a
--- /dev/null
+++ b/textures/crops_pumpkin_top.png
Binary files differ
diff --git a/textures/crops_roasted_pumpkin.png b/textures/crops_roasted_pumpkin.png
new file mode 100644
index 0000000..b3f6fb7
--- /dev/null
+++ b/textures/crops_roasted_pumpkin.png
Binary files differ