summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2018-06-09 16:47:38 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2018-06-09 16:47:38 +0100
commit6783670154386ae4a49ba689637fbf876349c42c (patch)
treeacd0ac0f2c120febda3512db6c1a7a392031767f
parentaa6dc610cfd855dc2d7bf4b2d157f2e71c8fc688 (diff)
tidy and tweak code
-rw-r--r--crops/barley.lua (renamed from barley.lua)0
-rw-r--r--crops/beans.lua (renamed from beanpole.lua)0
-rw-r--r--crops/beetroot.lua (renamed from beetroot.lua)0
-rw-r--r--crops/blueberry.lua (renamed from blueberry.lua)0
-rw-r--r--crops/carrot.lua (renamed from carrot.lua)0
-rw-r--r--crops/chili.lua (renamed from chili.lua)0
-rw-r--r--crops/cocoa.lua (renamed from cocoa.lua)0
-rw-r--r--crops/coffee.lua (renamed from coffee.lua)0
-rw-r--r--crops/corn.lua (renamed from corn.lua)0
-rw-r--r--crops/cotton.lua (renamed from cotton.lua)0
-rw-r--r--crops/cucumber.lua (renamed from cucumber.lua)0
-rw-r--r--crops/garlic.lua (renamed from garlic.lua)0
-rw-r--r--crops/grapes.lua (renamed from grapes.lua)0
-rw-r--r--crops/hemp.lua (renamed from hemp.lua)0
-rw-r--r--crops/melon.lua (renamed from melon.lua)0
-rw-r--r--crops/onion.lua (renamed from onion.lua)0
-rw-r--r--crops/peas.lua (renamed from pea.lua)0
-rw-r--r--crops/pepper.lua (renamed from pepper.lua)0
-rw-r--r--crops/pineapple.lua (renamed from pineapple.lua)0
-rw-r--r--crops/potato.lua (renamed from potato.lua)0
-rw-r--r--crops/pumpkin.lua (renamed from pumpkin.lua)0
-rw-r--r--crops/raspberry.lua (renamed from raspberry.lua)0
-rw-r--r--crops/rhubarb.lua (renamed from rhubarb.lua)0
-rw-r--r--crops/tomato.lua (renamed from tomato.lua)0
-rw-r--r--crops/wheat.lua (renamed from wheat.lua)0
-rw-r--r--donut.lua76
-rw-r--r--farming.conf_example2
-rw-r--r--food.lua74
-rw-r--r--hoebomb.lua142
-rw-r--r--hoes.lua138
-rw-r--r--init.lua71
31 files changed, 250 insertions, 253 deletions
diff --git a/barley.lua b/crops/barley.lua
index f509335..f509335 100644
--- a/barley.lua
+++ b/crops/barley.lua
diff --git a/beanpole.lua b/crops/beans.lua
index 888a0a1..888a0a1 100644
--- a/beanpole.lua
+++ b/crops/beans.lua
diff --git a/beetroot.lua b/crops/beetroot.lua
index 1510a76..1510a76 100644
--- a/beetroot.lua
+++ b/crops/beetroot.lua
diff --git a/blueberry.lua b/crops/blueberry.lua
index 500fcde..500fcde 100644
--- a/blueberry.lua
+++ b/crops/blueberry.lua
diff --git a/carrot.lua b/crops/carrot.lua
index 0aefcfd..0aefcfd 100644
--- a/carrot.lua
+++ b/crops/carrot.lua
diff --git a/chili.lua b/crops/chili.lua
index 9889162..9889162 100644
--- a/chili.lua
+++ b/crops/chili.lua
diff --git a/cocoa.lua b/crops/cocoa.lua
index 71d038e..71d038e 100644
--- a/cocoa.lua
+++ b/crops/cocoa.lua
diff --git a/coffee.lua b/crops/coffee.lua
index ab93d06..ab93d06 100644
--- a/coffee.lua
+++ b/crops/coffee.lua
diff --git a/corn.lua b/crops/corn.lua
index 4847903..4847903 100644
--- a/corn.lua
+++ b/crops/corn.lua
diff --git a/cotton.lua b/crops/cotton.lua
index 7f893ec..7f893ec 100644
--- a/cotton.lua
+++ b/crops/cotton.lua
diff --git a/cucumber.lua b/crops/cucumber.lua
index 4e6981c..4e6981c 100644
--- a/cucumber.lua
+++ b/crops/cucumber.lua
diff --git a/garlic.lua b/crops/garlic.lua
index 52ae25f..52ae25f 100644
--- a/garlic.lua
+++ b/crops/garlic.lua
diff --git a/grapes.lua b/crops/grapes.lua
index 8b0ae2a..8b0ae2a 100644
--- a/grapes.lua
+++ b/crops/grapes.lua
diff --git a/hemp.lua b/crops/hemp.lua
index 34dd56d..34dd56d 100644
--- a/hemp.lua
+++ b/crops/hemp.lua
diff --git a/melon.lua b/crops/melon.lua
index 2165558..2165558 100644
--- a/melon.lua
+++ b/crops/melon.lua
diff --git a/onion.lua b/crops/onion.lua
index 21b5c2e..21b5c2e 100644
--- a/onion.lua
+++ b/crops/onion.lua
diff --git a/pea.lua b/crops/peas.lua
index ef14dab..ef14dab 100644
--- a/pea.lua
+++ b/crops/peas.lua
diff --git a/pepper.lua b/crops/pepper.lua
index f700e35..f700e35 100644
--- a/pepper.lua
+++ b/crops/pepper.lua
diff --git a/pineapple.lua b/crops/pineapple.lua
index 3525136..3525136 100644
--- a/pineapple.lua
+++ b/crops/pineapple.lua
diff --git a/potato.lua b/crops/potato.lua
index a1512c2..a1512c2 100644
--- a/potato.lua
+++ b/crops/potato.lua
diff --git a/pumpkin.lua b/crops/pumpkin.lua
index d8e8ec6..d8e8ec6 100644
--- a/pumpkin.lua
+++ b/crops/pumpkin.lua
diff --git a/raspberry.lua b/crops/raspberry.lua
index 931d2ae..931d2ae 100644
--- a/raspberry.lua
+++ b/crops/raspberry.lua
diff --git a/rhubarb.lua b/crops/rhubarb.lua
index 90a2d8b..90a2d8b 100644
--- a/rhubarb.lua
+++ b/crops/rhubarb.lua
diff --git a/tomato.lua b/crops/tomato.lua
index 53012a8..53012a8 100644
--- a/tomato.lua
+++ b/crops/tomato.lua
diff --git a/wheat.lua b/crops/wheat.lua
index 68296cc..68296cc 100644
--- a/wheat.lua
+++ b/crops/wheat.lua
diff --git a/donut.lua b/donut.lua
deleted file mode 100644
index 9b29d27..0000000
--- a/donut.lua
+++ /dev/null
@@ -1,76 +0,0 @@
-
-local S = farming.intllib
-
--- Donut (thanks to Bockwurst for making the donut images)
-minetest.register_craftitem("farming:donut", {
- description = S("Donut"),
- inventory_image = "farming_donut.png",
- on_use = minetest.item_eat(4),
-})
-
-minetest.register_craft({
- output = "farming:donut 3",
- recipe = {
- {"", "group:food_wheat", ""},
- {"group:food_wheat", "group:food_sugar", "group:food_wheat"},
- {"", "group:food_wheat", ""},
- }
-})
-
--- Chocolate Donut
-minetest.register_craftitem("farming:donut_chocolate", {
- description = S("Chocolate Donut"),
- inventory_image = "farming_donut_chocolate.png",
- on_use = minetest.item_eat(6),
-})
-
-minetest.register_craft({
- output = "farming:donut_chocolate",
- recipe = {
- {'group:food_cocoa'},
- {'farming:donut'},
- }
-})
-
--- Apple Donut
-minetest.register_craftitem("farming:donut_apple", {
- description = S("Apple Donut"),
- inventory_image = "farming_donut_apple.png",
- on_use = minetest.item_eat(6),
-})
-
-minetest.register_craft({
- output = "farming:donut_apple",
- recipe = {
- {'default:apple'},
- {'farming:donut'},
- }
-})
-
--- Porridge Oats
-minetest.register_craftitem("farming:porridge", {
- description = S("Porridge"),
- inventory_image = "farming_porridge.png",
- on_use = minetest.item_eat(6, "farming:bowl"),
-})
-
-minetest.after(0, function()
-
- local fluid = "bucket:bucket_water"
- local fluid_return = "bucket:bucket_water"
-
- if minetest.get_modpath("mobs") and mobs and mobs.mod == "redo" then
- fluid = "group:food_milk"
- fluid_return = "mobs:bucket_milk"
- end
-
- minetest.register_craft({
- type = "shapeless",
- output = "farming:porridge",
- recipe = {
- "group:food_barley", "group:food_barley", "group:food_wheat",
- "group:food_wheat", "group:food_bowl", fluid
- },
- replacements = {{fluid_return, "bucket:bucket_empty"}}
- })
-end)
diff --git a/farming.conf_example b/farming.conf_example
index 2505054..f652e9c 100644
--- a/farming.conf_example
+++ b/farming.conf_example
@@ -13,7 +13,6 @@ farming.cucumber = true
farming.corn = true
farming.coffee = true
farming.melon = true
-farming.sugar = true
farming.pumpkin = true
farming.cocoa = true
farming.raspberry = true
@@ -30,7 +29,6 @@ farming.pepper = true
farming.pineapple = true
farming.peas = true
farming.beetroot = true
-farming.donuts = true
-- rarety of crops on map, default is 0.001 (higher number = more crops)
farming.rarety = 0.002
diff --git a/food.lua b/food.lua
index 777e317..f099e53 100644
--- a/food.lua
+++ b/food.lua
@@ -112,3 +112,77 @@ minetest.register_craft({
output = "farming:garlic_bread",
recipe = {"group:food_toast", "group:food_garlic_clove", "group:food_garlic_clove"},
})
+
+--= Donuts (thanks to Bockwurst for making the donut images)
+
+minetest.register_craftitem("farming:donut", {
+ description = S("Donut"),
+ inventory_image = "farming_donut.png",
+ on_use = minetest.item_eat(4),
+})
+
+minetest.register_craft({
+ output = "farming:donut 3",
+ recipe = {
+ {"", "group:food_wheat", ""},
+ {"group:food_wheat", "group:food_sugar", "group:food_wheat"},
+ {"", "group:food_wheat", ""},
+ }
+})
+
+minetest.register_craftitem("farming:donut_chocolate", {
+ description = S("Chocolate Donut"),
+ inventory_image = "farming_donut_chocolate.png",
+ on_use = minetest.item_eat(6),
+})
+
+minetest.register_craft({
+ output = "farming:donut_chocolate",
+ recipe = {
+ {'group:food_cocoa'},
+ {'farming:donut'},
+ }
+})
+
+minetest.register_craftitem("farming:donut_apple", {
+ description = S("Apple Donut"),
+ inventory_image = "farming_donut_apple.png",
+ on_use = minetest.item_eat(6),
+})
+
+minetest.register_craft({
+ output = "farming:donut_apple",
+ recipe = {
+ {'default:apple'},
+ {'farming:donut'},
+ }
+})
+
+--= Porridge Oats
+
+minetest.register_craftitem("farming:porridge", {
+ description = S("Porridge"),
+ inventory_image = "farming_porridge.png",
+ on_use = minetest.item_eat(6, "farming:bowl"),
+})
+
+minetest.after(0, function()
+
+ local fluid = "bucket:bucket_water"
+ local fluid_return = "bucket:bucket_water"
+
+ if minetest.get_modpath("mobs") and mobs and mobs.mod == "redo" then
+ fluid = "group:food_milk"
+ fluid_return = "mobs:bucket_milk"
+ end
+
+ minetest.register_craft({
+ type = "shapeless",
+ output = "farming:porridge",
+ recipe = {
+ "group:food_barley", "group:food_barley", "group:food_wheat",
+ "group:food_wheat", "group:food_bowl", fluid
+ },
+ replacements = {{fluid_return, "bucket:bucket_empty"}}
+ })
+end)
diff --git a/hoebomb.lua b/hoebomb.lua
deleted file mode 100644
index be8f828..0000000
--- a/hoebomb.lua
+++ /dev/null
@@ -1,142 +0,0 @@
-
--- load support for intllib.
-local MP = minetest.get_modpath(minetest.get_current_modname())
-local S, NS = dofile(MP.."/intllib.lua")
-
-
--- hoe bomb function
-local function hoe_area(pos, player)
-
- -- check for protection
- if minetest.is_protected(pos, player:get_player_name()) then
- minetest.record_protection_violation(pos, player:get_player_name())
- return
- end
-
- local r = 5 -- radius
-
- -- remove flora (grass, flowers etc.)
- local res = minetest.find_nodes_in_area(
- {x = pos.x - r, y = pos.y - 1, z = pos.z - r},
- {x = pos.x + r, y = pos.y + 2, z = pos.z + r},
- {"group:flora"})
-
- for n = 1, #res do
- minetest.swap_node(res[n], {name = "air"})
- end
-
- -- replace dirt with tilled soil
- res = nil
- res = minetest.find_nodes_in_area_under_air(
- {x = pos.x - r, y = pos.y - 1, z = pos.z - r},
- {x = pos.x + r, y = pos.y + 2, z = pos.z + r},
- {"group:soil"})
-
- for n = 1, #res do
- minetest.swap_node(res[n], {name = "farming:soil"})
- end
-end
-
-
--- throwable hoe bomb
-minetest.register_entity("farming:hoebomb_entity", {
- physical = true,
- visual = "sprite",
- visual_size = {x = 1.0, y = 1.0},
- textures = {"farming_hoe_bomb.png"},
- collisionbox = {0,0,0,0,0,0},
- lastpos = {},
- player = "",
-
- on_step = function(self, dtime)
-
- if not self.player then
-
- self.object:remove()
-
- return
- end
-
- local pos = self.object:get_pos()
-
- if self.lastpos.x ~= nil then
-
- local vel = self.object:getvelocity()
-
- -- only when potion hits something physical
- if vel.x == 0
- or vel.y == 0
- or vel.z == 0 then
-
- if self.player ~= "" then
-
- -- round up coords to fix glitching through doors
- self.lastpos = vector.round(self.lastpos)
-
- hoe_area(self.lastpos, self.player)
- end
-
- self.object:remove()
-
- return
-
- end
- end
-
- self.lastpos = pos
- end
-})
-
-
--- actual throwing function
-local function throw_potion(itemstack, player)
-
- local playerpos = player:get_pos()
-
- local obj = minetest.add_entity({
- x = playerpos.x,
- y = playerpos.y + 1.5,
- z = playerpos.z
- }, "farming:hoebomb_entity")
-
- local dir = player:get_look_dir()
- local velocity = 20
-
- obj:setvelocity({
- x = dir.x * velocity,
- y = dir.y * velocity,
- z = dir.z * velocity
- })
-
- obj:setacceleration({
- x = dir.x * -3,
- y = -9.5,
- z = dir.z * -3
- })
-
- obj:setyaw(player:get_look_yaw() + math.pi)
- obj:get_luaentity().player = player
-end
-
-
--- hoe bomb item
-minetest.register_craftitem("farming:hoe_bomb", {
- description = S("Hoe Bomb (use or throw on grassy areas to hoe land"),
- inventory_image = "farming_hoe_bomb.png",
- groups = {flammable = 2, not_in_creative_inventory = 1},
- on_use = function(itemstack, user, pointed_thing)
-
- if pointed_thing.type == "node" then
- hoe_area(pointed_thing.above, user)
- else
- throw_potion(itemstack, user)
-
- if not farming.is_creative(user:get_player_name()) then
-
- itemstack:take_item()
-
- return itemstack
- end
- end
- end,
-})
diff --git a/hoes.lua b/hoes.lua
index eaacb29..633e6f0 100644
--- a/hoes.lua
+++ b/hoes.lua
@@ -192,3 +192,141 @@ minetest.override_item("farming:hoe_diamond", {
original_description = "Diamond Hoe",
description = toolranks.create_description("Diamond Hoe")})
end
+
+
+-- hoe bomb function
+local function hoe_area(pos, player)
+
+ -- check for protection
+ if minetest.is_protected(pos, player:get_player_name()) then
+ minetest.record_protection_violation(pos, player:get_player_name())
+ return
+ end
+
+ local r = 5 -- radius
+
+ -- remove flora (grass, flowers etc.)
+ local res = minetest.find_nodes_in_area(
+ {x = pos.x - r, y = pos.y - 1, z = pos.z - r},
+ {x = pos.x + r, y = pos.y + 2, z = pos.z + r},
+ {"group:flora"})
+
+ for n = 1, #res do
+ minetest.swap_node(res[n], {name = "air"})
+ end
+
+ -- replace dirt with tilled soil
+ res = nil
+ res = minetest.find_nodes_in_area_under_air(
+ {x = pos.x - r, y = pos.y - 1, z = pos.z - r},
+ {x = pos.x + r, y = pos.y + 2, z = pos.z + r},
+ {"group:soil"})
+
+ for n = 1, #res do
+ minetest.swap_node(res[n], {name = "farming:soil"})
+ end
+end
+
+
+-- throwable hoe bomb
+minetest.register_entity("farming:hoebomb_entity", {
+ physical = true,
+ visual = "sprite",
+ visual_size = {x = 1.0, y = 1.0},
+ textures = {"farming_hoe_bomb.png"},
+ collisionbox = {0,0,0,0,0,0},
+ lastpos = {},
+ player = "",
+
+ on_step = function(self, dtime)
+
+ if not self.player then
+
+ self.object:remove()
+
+ return
+ end
+
+ local pos = self.object:get_pos()
+
+ if self.lastpos.x ~= nil then
+
+ local vel = self.object:getvelocity()
+
+ -- only when potion hits something physical
+ if vel.x == 0
+ or vel.y == 0
+ or vel.z == 0 then
+
+ if self.player ~= "" then
+
+ -- round up coords to fix glitching through doors
+ self.lastpos = vector.round(self.lastpos)
+
+ hoe_area(self.lastpos, self.player)
+ end
+
+ self.object:remove()
+
+ return
+
+ end
+ end
+
+ self.lastpos = pos
+ end
+})
+
+
+-- actual throwing function
+local function throw_potion(itemstack, player)
+
+ local playerpos = player:get_pos()
+
+ local obj = minetest.add_entity({
+ x = playerpos.x,
+ y = playerpos.y + 1.5,
+ z = playerpos.z
+ }, "farming:hoebomb_entity")
+
+ local dir = player:get_look_dir()
+ local velocity = 20
+
+ obj:setvelocity({
+ x = dir.x * velocity,
+ y = dir.y * velocity,
+ z = dir.z * velocity
+ })
+
+ obj:setacceleration({
+ x = dir.x * -3,
+ y = -9.5,
+ z = dir.z * -3
+ })
+
+ obj:setyaw(player:get_look_yaw() + math.pi)
+ obj:get_luaentity().player = player
+end
+
+
+-- hoe bomb item
+minetest.register_craftitem("farming:hoe_bomb", {
+ description = S("Hoe Bomb (use or throw on grassy areas to hoe land"),
+ inventory_image = "farming_hoe_bomb.png",
+ groups = {flammable = 2, not_in_creative_inventory = 1},
+ on_use = function(itemstack, user, pointed_thing)
+
+ if pointed_thing.type == "node" then
+ hoe_area(pointed_thing.above, user)
+ else
+ throw_potion(itemstack, user)
+
+ if not farming.is_creative(user:get_player_name()) then
+
+ itemstack:take_item()
+
+ return itemstack
+ end
+ end
+ end,
+})
diff --git a/init.lua b/init.lua
index 3364b0f..8baf53e 100644
--- a/init.lua
+++ b/init.lua
@@ -7,7 +7,7 @@
farming = {}
farming.mod = "redo"
-farming.version = "20180519"
+farming.version = "20180609"
farming.path = minetest.get_modpath("farming")
farming.select = {
type = "fixed",
@@ -586,7 +586,6 @@ farming.cucumber = true
farming.corn = true
farming.coffee = true
farming.melon = true
-farming.sugar = true
farming.pumpkin = true
farming.cocoa = true
farming.raspberry = true
@@ -603,7 +602,6 @@ farming.pepper = true
farming.pineapple = true
farming.peas = true
farming.beetroot = true
-farming.donuts = true
farming.rarety = 0.002 -- 0.006
@@ -632,37 +630,44 @@ dofile(farming.path.."/grass.lua")
dofile(farming.path.."/utensils.lua")
-- default crops
-dofile(farming.path.."/wheat.lua")
-dofile(farming.path.."/cotton.lua")
-
--- additional crops and food (if enabled)
-if farming.carrot then dofile(farming.path.."/carrot.lua") end
-if farming.potato then dofile(farming.path.."/potato.lua") end
-if farming.tomato then dofile(farming.path.."/tomato.lua") end
-if farming.cucumber then dofile(farming.path.."/cucumber.lua") end
-if farming.corn then dofile(farming.path.."/corn.lua") end
-if farming.coffee then dofile(farming.path.."/coffee.lua") end
-if farming.melon then dofile(farming.path.."/melon.lua") end
-if farming.sugar then dofile(farming.path.."/food.lua") end
-if farming.pumpkin then dofile(farming.path.."/pumpkin.lua") end
-if farming.cocoa then dofile(farming.path.."/cocoa.lua") end
-if farming.raspberry then dofile(farming.path.."/raspberry.lua") end
-if farming.blueberry then dofile(farming.path.."/blueberry.lua") end
-if farming.rhubarb then dofile(farming.path.."/rhubarb.lua") end
-if farming.beans then dofile(farming.path.."/beanpole.lua") end
-if farming.grapes then dofile(farming.path.."/grapes.lua") end
-if farming.barley then dofile(farming.path.."/barley.lua") end
-if farming.hemp then dofile(farming.path.."/hemp.lua") end
-if farming.garlic then dofile(farming.path.."/garlic.lua") end
-if farming.onion then dofile(farming.path.."/onion.lua") end
-if farming.pepper then dofile(farming.path.."/pepper.lua") end
-if farming.pineapple then dofile(farming.path.."/pineapple.lua") end
-if farming.peas then dofile(farming.path.."/pea.lua") end
-if farming.beetroot then dofile(farming.path.."/beetroot.lua") end
-if farming.chili then dofile(farming.path.."/chili.lua") end
-if farming.donuts then dofile(farming.path.."/donut.lua") end
+dofile(farming.path.."/crops/wheat.lua")
+dofile(farming.path.."/crops/cotton.lua")
+
+-- helper function
+local function ddoo(file, check)
+
+ if check then
+ dofile(farming.path .. "/crops/" .. file)
+ end
+end
+
+-- add additional crops and food (if enabled)
+ddoo("carrot.lua", farming.carrot)
+ddoo("potato.lua", farming.potato)
+ddoo("tomato.lua", farming.tomato)
+ddoo("cucumber.lua", farming.cucumber)
+ddoo("corn.lua", farming.corn)
+ddoo("coffee.lua", farming.coffee)
+ddoo("melon.lua", farming.melon)
+ddoo("pumpkin.lua", farming.pumpkin)
+ddoo("cocoa.lua", farming.cocoa)
+ddoo("raspberry.lua", farming.raspberry)
+ddoo("blueberry.lua", farming.blueberry)
+ddoo("rhubarb.lua", farming.rhubarb)
+ddoo("beans.lua", farming.beans)
+ddoo("grapes.lua", farming.grapes)
+ddoo("barley.lua", farming.barley)
+ddoo("hemp.lua", farming.hemp)
+ddoo("garlic.lua", farming.garlic)
+ddoo("onion.lua", farming.onion)
+ddoo("pepper.lua", farming.pepper)
+ddoo("pineapple.lua", farming.pineapple)
+ddoo("peas.lua", farming.peas)
+ddoo("beetroot.lua", farming.beetroot)
+ddoo("chili.lua", farming.chili)
+
+dofile(farming.path.."/food.lua")
dofile(farming.path.."/mapgen.lua")
dofile(farming.path.."/compatibility.lua") -- Farming Plus compatibility
-dofile(farming.path.."/hoebomb.lua")
dofile(farming.path.."/lucky_block.lua")