summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--corn.lua27
-rw-r--r--crops_settings.txt26
-rw-r--r--init.lua43
-rw-r--r--melon.lua17
-rw-r--r--polebean.lua9
-rw-r--r--potato.lua15
-rw-r--r--tomato.lua15
7 files changed, 93 insertions, 59 deletions
diff --git a/corn.lua b/corn.lua
index 6f21055..84f315f 100644
--- a/corn.lua
+++ b/corn.lua
@@ -10,9 +10,6 @@ of the license, or (at your option) any later version.
--]]
-local interval = crops_interval
-local chance = crops_chance
-
minetest.register_node("crops:corn", {
description = "corn",
inventory_image = "crops_corn.png",
@@ -87,10 +84,10 @@ minetest.register_node("crops:corn_base_seed", {
minetest.register_abm({
nodenames = { "crops:corn_base_seed" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
minetest.set_node(pos, { name = "crops:corn_base_1" })
@@ -115,10 +112,10 @@ minetest.register_node("crops:corn_base_1", {
minetest.register_abm({
nodenames = { "crops:corn_base_1" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
if not minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air" then
@@ -211,10 +208,10 @@ minetest.register_node("crops:corn_top_1", {
minetest.register_abm({
nodenames = { "crops:corn_top_1" },
neighbors = { "crops:corn_base_2" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
minetest.set_node(pos, { name = "crops:corn_top_2" })
@@ -247,10 +244,10 @@ minetest.register_node("crops:corn_top_2", {
minetest.register_abm({
nodenames = { "crops:corn_top_2" },
neighbors = { "crops:corn_base_2" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
minetest.set_node(pos, { name = "crops:corn_top_3" })
diff --git a/crops_settings.txt b/crops_settings.txt
new file mode 100644
index 0000000..46d8514
--- /dev/null
+++ b/crops_settings.txt
@@ -0,0 +1,26 @@
+
+--
+-- crops_settings.txt
+--
+-- These are the default difficulty settings for the crops mod. You can uncomment
+-- the "easy" or "difficult" settings if you wish, or come up with your own values.
+--
+
+--[[
+-- easy --
+crops.chance = 4
+crops.interval = 30
+crops.light = 8
+--]]
+
+-- normal --
+crops.chance = 8
+crops.interval = 30
+crops.light = 10
+
+--[[
+-- difficult --
+crops.chance = 16
+crops.interval = 30
+crops.light = 13
+--]]
diff --git a/init.lua b/init.lua
index 204ee06..1e27f51 100644
--- a/init.lua
+++ b/init.lua
@@ -10,15 +10,38 @@ of the license, or (at your option) any later version.
--]]
-crops_interval = 30
-crops_chance = 8
-
-dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/melon.lua")
-dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/corn.lua")
-dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/tomato.lua")
-dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/potato.lua")
-dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/polebean.lua")
-
-dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/cooking.lua")
+crops = {}
+
+local worldpath = minetest.get_worldpath()
+local modpath = minetest.get_modpath(minetest.get_current_modname())
+
+dofile(modpath .. "/crops_settings.txt")
+
+if io.open(worldpath .. "/crops_settings.txt", "r") == nil then
+ io.input(modpath .. "/crops_settings.txt")
+ io.output(worldpath .. "/crops_settings.txt")
+
+ local size = 4096
+ while true do
+ local buf = io.read(size)
+ if not buf then
+ io.close()
+ break
+ end
+ io.write(buf)
+ end
+else
+ dofile(worldpath .. "/crops_settings.txt")
+end
+
+-- crop nodes, crafts, craftitems
+dofile(modpath .. "/melon.lua")
+dofile(modpath .. "/corn.lua")
+dofile(modpath .. "/tomato.lua")
+dofile(modpath .. "/potato.lua")
+dofile(modpath .. "/polebean.lua")
+
+-- cooking recipes that mix craftitems
+dofile(modpath .. "/cooking.lua")
minetest.log("action", "[crops] loaded.")
diff --git a/melon.lua b/melon.lua
index b5cdecc..1473b7c 100644
--- a/melon.lua
+++ b/melon.lua
@@ -17,9 +17,6 @@ local faces = {
[4] = { x = 0, z = 1, r = 0, o = 2, m = 11 }
}
-local interval = crops_interval
-local chance = crops_chance
-
minetest.register_node("crops:melon_seed", {
description = "melon seed",
inventory_image = "crops_melon_seed.png",
@@ -141,10 +138,10 @@ minetest.register_node("crops:melon", {
minetest.register_abm({
nodenames = { "crops:melon_plant_1", "crops:melon_plant_2", "crops:melon_plant_3","crops:melon_plant_4" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
local n = string.gsub(node.name, "4", "5")
@@ -161,10 +158,10 @@ minetest.register_abm({
minetest.register_abm({
nodenames = { "crops:melon_plant_5" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
for face = 1, 4 do
@@ -199,7 +196,7 @@ minetest.register_abm({
--
minetest.register_abm({
nodenames = { "crops:melon_plant_5_attached" },
- interval = interval,
+ interval = crops.interval,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
for face = 1, 4 do
diff --git a/polebean.lua b/polebean.lua
index 7bea392..8a2f02a 100644
--- a/polebean.lua
+++ b/polebean.lua
@@ -10,9 +10,6 @@ of the license, or (at your option) any later version.
--]]
-local interval = crops_interval
-local chance = crops_chance
-
minetest.register_craft({
output = "crops:beanpoles",
recipe = {
@@ -238,11 +235,11 @@ end
minetest.register_abm({
nodenames = { "crops:beanpole_plant_base_1", "crops:beanpole_plant_base_2", "crops:beanpole_plant_base_3", "crops:beanpole_plant_base_4" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
neighbors = { "group:soil" },
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
if node.name == "crops:beanpole_plant_base_1" then
diff --git a/potato.lua b/potato.lua
index a202a35..a253811 100644
--- a/potato.lua
+++ b/potato.lua
@@ -10,9 +10,6 @@ of the license, or (at your option) any later version.
--]]
-local interval = crops_interval
-local chance = crops_chance
-
minetest.register_node("crops:potato_eyes", {
description = "potato eyes",
inventory_image = "crops_potato_eyes.png",
@@ -110,14 +107,14 @@ minetest.register_node("crops:soil_with_potatoes", {
minetest.register_abm({
nodenames = { "crops:potato_plant_1", "crops:potato_plant_2", "crops:potato_plant_3" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
local below = { x = pos.x, y = pos.y - 1, z = pos.z }
if not minetest.registered_nodes[minetest.get_node(below).name].groups.soil then
return
end
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
local n = string.gsub(node.name, "3", "4")
@@ -133,10 +130,10 @@ minetest.register_abm({
minetest.register_abm({
nodenames = { "crops:potato_plant_4" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
local below = { x = pos.x, y = pos.y - 1, z = pos.z }
diff --git a/tomato.lua b/tomato.lua
index 0bf60a4..0bb03d8 100644
--- a/tomato.lua
+++ b/tomato.lua
@@ -10,9 +10,6 @@ of the license, or (at your option) any later version.
--]]
-local interval = crops_interval
-local chance = crops_chance
-
minetest.register_node("crops:tomato_seed", {
description = "tomato seed",
inventory_image = "crops_tomato_seed.png",
@@ -124,10 +121,10 @@ minetest.register_craft({
minetest.register_abm({
nodenames = { "crops:tomato_plant_1", "crops:tomato_plant_2", "crops:tomato_plant_3" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
local n = string.gsub(node.name, "4", "5")
@@ -144,10 +141,10 @@ minetest.register_abm({
minetest.register_abm({
nodenames = { "crops:tomato_plant_4" },
neighbors = { "group:soil" },
- interval = interval,
- chance = chance,
+ interval = crops.interval,
+ chance = crops.chance,
action = function(pos, node, active_object_count, active_object_count_wider)
- if minetest.get_node_light(pos, nil) < 13 then
+ if minetest.get_node_light(pos, nil) < crops.light then
return
end
local meta = minetest.get_meta(pos)