summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.txt1
-rw-r--r--barley.lua96
-rw-r--r--beanpole.lua181
-rw-r--r--blueberry.lua88
-rw-r--r--carrot.lua176
-rw-r--r--cocoa.lua136
-rw-r--r--coffee.lua143
-rw-r--r--compatibility.lua2
-rw-r--r--corn.lua202
-rw-r--r--cotton.lua217
-rw-r--r--cucumber.lua93
-rw-r--r--grapes.lua252
-rw-r--r--grass.lua20
-rw-r--r--init.lua136
-rw-r--r--melon.lua146
-rw-r--r--potato.lua100
-rw-r--r--pumpkin.lua176
-rw-r--r--raspberry.lua89
-rw-r--r--rhubarb.lua74
-rw-r--r--textures/farming_barley.pngbin0 -> 230 bytes
-rw-r--r--textures/farming_barley_1.pngbin0 -> 140 bytes
-rw-r--r--textures/farming_barley_2.pngbin0 -> 151 bytes
-rw-r--r--textures/farming_barley_3.pngbin0 -> 209 bytes
-rw-r--r--textures/farming_barley_4.pngbin0 -> 229 bytes
-rw-r--r--textures/farming_barley_5.pngbin0 -> 246 bytes
-rw-r--r--textures/farming_barley_6.pngbin0 -> 271 bytes
-rw-r--r--textures/farming_barley_7.pngbin0 -> 277 bytes
-rw-r--r--textures/farming_barley_seed.pngbin0 -> 145 bytes
-rw-r--r--tomato.lua172
-rw-r--r--wheat.lua235
30 files changed, 949 insertions, 1786 deletions
diff --git a/README.txt b/README.txt
index 6792338..86a5fe3 100644
--- a/README.txt
+++ b/README.txt
@@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t
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.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
diff --git a/barley.lua b/barley.lua
new file mode 100644
index 0000000..d69b0ba
--- /dev/null
+++ b/barley.lua
@@ -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))
diff --git a/beanpole.lua b/beanpole.lua
index 634f6bf..d049438 100644
--- a/beanpole.lua
+++ b/beanpole.lua
@@ -2,39 +2,49 @@
All textures by
(C) Auke Kok <sofar@foo-projects.org>
CC-BY-SA-3.0
---]]
+]]
+-- beans
minetest.register_craftitem("farming:beans", {
description = "Green Beans",
inventory_image = "farming_beans.png",
on_use = minetest.item_eat(1),
+
on_place = function(itemstack, placer, pointed_thing)
+
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return
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"})
else
return
end
+
if not minetest.setting_getbool("creative_mode") then
+
itemstack:take_item()
+
-- check for refill
if itemstack:get_count() == 0 then
+
minetest.after(0.20,
farming.refill_plant,
placer,
"farming:beans",
placer:get_wield_index()
)
- end -- END refill
+ end
end
+
return itemstack
end
})
--- Beans can be used for green dye
+-- beans can be used for green dye
minetest.register_craft({
output = "dye:green",
recipe = {
@@ -42,8 +52,7 @@ minetest.register_craft({
}
})
--- Beanpole
-
+-- beanpole
minetest.register_node("farming:beanpole", {
description = "Bean Pole (place on soil before planting beans)",
drawtype = "plantlike",
@@ -54,33 +63,41 @@ minetest.register_node("farming:beanpole", {
walkable = false,
buildable_to = true,
sunlight_propagates = true,
- drop = {
- items = {
- {items = {'farming:beanpole'}, rarity = 1},
- }
- },
+ drop = "farming:beanpole",
selection_box = farming.select,
groups = {snappy = 3, flammable = 2, attached_node = 1},
sounds = default.node_sound_leaves_defaults(),
+
on_place = function(itemstack, placer, pointed_thing)
+
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return
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
end
+
local top = {
x = pointed_thing.above.x,
y = pointed_thing.above.y + 1,
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"})
+
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
+
return itemstack
end
})
@@ -100,9 +117,8 @@ minetest.register_craft({
burntime = 10,
})
--- Define Green Bean growth stages
-
-minetest.register_node("farming:beanpole_1", {
+-- green bean definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_beanpole_1.png"},
visual_scale = 1.45,
@@ -120,101 +136,38 @@ minetest.register_node("farming:beanpole_1", {
snappy = 3, flammable = 3, not_in_creative_inventory = 1,
attached_node = 1, growing = 1
},
- sounds = default.node_sound_leaves_defaults(),
-})
-
-minetest.register_node("farming:beanpole_2", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_beanpole_3.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_4", {
- drawtype = "plantlike",
- tiles = {"farming_beanpole_4.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(),
-})
-
--- Last stage of growth does not have growing group so abm never checks these
-
-minetest.register_node("farming:beanpole_5", {
- drawtype = "plantlike",
- tiles = {"farming_beanpole_5.png"},
- visual_scale = 1.45,
- paramtype = "light",
- walkable = false,
- buildable_to = true,
- sunlight_propagates = true,
- drop = {
- items = {
- {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)
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:beanpole_1", table.copy(crop_def))
+
+-- stage2
+crop_def.tiles = {"farming_beanpole_2.png"}
+minetest.register_node("farming:beanpole_2", table.copy(crop_def))
+
+-- stage 3
+crop_def.tiles = {"farming_beanpole_3.png"}
+minetest.register_node("farming:beanpole_3", table.copy(crop_def))
+
+-- stage 4
+crop_def.tiles = {"farming_beanpole_4.png"}
+minetest.register_node("farming:beanpole_4", table.copy(crop_def))
+
+-- stage 5 (final)
+crop_def.tiles = {"farming_beanpole_5.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:beanpole'}, rarity = 1},
+ {items = {'farming:beans 3'}, rarity = 1},
+ {items = {'farming:beans 2'}, rarity = 2},
+ {items = {'farming:beans 2'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:beanpole_5", table.copy(crop_def))
+-- wild green bean bush (this is what you find on the map)
minetest.register_node("farming:beanbush", {
drawtype = "plantlike",
tiles = {"farming_beanbush.png"},
@@ -236,4 +189,4 @@ minetest.register_node("farming:beanbush", {
not_in_creative_inventory=1
},
sounds = default.node_sound_leaves_defaults(),
-}) \ No newline at end of file
+})
diff --git a/blueberry.lua b/blueberry.lua
index f785c23..6a29ba9 100644
--- a/blueberry.lua
+++ b/blueberry.lua
@@ -1,6 +1,5 @@
---= Blueberries
-
+-- blueberries
minetest.register_craftitem("farming:blueberries", {
description = "Blueberries",
inventory_image = "farming_blueberries.png",
@@ -10,7 +9,7 @@ minetest.register_craftitem("farming:blueberries", {
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", {
description = "Blueberry Muffin",
@@ -25,9 +24,8 @@ minetest.register_craft({
}
})
--- Define Blueberry growth stages
-
-minetest.register_node("farming:blueberry_1", {
+-- blueberry definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_blueberry_1.png"},
paramtype = "light",
@@ -40,64 +38,28 @@ minetest.register_node("farming:blueberry_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 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", {
- drawtype = "plantlike",
- 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(),
-})
+-- stage 1
+minetest.register_node("farming:blueberry_1", table.copy(crop_def))
-minetest.register_node("farming:blueberry_3", {
- drawtype = "plantlike",
- tiles = {"farming_blueberry_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(),
-})
+-- stage 2
+crop_def.tiles = {"farming_blueberry_2.png"}
+minetest.register_node("farming:blueberry_2", table.copy(crop_def))
--- 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", {
- drawtype = "plantlike",
- tiles = {"farming_blueberry_4.png"},
- paramtype = "light",
- sunlight_propagates = true,
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:blueberries 2'}, rarity = 1},
- {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(),
-}) \ No newline at end of file
+-- stage 4 (final)
+crop_def.tiles = {"farming_blueberry_4.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:blueberries 2'}, rarity = 1},
+ {items = {'farming:blueberries'}, rarity = 2},
+ {items = {'farming:blueberries'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:blueberry_4", table.copy(crop_def))
diff --git a/carrot.lua b/carrot.lua
index 19bb3ec..cecaae7 100644
--- a/carrot.lua
+++ b/carrot.lua
@@ -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", {
description = "Carrot",
inventory_image = "farming_carrot.png",
@@ -11,8 +14,7 @@ minetest.register_craftitem("farming:carrot", {
on_use = minetest.item_eat(4),
})
--- Golden Carrot
-
+-- golden carrot
minetest.register_craftitem("farming:carrot_gold", {
description = "Golden Carrot",
inventory_image = "farming_carrot_gold.png",
@@ -28,9 +30,8 @@ minetest.register_craft({
}
})
--- Define Carrot growth stages
-
-minetest.register_node("farming:carrot_1", {
+-- carrot definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_carrot_1.png"},
paramtype = "light",
@@ -43,133 +44,50 @@ minetest.register_node("farming:carrot_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 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", {
- drawtype = "plantlike",
- 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(),
-})
+-- stage 1
+minetest.register_node("farming:carrot_1", table.copy(crop_def))
-minetest.register_node("farming:carrot_4", {
- drawtype = "plantlike",
- tiles = {"farming_carrot_4.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 2
+crop_def.tiles = {"farming_carrot_2.png"}
+minetest.register_node("farming:carrot_2", table.copy(crop_def))
-minetest.register_node("farming:carrot_5", {
- drawtype = "plantlike",
- tiles = {"farming_carrot_5.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(),
-})
+-- stage 3
+crop_def.tiles = {"farming_carrot_3.png"}
+minetest.register_node("farming:carrot_3", table.copy(crop_def))
-minetest.register_node("farming:carrot_6", {
- drawtype = "plantlike",
- tiles = {"farming_carrot_6.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(),
-})
+-- stage 4
+crop_def.tiles = {"farming_carrot_4.png"}
+minetest.register_node("farming:carrot_4", table.copy(crop_def))
-minetest.register_node("farming:carrot_7", {
- drawtype = "plantlike",
- tiles = {"farming_carrot_7.png"},
- 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(),
-})
+-- stage 5
+crop_def.tiles = {"farming_carrot_5.png"}
+minetest.register_node("farming:carrot_5", table.copy(crop_def))
--- 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", {
- drawtype = "plantlike",
- tiles = {"farming_carrot_8.png"},
- paramtype = "light",
- sunlight_propagates = true,
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:carrot 2'}, rarity = 1},
- {items = {'farming:carrot 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(),
-}) \ No newline at end of file
+-- stage 7
+crop_def.tiles = {"farming_carrot_7.png"}
+crop_def.drop = {
+ items = {
+ {items = {'farming:carrot'}, rarity = 1},
+ {items = {'farming:carrot 2'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:carrot_7", table.copy(crop_def))
+
+-- stage 8 (final)
+crop_def.tiles = {"farming_carrot_8.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:carrot 2'}, rarity = 1},
+ {items = {'farming:carrot 3'}, rarity = 2},
+ }
+}
+minetest.register_node("farming:carrot_8", table.copy(crop_def))
diff --git a/cocoa.lua b/cocoa.lua
index 3635ff4..e5e50cf 100644
--- a/cocoa.lua
+++ b/cocoa.lua
@@ -1,17 +1,17 @@
--- Place Cocoa
-
+-- place cocoa
function place_cocoa(itemstack, placer, pointed_thing, plantname)
+
local pt = pointed_thing
-- check if pointing at a node
- if not pt and pt.type ~= "node" then
+ if not pt or pt.type ~= "node" then
return
end
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
return
end
@@ -20,26 +20,30 @@ function place_cocoa(itemstack, placer, pointed_thing, plantname)
if under.name ~= "default:jungletree" then
return
end
-
+
-- add the node and remove 1 item from the itemstack
minetest.set_node(pt.above, {name = plantname})
+
if not minetest.setting_getbool("creative_mode") then
+
itemstack:take_item()
+
-- check for refill
if itemstack:get_count() == 0 then
+
minetest.after(0.20,
farming.refill_plant,
placer,
"farming:cocoa_beans",
placer:get_wield_index()
)
- end -- END refill
+ end
end
+
return itemstack
end
---= Cocoa
-
+-- cocoa beans
minetest.register_craftitem("farming:cocoa_beans", {
description = "Cocoa Beans",
inventory_image = "farming_cocoa_beans.png",
@@ -55,8 +59,7 @@ minetest.register_craft( {
}
})
--- Cookie
-
+-- chocolate cookie
minetest.register_craftitem("farming:cookie", {
description = "Cookie",
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", {
description = "Bar of Dark Chocolate",
inventory_image = "farming_chocolate_dark.png",
@@ -85,9 +87,8 @@ minetest.register_craft( {
}
})
--- Define Coffee growth stages
-
-minetest.register_node("farming:cocoa_1", {
+-- cocoa definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_cocoa_1.png"},
paramtype = "light",
@@ -105,81 +106,64 @@ minetest.register_node("farming:cocoa_1", {
snappy = 3, flammable = 2, plant = 1, growing = 1,
not_in_creative_inventory=1, leafdecay = 1, leafdecay_drop = 1
},
- sounds = default.node_sound_leaves_defaults(),
-})
-
-minetest.register_node("farming:cocoa_2", {
- drawtype = "plantlike",
- 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(),
-})
+ sounds = default.node_sound_leaves_defaults()
+}
--- Last stage of Cocoa growth does not have growing=1 so abm never has to check these
+-- stage 1
+minetest.register_node("farming:cocoa_1", table.copy(crop_def))
-minetest.register_node("farming:cocoa_3", {
- drawtype = "plantlike",
- tiles = {"farming_cocoa_3.png"},
- paramtype = "light",
- walkable = true,
- drop = {
- items = {
- {items = {'farming:cocoa_beans 2'}, rarity = 1},
- {items = {'farming:cocoa_beans 1'}, rarity = 2},
- }
- },
- 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
+-- 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))
+
+-- stage 3 (final)
+crop_def.tiles = {"farming_cocoa_3.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:cocoa_beans 2'}, rarity = 1},
+ {items = {'farming:cocoa_beans 1'}, rarity = 2},
+ }
+}
+minetest.register_node("farming:cocoa_3", table.copy(crop_def))
+-- add random cocoa pods to jungle tree trunks
minetest.register_abm({
nodenames = {"default:jungletree"},
neighbors = {"default:jungleleaves", "moretrees:jungletree_leaves_green"},
- interval = 80,
- chance = 20,
+ interval = 8,
+ chance = 80,
+ catch_up = false,
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
- elseif dir == 2 then pos.x = pos.x - 1
- elseif dir == 3 then pos.z = pos.z + 1
- elseif dir == 4 then pos.z = pos.z -1
+ if dir == 1 then
+ pos.x = pos.x + 1
+ elseif dir == 2 then
+ 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
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
--- print ("COCOA", pos.x, pos.y, pos.z)
+
+ --print ("Cocoa Pod added at " .. minetest.pos_to_string(pos))
+
minetest.set_node(pos, {
- name = "farming:cocoa_"..tostring(math.random(1, 3))
+ name = "farming:cocoa_" .. tostring(math.random(1, 3))
})
end
end,
-}) \ No newline at end of file
+})
diff --git a/coffee.lua b/coffee.lua
index 19c3f7f..c9854e6 100644
--- a/coffee.lua
+++ b/coffee.lua
@@ -1,6 +1,5 @@
---= Coffee
-
+-- coffee
minetest.register_craftitem("farming:coffee_beans", {
description = "Coffee Beans",
inventory_image = "farming_coffee_beans.png",
@@ -9,12 +8,8 @@ minetest.register_craftitem("farming:coffee_beans", {
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", {
description = "Drinking Cup (empty)",
drawtype = "plantlike",
@@ -39,15 +34,9 @@ minetest.register_craft( {
}
})
---= 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"),
---})
-
+-- cold cup of coffee
minetest.register_node("farming:coffee_cup", {
- description = "Cup of Coffee (cold)",
+ description = "Cold Cup of Coffee",
drawtype = "plantlike",
tiles = {"farming_coffee_cup.png"},
inventory_image = "farming_coffee_cup.png",
@@ -67,8 +56,6 @@ minetest.register_craft( {
output = "farming:coffee_cup",
recipe = {
{"farming:drinking_cup", "farming:coffee_beans","bucket:bucket_water"},
- {"","",""},
- {"","",""}
},
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}}
})
@@ -80,15 +67,9 @@ minetest.register_craft({
recipe = "farming:coffee_cup"
})
---= 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"),
---})
-
+-- hot cup of coffee
minetest.register_node("farming:coffee_cup_hot", {
- description = "Cup of Coffee (hot)",
+ description = "Hot Cup of Coffee",
drawtype = "plantlike",
tiles = {"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(),
})
--- Define Coffee growth stages
-
-minetest.register_node("farming:coffee_1", {
+-- coffee definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_coffee_1.png"},
paramtype = "light",
@@ -119,81 +99,32 @@ minetest.register_node("farming:coffee_1", {
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_2", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_coffee_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:coffee_4", {
- drawtype = "plantlike",
- tiles = {"farming_coffee_4.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 doesn not have growing group so abm never checks these
-
-minetest.register_node("farming:coffee_5", {
- drawtype = "plantlike",
- tiles = {"farming_coffee_5.png"},
- paramtype = "light",
- sunlight_propagates = true,
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:coffee_beans 2'}, rarity = 1},
- {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(),
-}) \ No newline at end of file
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:coffee_1", table.copy(crop_def))
+
+-- stage 2
+crop_def.tiles = {"farming_coffee_2.png"}
+minetest.register_node("farming:coffee_2", table.copy(crop_def))
+
+-- stage 3
+crop_def.tiles = {"farming_coffee_3.png"}
+minetest.register_node("farming:coffee_3", table.copy(crop_def))
+
+-- stage 4
+crop_def.tiles = {"farming_coffee_4.png"}
+minetest.register_node("farming:coffee_4", table.copy(crop_def))
+
+-- stage 5 (final)
+crop_def.tiles = {"farming_coffee_5.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:coffee_beans 2'}, rarity = 1},
+ {items = {'farming:coffee_beans 2'}, rarity = 2},
+ {items = {'farming:coffee_beans 2'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:coffee_5", table.copy(crop_def))
diff --git a/compatibility.lua b/compatibility.lua
index 708b54e..a875d9b 100644
--- a/compatibility.lua
+++ b/compatibility.lua
@@ -94,4 +94,4 @@ minetest.register_alias("farming_plus:tomato_3", "farming:tomato_6")
minetest.register_alias("farming_plus:tomato", "farming:tomato_8")
-- Weed
-minetest.register_alias("farming:weed", "default:grass_2") \ No newline at end of file
+minetest.register_alias("farming:weed", "default:grass_2")
diff --git a/corn.lua b/corn.lua
index dcb0833..4370757 100644
--- a/corn.lua
+++ b/corn.lua
@@ -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", {
description = "Corn",
inventory_image = "farming_corn.png",
@@ -11,8 +14,7 @@ minetest.register_craftitem("farming:corn", {
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", {
description = "Corn on the Cob",
inventory_image = "farming_corn_cob.png",
@@ -26,8 +28,7 @@ minetest.register_craft({
recipe = "farming:corn"
})
---= Ethanol (Thanks to JKMurray for this idea)
-
+-- ethanol (thanks to JKMurray for this idea)
minetest.register_craftitem("farming:bottle_ethanol", {
description = "Bottle of Ethanol",
inventory_image = "farming_bottle_ethanol.png",
@@ -48,9 +49,8 @@ minetest.register_craft({
replacements = {{ "farming:bottle_ethanol", "vessels:glass_bottle"}}
})
--- Define Corn growth stages
-
-minetest.register_node("farming:corn_1", {
+-- corn definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_corn_1.png"},
paramtype = "light",
@@ -63,138 +63,52 @@ minetest.register_node("farming:corn_1", {
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_2", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_corn_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:corn_4", {
- drawtype = "plantlike",
- tiles = {"farming_corn_4.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:corn_5", {
- drawtype = "plantlike",
- tiles = {"farming_corn_5.png"},
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_corn_6.png"},
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_corn_7.png"},
- visual_scale = 1.45,
- 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
-
-minetest.register_node("farming:corn_8", {
- drawtype = "plantlike",
- tiles = {"farming_corn_8.png"},
- visual_scale = 1.45,
- paramtype = "light",
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:corn 2'}, rarity = 1},
- {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(),
-}) \ No newline at end of file
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:corn_1", table.copy(crop_def))
+
+-- stage 2
+crop_def.tiles = {"farming_corn_2.png"}
+minetest.register_node("farming:corn_2", table.copy(crop_def))
+
+-- stage 3
+crop_def.tiles = {"farming_corn_3.png"}
+minetest.register_node("farming:corn_3", table.copy(crop_def))
+
+-- stage 4
+crop_def.tiles = {"farming_corn_4.png"}
+minetest.register_node("farming:corn_4", table.copy(crop_def))
+
+-- stage 5
+crop_def.tiles = {"farming_corn_5.png"}
+minetest.register_node("farming:corn_5", table.copy(crop_def))
+
+-- stage 6
+crop_def.tiles = {"farming_corn_6.png"}
+crop_def.visual_scale = 1.45
+minetest.register_node("farming:corn_6", table.copy(crop_def))
+
+-- 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))
+
+-- stage 8 (final)
+crop_def.tiles = {"farming_corn_8.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:corn 2'}, rarity = 1},
+ {items = {'farming:corn 2'}, rarity = 2},
+ {items = {'farming:corn 2'}, rarity = 2},
+ }
+}
+minetest.register_node("farming:corn_8", table.copy(crop_def))
diff --git a/cotton.lua b/cotton.lua
index 1edbd3a..2ddf88e 100644
--- a/cotton.lua
+++ b/cotton.lua
@@ -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", {
description = "Cotton Seed",
tiles = {"farming_cotton_seed.png"},
@@ -25,7 +17,7 @@ minetest.register_node("farming:seed_cotton", {
end,
})
--- Cotton
+-- cotton / string
minetest.register_craftitem("farming:cotton", {
description = "Cotton",
@@ -34,8 +26,7 @@ minetest.register_craftitem("farming:cotton", {
minetest.register_alias("farming:string", "farming:cotton")
--- String to Wool
-
+-- cotton to wool
minetest.register_craft({
output = "wool:white",
recipe = {
@@ -44,9 +35,8 @@ minetest.register_craft({
}
})
--- Define Cotton growth stages
-
-minetest.register_node("farming:cotton_1", {
+-- cotton definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_cotton_1.png"},
paramtype = "light",
@@ -59,147 +49,66 @@ minetest.register_node("farming:cotton_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 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", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_cotton_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:cotton_4", {
- drawtype = "plantlike",
- tiles = {"farming_cotton_4.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:cotton_5", {
- drawtype = "plantlike",
- tiles = {"farming_cotton_5.png"},
- 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(),
-})
+-- stage 1
+minetest.register_node("farming:cotton_1", table.copy(crop_def))
-minetest.register_node("farming:cotton_6", {
- drawtype = "plantlike",
- tiles = {"farming_cotton_6.png"},
- paramtype = "light",
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- 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(),
-})
+-- stage 2
+crop_def.tiles = {"farming_cotton_2.png"}
+minetest.register_node("farming:cotton_2", table.copy(crop_def))
-minetest.register_node("farming:cotton_7", {
- drawtype = "plantlike",
- tiles = {"farming_cotton_7.png"},
- paramtype = "light",
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {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(),
-})
+-- stage 3
+crop_def.tiles = {"farming_cotton_3.png"}
+minetest.register_node("farming:cotton_3", table.copy(crop_def))
--- Last stage of growth does not have growing group so abm never checks these
+-- stage 4
+crop_def.tiles = {"farming_cotton_4.png"}
+minetest.register_node("farming:cotton_4", table.copy(crop_def))
-minetest.register_node("farming:cotton_8", {
- drawtype = "plantlike",
- tiles = {"farming_cotton_8.png"},
- paramtype = "light",
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {"farming:string"}, rarity = 1},
- {items = {"farming:string"}, rarity = 2},
- {items = {"farming:string"}, rarity = 3},
- {items = {"farming:seed_cotton"}, rarity = 1},
- {items = {"farming:seed_cotton"}, rarity = 2},
- {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(),
-}) \ No newline at end of file
+-- stage 5
+crop_def.tiles = {"farming_cotton_5.png"}
+crop_def.drop = {
+ items = {
+ {items = {"farming:seed_cotton"}, rarity = 1},
+ }
+}
+minetest.register_node("farming:cotton_5", table.copy(crop_def))
+
+-- stage 6
+crop_def.tiles = {"farming_cotton_6.png"}
+crop_def.drop = {
+ items = {
+ {items = {"farming:cotton"}, rarity = 1},
+ {items = {"farming:cotton"}, rarity = 2},
+ }
+}
+minetest.register_node("farming:cotton_6", table.copy(crop_def))
+
+-- 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))
+
+-- stage 8 (final)
+crop_def.tiles = {"farming_cotton_8.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {"farming:string"}, rarity = 1},
+ {items = {"farming:string"}, rarity = 2},
+ {items = {"farming:string"}, rarity = 3},
+ {items = {"farming:seed_cotton"}, rarity = 1},
+ {items = {"farming:seed_cotton"}, rarity = 2},
+ {items = {"farming:seed_cotton"}, rarity = 3},
+ }
+}
+minetest.register_node("farming:cotton_8", table.copy(crop_def))
diff --git a/cucumber.lua b/cucumber.lua
index 6a1bbab..22e367b 100644
--- a/cucumber.lua
+++ b/cucumber.lua
@@ -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", {
description = "Cucumber",
inventory_image = "farming_cucumber.png",
@@ -11,9 +14,8 @@ minetest.register_craftitem("farming:cucumber", {
on_use = minetest.item_eat(4),
})
--- Define Cucumber growth stages
-
-minetest.register_node("farming:cucumber_1", {
+-- cucumber definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_cucumber_1.png"},
paramtype = "light",
@@ -25,60 +27,27 @@ minetest.register_node("farming:cucumber_1", {
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_2", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_cucumber_3.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(),
-})
-
--- Last stage of growth does not have growing group so abm never checks these
-
-minetest.register_node("farming:cucumber_4", {
- drawtype = "plantlike",
- tiles = {"farming_cucumber_4.png"},
- paramtype = "light",
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:cucumber'}, rarity = 1},
- {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(),
-}) \ No newline at end of file
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:cucumber_1", table.copy(crop_def))
+
+-- stage 2
+crop_def.tiles = {"farming_cucumber_2.png"}
+minetest.register_node("farming:cucumber_2", table.copy(crop_def))
+
+-- stage 3
+crop_def.tiles = {"farming_cucumber_3.png"}
+minetest.register_node("farming:cucumber_3", table.copy(crop_def))
+
+-- stage 4 (final)
+crop_def.tiles = {"farming_cucumber_4.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:cucumber'}, rarity = 1},
+ {items = {'farming:cucumber 2'}, rarity = 2},
+ }
+}
+minetest.register_node("farming:cucumber_4", table.copy(crop_def))
diff --git a/grapes.lua b/grapes.lua
index a82e02e..a23f560 100644
--- a/grapes.lua
+++ b/grapes.lua
@@ -1,36 +1,45 @@
--- Grapes
+-- grapes
minetest.register_craftitem("farming:grapes", {
description = "Grapes",
inventory_image = "farming_grapes.png",
on_use = minetest.item_eat(2),
+
on_place = function(itemstack, placer, pointed_thing)
+
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return
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"})
else
return
end
+
if not minetest.setting_getbool("creative_mode") then
+
itemstack:take_item()
+
-- check for refill
if itemstack:get_count() == 0 then
+
minetest.after(0.20,
farming.refill_plant,
placer,
"farming:grapes",
placer:get_wield_index()
)
- end -- END refill
+ end
end
+
return itemstack
end
})
--- Grapes can be used for violet dye
+-- grapes can be used for violet dye
minetest.register_craft({
output = "dye:violet",
recipe = {
@@ -38,8 +47,7 @@ minetest.register_craft({
}
})
--- Trellis
-
+-- trellis
minetest.register_node("farming:trellis", {
description = "Trellis (place on soil before planting grapes)",
drawtype = "plantlike",
@@ -50,33 +58,41 @@ minetest.register_node("farming:trellis", {
walkable = false,
buildable_to = true,
sunlight_propagates = true,
- drop = {
- items = {
- {items = {'farming:trellis'}, rarity = 1},
- }
- },
+ drop = "farming:trellis",
selection_box = farming.select,
groups = {snappy = 3, flammable = 2, attached_node = 1},
sounds = default.node_sound_leaves_defaults(),
+
on_place = function(itemstack, placer, pointed_thing)
+
if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then
return
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
end
+
local top = {
x = pointed_thing.above.x,
y = pointed_thing.above.y + 1,
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"})
+
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
+
return itemstack
end
})
@@ -96,9 +112,8 @@ minetest.register_craft({
burntime = 15,
})
--- Define Grapes growth stages
-
-minetest.register_node("farming:grapes_1", {
+-- grapes definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_grapes_1.png"},
visual_scale = 1.45,
@@ -116,163 +131,50 @@ minetest.register_node("farming:grapes_1", {
snappy = 3, flammable = 3, not_in_creative_inventory = 1,
attached_node = 1, growing = 1
},
- sounds = default.node_sound_leaves_defaults(),
-})
-
-minetest.register_node("farming:grapes_2", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_grapes_3.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_4", {
- drawtype = "plantlike",
- tiles = {"farming_grapes_4.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_5", {
- drawtype = "plantlike",
- tiles = {"farming_grapes_5.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_6", {
- drawtype = "plantlike",
- tiles = {"farming_grapes_6.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_7", {
- drawtype = "plantlike",
- tiles = {"farming_grapes_7.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(),
-})
-
--- Last stage of growth does not have growing group so abm never checks these
-
-minetest.register_node("farming:grapes_8", {
- drawtype = "plantlike",
- tiles = {"farming_grapes_8.png"},
- visual_scale = 1.45,
- paramtype = "light",
- walkable = false,
- buildable_to = true,
- sunlight_propagates = true,
- drop = {
- items = {
- {items = {'farming:trellis'}, rarity = 1},
- {items = {'farming:grapes 3'}, rarity = 1},
- {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)
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:grapes_1", table.copy(crop_def))
+
+-- stage2
+crop_def.tiles = {"farming_grapes_2.png"}
+minetest.register_node("farming:grapes_2", table.copy(crop_def))
+
+-- stage 3
+crop_def.tiles = {"farming_grapes_3.png"}
+minetest.register_node("farming:grapes_3", table.copy(crop_def))
+
+-- stage 4
+crop_def.tiles = {"farming_grapes_4.png"}
+minetest.register_node("farming:grapes_4", table.copy(crop_def))
+
+-- stage 5
+crop_def.tiles = {"farming_grapes_5.png"}
+minetest.register_node("farming:grapes_5", table.copy(crop_def))
+
+-- stage 6
+crop_def.tiles = {"farming_grapes_6.png"}
+minetest.register_node("farming:grapes_6", table.copy(crop_def))
+
+-- stage 7
+crop_def.tiles = {"farming_grapes_7.png"}
+minetest.register_node("farming:grapes_7", table.copy(crop_def))
+
+-- stage 8 (final)
+crop_def.tiles = {"farming_grapes_8.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:trellis'}, rarity = 1},
+ {items = {'farming:grapes 3'}, rarity = 1},
+ {items = {'farming:grapes 1'}, rarity = 2},
+ {items = {'farming:grapes 1'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:grapes_8", table.copy(crop_def))
+-- wild grape vine (this is what you find on the map)
minetest.register_node("farming:grapebush", {
drawtype = "plantlike",
tiles = {"farming_grapebush.png"},
diff --git a/grass.lua b/grass.lua
index 288299b..aacb220 100644
--- a/grass.lua
+++ b/grass.lua
@@ -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, {
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
-- Override default Jungle Grass and have it drop Cotton Seeds
@@ -25,4 +39,4 @@ minetest.override_item("default:junglegrass", {
{items = {'default:junglegrass'}},
}
},
-}) \ No newline at end of file
+})
diff --git a/init.lua b/init.lua
index d13279e..e141ead 100644
--- a/init.lua
+++ b/init.lua
@@ -1,5 +1,5 @@
--[[
- Minetest Farming Redo Mod 1.22 (8th December 2015)
+ Minetest Farming Redo Mod 1.22 (10th March 2016)
by TenPlus1
NEW growing routine by prestidigitator
auto-refill by crabman77
@@ -69,6 +69,7 @@ dofile(farming.path.."/blueberry.lua")
dofile(farming.path.."/rhubarb.lua")
dofile(farming.path.."/beanpole.lua")
dofile(farming.path.."/grapes.lua")
+dofile(farming.path.."/barley.lua")
dofile(farming.path.."/donut.lua")
dofile(farming.path.."/mapgen.lua")
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
@@ -76,7 +77,7 @@ dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
-- Utility Functions
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)
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 node.name then
- name = node.name
+ name = node.name
elseif node.x and node.y and node.z then
node = minetest.get_node_or_nil(node)
name = node and node.name
@@ -189,7 +190,9 @@ local function plant_name_stage(node)
name = tostring(node)
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("_[^_]+$")
@@ -205,8 +208,9 @@ local function plant_name_stage(node)
return name, 0
end
---- Map from node name to
- -- { plant_name = ..., name = ..., stage = n, stages_left = { node_name, ... } }
+-- Map from node name to
+-- { plant_name = ..., name = ..., stage = n, stages_left = { node_name, ... } }
+
local 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_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]
- if stages then return stages end
+ if stages then
+ return stages
+ end
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,
{
on_construct = function(pos)
- if old_constr then old_constr(pos) end
+
+ if old_constr then
+ old_constr(pos)
+ end
+
farming.handle_growth(pos)
end,
on_destruct = function(pos)
+
minetest.get_node_timer(pos):stop()
- if old_destr then old_destr(pos) end
+
+ if old_destr then
+ old_destr(pos)
+ end
end,
on_timer = function(pos, elapsed)
@@ -290,6 +306,7 @@ register_plant_node = function(node)
local plant_name, stage = plant_name_stage(node)
if plant_name then
+
local stages = reg_plant_stages(plant_name, stage, false)
return stages and #stages.stages_left
else
@@ -299,7 +316,9 @@ end
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)
@@ -319,28 +338,33 @@ local function set_growing(pos, stages_left)
end
end
---- 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 node
- -- The cached node table if available, or nil.
+-- 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 node
+-- The cached node table if available, or nil.
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)
- if stages_left then set_growing(pos, stages_left) end
+ if stages_left then
+ set_growing(pos, stages_left)
+ end
end
-minetest.after(0,
- function()
- for _, node_def in pairs(minetest.registered_nodes) do
- register_plant_node(node_def)
- end
- end)
+minetest.after(0, function()
+
+ for _, node_def in pairs(minetest.registered_nodes) do
+ register_plant_node(node_def)
+ end
+end)
local abm_func = farming.handle_growth
@@ -349,6 +373,7 @@ if farming.DEBUG then
local normal_abm_func = abm_func
abm_func = function(...)
+
local t0 = minetest.get_us_time()
local r = { normal_abm_func(...) }
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
-- nodes added to map before timers were incorporated).
-minetest.register_abm({
+minetest.register_abm({
nodenames = { "group:growing" },
interval = 300,
chance = 1,
action = abm_func
})
---- Plant timer function.
- --
- -- Grows plants under the right conditions.
+-- Plant timer function.
+-- Grows plants under the right conditions.
function farming.plant_growth_timer(pos, elapsed, 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
- if max_growth <= 0 then return false end
+ if max_growth <= 0 then
+ return false
+ end
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
end
else
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
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
- 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
- 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)
- 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
else
- local night_light = (minetest.get_node_light(light_pos, 0) or 0) -- CHANGED
- local day_light = (minetest.get_node_light(light_pos, 0.5) 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)
local night_growth = in_range(night_light, MIN_LIGHT, MAX_LIGHT)
local day_growth = in_range(day_light, MIN_LIGHT, MAX_LIGHT)
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
+
elseif not day_growth then
+
lambda = night_time(elapsed) / STAGE_LENGTH_AVG
end
growth = statistics.poisson(lambda, max_growth)
- if growth < 1 then return true end
+ if growth < 1 then
+ return true
+ end
end
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
return true
end
@@ -479,7 +523,9 @@ function farming.refill_plant(player, plantname, index)
local inv = player:get_inventory()
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
@@ -492,7 +538,7 @@ function farming.refill_plant(player, plantname, index)
return
end
end
-end -- END refill
+end
-- Place Seeds on Soil
@@ -646,4 +692,4 @@ farming.register_plant("farming:cotton", {
description = "Cotton2 seed",
inventory_image = "farming_cotton_seed.png",
steps = 8,
-})]] \ No newline at end of file
+})]]
diff --git a/melon.lua b/melon.lua
index 77b2390..e82ddaf 100644
--- a/melon.lua
+++ b/melon.lua
@@ -1,6 +1,5 @@
---= Melon
-
+-- melon
minetest.register_craftitem("farming:melon_slice", {
description = "Melon Slice",
inventory_image = "farming_melon_slice.png",
@@ -26,9 +25,8 @@ minetest.register_craft({
}
})
--- Define Melon growth stages
-
-minetest.register_node("farming:melon_1", {
+-- melon definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_melon_1.png"},
paramtype = "light",
@@ -41,119 +39,41 @@ minetest.register_node("farming:melon_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 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", {
- drawtype = "plantlike",
- 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(),
-})
+-- stage 1
+minetest.register_node("farming:melon_1", table.copy(crop_def))
-minetest.register_node("farming:melon_3", {
- drawtype = "plantlike",
- tiles = {"farming_melon_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(),
-})
+-- stage 2
+crop_def.tiles = {"farming_melon_2.png"}
+minetest.register_node("farming:melon_2", table.copy(crop_def))
-minetest.register_node("farming:melon_4", {
- drawtype = "plantlike",
- tiles = {"farming_melon_4.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(),
-})
+-- stage 3
+crop_def.tiles = {"farming_melon_3.png"}
+minetest.register_node("farming:melon_3", table.copy(crop_def))
-minetest.register_node("farming:melon_5", {
- drawtype = "plantlike",
- tiles = {"farming_melon_5.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(),
-})
+-- stage 4
+crop_def.tiles = {"farming_melon_4.png"}
+minetest.register_node("farming:melon_4", table.copy(crop_def))
-minetest.register_node("farming:melon_6", {
- drawtype = "plantlike",
- tiles = {"farming_melon_6.png"},
- 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(),
-})
+-- stage 5
+crop_def.tiles = {"farming_melon_5.png"}
+minetest.register_node("farming:melon_5", table.copy(crop_def))
-minetest.register_node("farming:melon_7", {
- drawtype = "plantlike",
- tiles = {"farming_melon_7.png"},
- 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(),
-})
+-- stage 6
+crop_def.tiles = {"farming_melon_6.png"}
+minetest.register_node("farming:melon_6", table.copy(crop_def))
--- 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", {
- --drawtype = "nodebox",
- description = "Melon",
- tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"},
- paramtype = "light",
- walkable = true,
- drop = {
- items = {
- {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(),
-}) \ No newline at end of file
+-- stage 8 (final)
+crop_def.drawtype = "nodebox"
+crop_def.description = "Melon"
+crop_def.tiles = {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png"}
+crop_def.selection_box = {-.5, -.5, -.5, .5, .5, .5}
+crop_def.groups = {snappy = 1, oddly_breakable_by_hand = 1, flammable = 2, plant = 1}
+crop_def.drop = "farming:melon_slice 9"
+minetest.register_node("farming:melon_8", table.copy(crop_def))
diff --git a/potato.lua b/potato.lua
index fb13d99..12a7c6a 100644
--- a/potato.lua
+++ b/potato.lua
@@ -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", {
description = "Potato",
inventory_image = "farming_potato.png",
@@ -11,6 +14,7 @@ minetest.register_craftitem("farming:potato", {
on_use = minetest.item_eat(1),
})
+-- baked potato
minetest.register_craftitem("farming:baked_potato", {
description = "Baked Potato",
inventory_image = "farming_baked_potato.png",
@@ -24,9 +28,8 @@ minetest.register_craft({
recipe = "farming:potato"
})
--- Define Potato growth stages
-
-minetest.register_node("farming:potato_1", {
+-- potato definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_potato_1.png"},
paramtype = "light",
@@ -40,68 +43,33 @@ minetest.register_node("farming:potato_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 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", {
- drawtype = "plantlike",
- 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(),
-})
+-- stage 1
+minetest.register_node("farming:potato_1", table.copy(crop_def))
-minetest.register_node("farming:potato_3", {
- drawtype = "plantlike",
- tiles = {"farming_potato_3.png"},
- 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(),
-})
+-- stage 2
+crop_def.tiles = {"farming_potato_2.png"}
+minetest.register_node("farming:potato_2", table.copy(crop_def))
--- 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", {
- drawtype = "plantlike",
- tiles = {"farming_potato_4.png"},
- paramtype = "light",
- sunlight_propagates = true,
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {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(),
-}) \ No newline at end of file
+-- stage 4
+crop_def.tiles = {"farming_potato_4.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:potato 2'}, rarity = 1},
+ {items = {'farming:potato 3'}, rarity = 2},
+ }
+}
+minetest.register_node("farming:potato_4", table.copy(crop_def))
diff --git a/pumpkin.lua b/pumpkin.lua
index 708d7ea..e443d66 100644
--- a/pumpkin.lua
+++ b/pumpkin.lua
@@ -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", {
description = "Pumpkin",
tiles = {
@@ -20,6 +23,7 @@ minetest.register_node("farming:pumpkin", {
sounds = default.node_sound_wood_defaults(),
})
+-- pumpkin slice
minetest.register_craftitem("farming:pumpkin_slice", {
description = "Pumpkin Slice",
inventory_image = "farming_pumpkin_slice.png",
@@ -45,7 +49,7 @@ minetest.register_craft({
}
})
--- Jack 'O Lantern
+-- jack 'o lantern
minetest.register_node("farming:jackolantern", {
description = "Jack 'O Lantern",
tiles = {
@@ -95,7 +99,7 @@ minetest.register_craft({
}
})
--- Pumpkin Bread
+-- pumpkin bread
minetest.register_craftitem("farming:pumpkin_bread", {
description = ("Pumpkin Bread"),
inventory_image = "farming_pumpkin_bread.png",
@@ -120,9 +124,8 @@ minetest.register_craft({
cooktime = 10
})
--- Define Pumpkin growth stages
-
-minetest.register_node("farming:pumpkin_1", {
+-- pumpkin definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_pumpkin_1.png"},
paramtype = "light",
@@ -136,125 +139,42 @@ minetest.register_node("farming:pumpkin_1", {
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_2", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_pumpkin_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:pumpkin_4", {
- drawtype = "plantlike",
- tiles = {"farming_pumpkin_4.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_5", {
- drawtype = "plantlike",
- tiles = {"farming_pumpkin_5.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_6", {
- drawtype = "plantlike",
- tiles = {"farming_pumpkin_6.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:pumpkin_7", {
- drawtype = "plantlike",
- tiles = {"farming_pumpkin_7.png"},
- 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
-
-minetest.register_node("farming:pumpkin_8", {
- drawtype = "plantlike",
- tiles = {"farming_pumpkin_8.png"},
- paramtype = "light",
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:pumpkin_slice 9'}, rarity = 1},
- }
- },
- selection_box = farming.select,
- groups = {
- snappy = 3, flammable = 2, plant = 1, attached_node = 1,
- not_in_creative_inventory = 1
- },
- sounds = default.node_sound_defaults(),
-}) \ No newline at end of file
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:pumpkin_1", table.copy(crop_def))
+
+-- stage 2
+crop_def.tiles = {"farming_pumpkin_2.png"}
+minetest.register_node("farming:pumpkin_2", table.copy(crop_def))
+
+-- stage 3
+crop_def.tiles = {"farming_pumpkin_3.png"}
+minetest.register_node("farming:pumpkin_3", table.copy(crop_def))
+
+-- stage 4
+crop_def.tiles = {"farming_pumpkin_4.png"}
+minetest.register_node("farming:pumpkin_4", table.copy(crop_def))
+
+-- stage 5
+crop_def.tiles = {"farming_pumpkin_5.png"}
+minetest.register_node("farming:pumpkin_5", table.copy(crop_def))
+
+-- stage 6
+crop_def.tiles = {"farming_pumpkin_6.png"}
+minetest.register_node("farming:pumpkin_6", table.copy(crop_def))
+
+-- stage 7
+crop_def.tiles = {"farming_pumpkin_7.png"}
+minetest.register_node("farming:pumpkin_7", table.copy(crop_def))
+
+-- stage 8 (final)
+crop_def.tiles = {"farming_pumpkin_8.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:pumpkin_slice 9'}, rarity = 1},
+ }
+}
+minetest.register_node("farming:pumpkin_8", table.copy(crop_def))
diff --git a/raspberry.lua b/raspberry.lua
index b202f60..51d10cc 100644
--- a/raspberry.lua
+++ b/raspberry.lua
@@ -1,6 +1,5 @@
---= Raspberries
-
+-- raspberries
minetest.register_craftitem("farming:raspberries", {
description = "Raspberries",
inventory_image = "farming_raspberries.png",
@@ -10,8 +9,7 @@ minetest.register_craftitem("farming:raspberries", {
on_use = minetest.item_eat(1),
})
--- Raspberry Smoothie
-
+-- raspberry smoothie
minetest.register_craftitem("farming:smoothie_raspberry", {
description = "Raspberry Smoothie",
inventory_image = "farming_raspberry_smoothie.png",
@@ -27,9 +25,8 @@ minetest.register_craft({
}
})
--- Define Raspberry growth stages
-
-minetest.register_node("farming:raspberry_1", {
+-- raspberries definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_raspberry_1.png"},
paramtype = "light",
@@ -42,64 +39,28 @@ minetest.register_node("farming:raspberry_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 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", {
- drawtype = "plantlike",
- 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(),
-})
+-- stage 1
+minetest.register_node("farming:raspberry_1", table.copy(crop_def))
-minetest.register_node("farming:raspberry_3", {
- drawtype = "plantlike",
- tiles = {"farming_raspberry_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(),
-})
+-- stage 2
+crop_def.tiles = {"farming_raspberry_2.png"}
+minetest.register_node("farming:raspberry_2", table.copy(crop_def))
--- 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", {
- drawtype = "plantlike",
- tiles = {"farming_raspberry_4.png"},
- paramtype = "light",
- sunlight_propagates = true,
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:raspberries 2'}, rarity = 1},
- {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(),
-}) \ No newline at end of file
+-- stage 4 (final)
+crop_def.tiles = {"farming_raspberry_4.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:raspberries 2'}, rarity = 1},
+ {items = {'farming:raspberries'}, rarity = 2},
+ {items = {'farming:raspberries'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:raspberry_4", table.copy(crop_def))
diff --git a/rhubarb.lua b/rhubarb.lua
index 1f1f404..c93b058 100644
--- a/rhubarb.lua
+++ b/rhubarb.lua
@@ -1,6 +1,5 @@
---= Rhubarb
-
+-- rhubarb
minetest.register_craftitem("farming:rhubarb", {
description = "Rhubarb",
inventory_image = "farming_rhubarb.png",
@@ -10,6 +9,7 @@ minetest.register_craftitem("farming:rhubarb", {
on_use = minetest.item_eat(1),
})
+-- rhubarb pie
minetest.register_craftitem("farming:rhubarb_pie", {
description = "Rhubarb Pie",
inventory_image = "farming_rhubarb_pie.png",
@@ -25,9 +25,8 @@ minetest.register_craft({
}
})
--- Define Rhubarb growth stages
-
-minetest.register_node("farming:rhubarb_1", {
+-- rhubarb definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_rhubarb_1.png"},
paramtype = "light",
@@ -40,47 +39,24 @@ minetest.register_node("farming:rhubarb_1", {
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:rhubarb_2", {
- drawtype = "plantlike",
- 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
-
-minetest.register_node("farming:rhubarb_3", {
- drawtype = "plantlike",
- tiles = {"farming_rhubarb_3.png"},
- paramtype = "light",
- sunlight_propagates = true,
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:rhubarb 2'}, rarity = 1},
- {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(),
-}) \ No newline at end of file
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:rhubarb_1", table.copy(crop_def))
+
+-- stage2
+crop_def.tiles = {"farming_rhubarb_2.png"}
+minetest.register_node("farming:rhubarb_2", table.copy(crop_def))
+
+-- stage 3 (final)
+crop_def.tiles = {"farming_rhubarb_3.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:rhubarb 2'}, rarity = 1},
+ {items = {'farming:rhubarb'}, rarity = 2},
+ {items = {'farming:rhubarb'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:rhubarb_3", table.copy(crop_def))
diff --git a/textures/farming_barley.png b/textures/farming_barley.png
new file mode 100644
index 0000000..ca929e0
--- /dev/null
+++ b/textures/farming_barley.png
Binary files differ
diff --git a/textures/farming_barley_1.png b/textures/farming_barley_1.png
new file mode 100644
index 0000000..4a458b1
--- /dev/null
+++ b/textures/farming_barley_1.png
Binary files differ
diff --git a/textures/farming_barley_2.png b/textures/farming_barley_2.png
new file mode 100644
index 0000000..96610c2
--- /dev/null
+++ b/textures/farming_barley_2.png
Binary files differ
diff --git a/textures/farming_barley_3.png b/textures/farming_barley_3.png
new file mode 100644
index 0000000..ef14b5b
--- /dev/null
+++ b/textures/farming_barley_3.png
Binary files differ
diff --git a/textures/farming_barley_4.png b/textures/farming_barley_4.png
new file mode 100644
index 0000000..f7c9054
--- /dev/null
+++ b/textures/farming_barley_4.png
Binary files differ
diff --git a/textures/farming_barley_5.png b/textures/farming_barley_5.png
new file mode 100644
index 0000000..68c0d68
--- /dev/null
+++ b/textures/farming_barley_5.png
Binary files differ
diff --git a/textures/farming_barley_6.png b/textures/farming_barley_6.png
new file mode 100644
index 0000000..496a218
--- /dev/null
+++ b/textures/farming_barley_6.png
Binary files differ
diff --git a/textures/farming_barley_7.png b/textures/farming_barley_7.png
new file mode 100644
index 0000000..1c636af
--- /dev/null
+++ b/textures/farming_barley_7.png
Binary files differ
diff --git a/textures/farming_barley_seed.png b/textures/farming_barley_seed.png
new file mode 100644
index 0000000..2f00a20
--- /dev/null
+++ b/textures/farming_barley_seed.png
Binary files differ
diff --git a/tomato.lua b/tomato.lua
index 99c091a..9cff4a7 100644
--- a/tomato.lua
+++ b/tomato.lua
@@ -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", {
description = "Tomato",
inventory_image = "farming_tomato.png",
@@ -11,9 +14,8 @@ minetest.register_craftitem("farming:tomato", {
on_use = minetest.item_eat(4),
})
--- Define Tomato growth stages
-
-minetest.register_node("farming:tomato_1", {
+-- tomato definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_tomato_1.png"},
paramtype = "light",
@@ -26,133 +28,49 @@ minetest.register_node("farming:tomato_1", {
snappy = 3, flammable = 2, plant = 1, attached_node = 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", {
- drawtype = "plantlike",
- 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(),
-})
+-- stage 1
+minetest.register_node("farming:tomato_1", table.copy(crop_def))
-minetest.register_node("farming:tomato_3", {
- drawtype = "plantlike",
- tiles = {"farming_tomato_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(),
-})
+-- stage2
+crop_def.tiles = {"farming_tomato_2.png"}
+minetest.register_node("farming:tomato_2", table.copy(crop_def))
-minetest.register_node("farming:tomato_4", {
- drawtype = "plantlike",
- tiles = {"farming_tomato_4.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(),
-})
+-- stage 3
+crop_def.tiles = {"farming_tomato_3.png"}
+minetest.register_node("farming:tomato_3", table.copy(crop_def))
-minetest.register_node("farming:tomato_5", {
- drawtype = "plantlike",
- tiles = {"farming_tomato_5.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(),
-})
+-- stage 4
+crop_def.tiles = {"farming_tomato_4.png"}
+minetest.register_node("farming:tomato_4", table.copy(crop_def))
-minetest.register_node("farming:tomato_6", {
- drawtype = "plantlike",
- tiles = {"farming_tomato_6.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(),
-})
+-- stage 5
+crop_def.tiles = {"farming_tomato_5.png"}
+minetest.register_node("farming:tomato_5", table.copy(crop_def))
-minetest.register_node("farming:tomato_7", {
- drawtype = "plantlike",
- tiles = {"farming_tomato_7.png"},
- 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(),
-})
+-- stage 6
+crop_def.tiles = {"farming_tomato_6.png"}
+minetest.register_node("farming:tomato_6", table.copy(crop_def))
--- 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", {
- drawtype = "plantlike",
- tiles = {"farming_tomato_8.png"},
- paramtype = "light",
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:tomato 3'}, rarity = 1},
- {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(),
-}) \ No newline at end of file
+-- stage 8 (final)
+crop_def.tiles = {"farming_tomato_8.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:tomato 3'}, rarity = 1},
+ {items = {'farming:tomato 3'}, rarity = 2},
+ }
+}
+minetest.register_node("farming:tomato_8", table.copy(crop_def))
diff --git a/wheat.lua b/wheat.lua
index d2bad0d..c19ac27 100644
--- a/wheat.lua
+++ b/wheat.lua
@@ -1,16 +1,5 @@
---= Wheat
-
--- 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,
---})
-
+-- wheat seeds
minetest.register_node("farming:seed_wheat", {
description = "Wheat Seed",
tiles = {"farming_wheat_seed.png"},
@@ -28,15 +17,13 @@ minetest.register_node("farming:seed_wheat", {
end,
})
--- Harvested Wheat
-
+-- harvested wheat
minetest.register_craftitem("farming:wheat", {
description = "Wheat",
inventory_image = "farming_wheat.png",
})
--- Straw
-
+-- straw
minetest.register_node("farming:straw", {
description = "Straw",
tiles = {"farming_straw.png"},
@@ -62,7 +49,6 @@ minetest.register_craft({
})
-- flour
-
minetest.register_craftitem("farming:flour", {
description = "Flour",
inventory_image = "farming_flour.png",
@@ -74,8 +60,7 @@ minetest.register_craft({
recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"}
})
--- Bread
-
+-- bread
minetest.register_craftitem("farming:bread", {
description = "Bread",
inventory_image = "farming_bread.png",
@@ -89,9 +74,8 @@ minetest.register_craft({
recipe = "farming:flour"
})
--- Define Wheat growth stages
-
-minetest.register_node("farming:wheat_1", {
+-- wheat definition
+local crop_def = {
drawtype = "plantlike",
tiles = {"farming_wheat_1.png"},
paramtype = "light",
@@ -102,150 +86,67 @@ minetest.register_node("farming:wheat_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_2", {
- drawtype = "plantlike",
- tiles = {"farming_wheat_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:wheat_3", {
- drawtype = "plantlike",
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_wheat_4.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_5", {
- drawtype = "plantlike",
- tiles = {"farming_wheat_5.png"},
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_wheat_6.png"},
- 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", {
- drawtype = "plantlike",
- tiles = {"farming_wheat_7.png"},
- paramtype = "light",
- sunlight_propagates = true,
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- 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
-
-minetest.register_node("farming:wheat_8", {
- drawtype = "plantlike",
- tiles = {"farming_wheat_8.png"},
- paramtype = "light",
- waving = 1,
- walkable = false,
- buildable_to = true,
- drop = {
- items = {
- {items = {'farming:wheat'}, rarity = 1},
- {items = {'farming:wheat'}, rarity = 2},
- {items = {'farming:seed_wheat'}, rarity = 1},
- {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
- },
- sounds = default.node_sound_leaves_defaults(),
-}) \ No newline at end of file
+ sounds = default.node_sound_leaves_defaults()
+}
+
+-- stage 1
+minetest.register_node("farming:wheat_1", table.copy(crop_def))
+
+-- stage 2
+crop_def.tiles = {"farming_wheat_2.png"}
+minetest.register_node("farming:wheat_2", table.copy(crop_def))
+
+-- stage 3
+crop_def.tiles = {"farming_wheat_3.png"}
+minetest.register_node("farming:wheat_3", table.copy(crop_def))
+
+-- stage 4
+crop_def.tiles = {"farming_wheat_4.png"}
+minetest.register_node("farming:wheat_4", table.copy(crop_def))
+
+-- stage 5
+crop_def.tiles = {"farming_wheat_5.png"}
+crop_def.drop = {
+ items = {
+ {items = {'farming:wheat'}, rarity = 2},
+ {items = {'farming:seed_wheat'}, rarity = 2},
+ }
+}
+minetest.register_node("farming:wheat_5", table.copy(crop_def))
+
+-- 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))
+
+-- stage 7
+crop_def.tiles = {"farming_wheat_7.png"}
+crop_def.drop = {
+ items = {
+ {items = {'farming:wheat'}, rarity = 1},
+ {items = {'farming:wheat'}, rarity = 3},
+ {items = {'farming:seed_wheat'}, rarity = 1},
+ {items = {'farming:seed_wheat'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:wheat_7", table.copy(crop_def))
+
+-- stage 8 (final)
+crop_def.tiles = {"farming_wheat_8.png"}
+crop_def.groups.growing = 0
+crop_def.drop = {
+ items = {
+ {items = {'farming:wheat'}, rarity = 1},
+ {items = {'farming:wheat'}, rarity = 3},
+ {items = {'farming:seed_wheat'}, rarity = 1},
+ {items = {'farming:seed_wheat'}, rarity = 3},
+ }
+}
+minetest.register_node("farming:wheat_8", table.copy(crop_def))