commit a84a2cdc588dcafd091a512240a1ec2c50aa481a Author: PilzAdam Date: Mon Sep 17 17:45:45 2012 +0200 The old light version is now the main version diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..3f98b6a --- /dev/null +++ b/README.txt @@ -0,0 +1,48 @@ +===FARMING MOD for MINETEST-C55=== +by PilzAdam + +Light version + +Introduction: +This mod adds farming to Minetest. + +How to install: +Unzip the archive an place it in minetest-base-directory/mods/minetest/ +if you have a windows client or a linux run-in-place client. If you have +a linux system-wide instalation place it in ~/.minetest/mods/minetest/. +If you want to install this mod only in one world create the folder +worldmods/ in your worlddirectory. +For further information or help see: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Craft a wood/stone/steel hoe: +material material + stick + stick +Dig dirt with it and turn it to soil. Water the soil and plant the seeds +you get by digging dirt with the hoe. Wait until the seeds are seasoned +and harvest them. When harvesting you will get the product and new seeds. +For further information or help see: +http://minetest.net/forum/viewtopic.php?id=2787 + +License: +Sourcecode: WTFPL (see below) +Graphics: WTFPL (see below) + +See also: +http://minetest.net/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/cactus.lua b/cactus.lua new file mode 100644 index 0000000..3723e70 --- /dev/null +++ b/cactus.lua @@ -0,0 +1,22 @@ +minetest.register_abm({ + nodenames = {"default:cactus"}, + interval = 50, + chance = 20, + action = function(pos, node) + pos.y = pos.y-1 + local name = minetest.env:get_node(pos).name + if name == "default:desert_sand" or name == "default:sand" then + pos.y = pos.y+1 + local height = 0 + while minetest.env:get_node(pos).name == "default:cactus" do + height = height+1 + pos.y = pos.y+1 + end + if height < 4 then + if minetest.env:get_node(pos).name == "air" then + minetest.env:set_node(pos, node) + end + end + end + end +}) diff --git a/changelog.txt b/changelog.txt new file mode 100644 index 0000000..80138c5 --- /dev/null +++ b/changelog.txt @@ -0,0 +1,17 @@ +Version 3: +- make pumpkins with face not craftable but created by punching with a sword +- change groups of pumpkins to more wood like +- add big pumpkin +- add scarecrow +- make bread non stackable +- make saplings plantable everywhere (they still grow only with light and wet soil) +- add weed +- add fuel attributes to nearly everything +- add pumpkin bread +Version 2: +- soil dont turn to dirt when walking over it +- fix hoe bug +- rename corn to wheat +- new textures for harvested wheat +- make cotton drop strings when harvested +- add rubber diff --git a/cotton.lua b/cotton.lua new file mode 100644 index 0000000..3ea3390 --- /dev/null +++ b/cotton.lua @@ -0,0 +1,90 @@ +minetest.register_craftitem("farming:cotton_seed", { + description = "Cotton Seeds", + inventory_image = "farming_cotton_seed.png", + on_place = function(itemstack, placer, pointed_thing) + local above = minetest.env:get_node(pointed_thing.above) + if above.name == "air" then + above.name = "farming:cotton_1" + minetest.env:set_node(pointed_thing.above, above) + itemstack:take_item(1) + return itemstack + end + end +}) + +minetest.register_node("farming:cotton_1", { + paramtype = "light", + walkable = false, + drawtype = "plantlike", + drop = "", + tiles = {"farming_cotton_1.png"}, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.5+6/16, 0.5} + }, + }, + groups = {snappy=3, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("farming:cotton_2", { + paramtype = "light", + walkable = false, + drawtype = "plantlike", + drop = "", + tiles = {"farming_cotton_2.png"}, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.5+12/16, 0.5} + }, + }, + groups = {snappy=3, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("farming:cotton", { + paramtype = "light", + walkable = false, + drawtype = "plantlike", + tiles = {"farming_cotton.png"}, + drop = { + max_items = 6, + items = { + { items = {'farming:cotton_seed'} }, + { items = {'farming:cotton_seed'}, rarity = 2}, + { items = {'farming:cotton_seed'}, rarity = 5}, + { items = {'farming:string'} }, + { items = {'farming:string'}, rarity = 2 }, + { items = {'farming:string'}, rarity = 5 } + } + }, + groups = {snappy=3, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +farming:add_plant("farming:cotton", {"farming:cotton_1", "farming:cotton_2"}, 50, 20) + +minetest.register_craftitem("farming:string", { + description = "String", + inventory_image = "farming_string.png", +}) + +minetest.register_craft({ + output = "wool:white", + recipe = {{"farming:string"}} +}) + +-- ========= FUEL ========= +minetest.register_craft({ + type = "fuel", + recipe = "farming:cotton_seed", + burntime = 1 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:string", + burntime = 1 +}) diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..0b8ebe0 --- /dev/null +++ b/depends.txt @@ -0,0 +1,3 @@ +default +bucket +wool diff --git a/hoes.lua b/hoes.lua new file mode 100644 index 0000000..33cf462 --- /dev/null +++ b/hoes.lua @@ -0,0 +1,83 @@ +local function create_soil(pos, inv, p) + if pos == nil then + return false + end + local node = minetest.env:get_node(pos) + local name = node.name + local above = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}) + if name == "default:dirt" or name == "default:dirt_with_grass" then + if above.name == "air" then + node.name = "farming:soil" + minetest.env:set_node(pos, node) + if inv and p and name == "default:dirt_with_grass" then + for name,rarity in pairs(farming.seeds) do + if math.random(1, rarity-p) == 1 then + inv:add_item("main", ItemStack(name)) + end + end + end + return true + end + end + return false +end + +minetest.register_tool("farming:hoe_wood", { + description = "Wood Hoe", + inventory_image = "farming_hoe_wood.png", + on_use = function(itemstack, user, pointed_thing) + if create_soil(pointed_thing.under, user:get_inventory(), 0) then + itemstack:add_wear(65535/30) + return itemstack + end + end +}) + +minetest.register_craft({ + output = "farming:hoe_wood", + recipe = { + {"default:wood", "default:wood"}, + {"", "default:stick"}, + {"", "default:stick"} + } +}) + +minetest.register_tool("farming:hoe_stone", { + description = "Stone Hoe", + inventory_image = "farming_hoe_stone.png", + on_use = function(itemstack, user, pointed_thing) + if create_soil(pointed_thing.under, user:get_inventory(), 5) then + itemstack:add_wear(65535/50) + return itemstack + end + end +}) + +minetest.register_craft({ + output = "farming:hoe_stone", + recipe = { + {"default:cobble", "default:cobble"}, + {"", "default:stick"}, + {"", "default:stick"} + } +}) + +minetest.register_tool("farming:hoe_steel", { + description = "Steel Hoe", + inventory_image = "farming_hoe_steel.png", + on_use = function(itemstack, user, pointed_thing) + if create_soil(pointed_thing.under, user:get_inventory(), 10) then + itemstack:add_wear(65535/80) + return itemstack + end + end +}) + +minetest.register_craft({ + output = "farming:hoe_steel", + recipe = { + {"default:steel_ingot", "default:steel_ingot"}, + {"", "default:stick"}, + {"", "default:stick"} + } +}) diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..4b864c6 --- /dev/null +++ b/init.lua @@ -0,0 +1,205 @@ +farming = {} + +function farming:add_plant(full_grown, names, interval, chance) + minetest.register_abm({ + nodenames = names, + interval = interval, + chance = chance, + action = function(pos, node) + pos.y = pos.y-1 + if minetest.env:get_node(pos).name ~= "farming:soil_wet" then + return + end + pos.y = pos.y+1 + if minetest.env:get_node_light(pos) < 8 then + return + end + local step = nil + for i,name in ipairs(names) do + if name == node.name then + step = i + break + end + end + if step == nil then + return + end + local new_node = {name=names[step+1]} + if new_node.name == nil then + new_node.name = full_grown + end + minetest.env:set_node(pos, new_node) + end +} ) +end + +function farming:generate_tree(pos, trunk, leaves, underground, replacements) + pos.y = pos.y-1 + local nodename = minetest.env:get_node(pos).name + local ret = true + for _,name in ipairs(underground) do + if nodename == name then + ret = false + break + end + end + pos.y = pos.y+1 + if ret or minetest.env:get_node_light(pos) < 8 then + return + end + + node = {name = ""} + for dy=1,4 do + pos.y = pos.y+dy + if minetest.env:get_node(pos).name ~= "air" then + return + end + pos.y = pos.y-dy + end + node.name = trunk + for dy=0,4 do + pos.y = pos.y+dy + minetest.env:set_node(pos, node) + pos.y = pos.y-dy + end + + if not replacements then + replacements = {} + end + + node.name = leaves + pos.y = pos.y+3 + for dx=-2,2 do + for dz=-2,2 do + for dy=0,3 do + pos.x = pos.x+dx + pos.y = pos.y+dy + pos.z = pos.z+dz + + if dx == 0 and dz == 0 and dy==3 then + if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then + minetest.env:set_node(pos, node) + for name,rarity in pairs(replacements) do + if math.random(1, rarity) == 1 then + minetest.env:set_node(pos, {name=name}) + end + end + end + elseif dx == 0 and dz == 0 and dy==4 then + if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then + minetest.env:set_node(pos, node) + for name,rarity in pairs(replacements) do + if math.random(1, rarity) == 1 then + minetest.env:set_node(pos, {name=name}) + end + end + end + elseif math.abs(dx) ~= 2 and math.abs(dz) ~= 2 then + if minetest.env:get_node(pos).name == "air" then + minetest.env:set_node(pos, node) + for name,rarity in pairs(replacements) do + if math.random(1, rarity) == 1 then + minetest.env:set_node(pos, {name=name}) + end + end + end + else + if math.abs(dx) ~= 2 or math.abs(dz) ~= 2 then + if minetest.env:get_node(pos).name == "air" and math.random(1, 5) <= 4 then + minetest.env:set_node(pos, node) + for name,rarity in pairs(replacements) do + if math.random(1, rarity) == 1 then + minetest.env:set_node(pos, {name=name}) + end + end + end + end + end + + pos.x = pos.x-dx + pos.y = pos.y-dy + pos.z = pos.z-dz + end + end + end +end + +farming.seeds = { + ["farming:wheat_seed"]=20, + ["farming:cotton_seed"]=30, + ["farming:pumpkin_seed"]=60, + ["farming:strawberry_seed"]=30, + ["farming:rhubarb_seed"]=30, + ["farming:potatoe_seed"]=30, + ["farming:tomato_seed"]=30, + ["farming:orange_seed"]=30, + ["farming:carrot_seed"]=30, +} + +-- ========= ALIASES FOR FARMING MOD BY SAPIER ========= +-- hoes +minetest.register_alias("farming:wood_hoe", "farming:hoe_wood") +minetest.register_alias("farming:cobble_hoe", "farming:hoe_stone") +minetest.register_alias("farming:steel_hoe", "farming:hoe_steel") +minetest.register_alias("farming:mese_hoe", "farming:hoe_steel") + +-- wheat -> wheat +minetest.register_alias("farming:wheat_node", "farming:wheat") +--minetest.register_alias("farming:wheat", "farming_wheat_harvested") cant do this +minetest.register_alias("farming:wheat_straw", "farming:wheat") +minetest.register_alias("farming:seed_wheat", "farming:wheat_seed") +for lvl = 1, 6, 1 do + minetest.register_entity(":farming:wheat_lvl"..lvl, { + on_activate = function(self, staticdata) + minetest.env:set_node(self.object:getpos(), {name="farming:wheat_1"}) + end + }) +end + +-- rye -> wheat +minetest.register_alias("farming:rhy_node", "farming:wheat") +minetest.register_alias("farming:rhy", "farming:wheat_harvested") +minetest.register_alias("farming:rhy_straw", "farming:wheat") +minetest.register_alias("farming:seed_rhy", "farming:wheat_seed") +for lvl = 1, 6, 1 do + minetest.register_entity(":farming:rhy_lvl"..lvl, { + on_activate = function(self, staticdata) + minetest.env:set_node(self.object:getpos(), {name="farming:wheat_1"}) + end + }) +end + +-- corn -> wheat +minetest.register_alias("farming:corn_node", "farming:wheat") +minetest.register_alias("farming:corn", "farming:wheat_harvested") +minetest.register_alias("farming:corn_straw", "farming:wheat") +minetest.register_alias("farming:seed_corn", "farming:wheat_seed") +for lvl = 1, 6, 1 do + minetest.register_entity(":farming:corn_lvl"..lvl, { + on_activate = function(self, staticdata) + minetest.env:set_node(self.object:getpos(), {name="farming:wheat_1"}) + end + }) +end + + +-- ========= SOIL ========= +dofile(minetest.get_modpath("farming").."/soil.lua") + +-- ========= HOES ========= +dofile(minetest.get_modpath("farming").."/hoes.lua") + +-- ========= CORN ========= +dofile(minetest.get_modpath("farming").."/wheat.lua") + +-- ========= COTTON ========= +dofile(minetest.get_modpath("farming").."/cotton.lua") + +-- ========= WEED ========= +dofile(minetest.get_modpath("farming").."/weed.lua") + +-- ========= PAPYRUS ========= +dofile(minetest.get_modpath("farming").."/papyrus.lua") + +-- ========= CACTUS ========= +dofile(minetest.get_modpath("farming").."/cactus.lua") diff --git a/papyrus.lua b/papyrus.lua new file mode 100644 index 0000000..d33e072 --- /dev/null +++ b/papyrus.lua @@ -0,0 +1,25 @@ +minetest.register_abm({ + nodenames = {"default:papyrus"}, + interval = 50, + chance = 20, + action = function(pos, node) + pos.y = pos.y-1 + local name = minetest.env:get_node(pos).name + if name == "default:dirt" or name == "default:dirt_with_grass" then + if minetest.env:find_node_near(pos, 3, {"default:water_source", "default:water_flowing"}) == nil then + return + end + pos.y = pos.y+1 + local height = 0 + while minetest.env:get_node(pos).name == "default:papyrus" do + height = height+1 + pos.y = pos.y+1 + end + if height < 4 then + if minetest.env:get_node(pos).name == "air" then + minetest.env:set_node(pos, node) + end + end + end + end +}) diff --git a/pumpkin.lua b/pumpkin.lua new file mode 100644 index 0000000..73991ca --- /dev/null +++ b/pumpkin.lua @@ -0,0 +1,446 @@ +minetest.register_craftitem("farming:pumpkin_seed", { + description = "Pumpkin Seed", + inventory_image = "farming_pumpkin_seed.png", + on_place = function(itemstack, placer, pointed_thing) + local above = minetest.env:get_node(pointed_thing.above) + if above.name == "air" then + above.name = "farming:pumpkin_1" + minetest.env:set_node(pointed_thing.above, above) + itemstack:take_item(1) + return itemstack + end + end +}) + +minetest.register_node("farming:pumpkin_1", { + paramtype = "light", + drawtype = "nodebox", + drop = "", + tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"}, + node_box = { + type = "fixed", + fixed = { + {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2} + }, + }, + selection_box = { + type = "fixed", + fixed = { + {-0.2, -0.5, -0.2, 0.2, -0.1, 0.2} + }, + }, + groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("farming:pumpkin_2", { + paramtype = "light", + drawtype = "nodebox", + drop = "", + tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"}, + node_box = { + type = "fixed", + fixed = { + {-0.35, -0.5, -0.35, 0.35, 0.2, 0.35} + }, + }, + selection_box = { + type = "fixed", + fixed = { + {-0.35, -0.5, -0.35, 0.35, 0.2, 0.35} + }, + }, + groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("farming:pumpkin", { + description = "Pumpkin", + paramtype2 = "facedir", + tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"}, + groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2}, + sounds = default.node_sound_wood_defaults(), + + on_punch = function(pos, node, puncher) + local tool = puncher:get_wielded_item():get_name() + if tool and tool == "default:sword_wood" or tool == "default:sword_stone" or tool == "default:sword_steel" then + node.name = "farming:pumpkin_face" + minetest.env:set_node(pos, node) + puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed")) + if math.random(1, 5) == 1 then + puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed")) + end + end + end +}) + +farming:add_plant("farming:pumpkin", {"farming:pumpkin_1", "farming:pumpkin_2"}, 80, 20) + +minetest.register_node("farming:pumpkin_face", { + description = "Pumpkin", + paramtype2 = "facedir", + tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"}, + groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_node("farming:pumpkin_face_light", { + description = "Pumpkin", + paramtype2 = "facedir", + light_source = LIGHT_MAX-2, + tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_light.png"}, + groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2}, + sounds = default.node_sound_wood_defaults(), +}) + +minetest.register_craft({ + type = "shapeless", + output = "farming:pumpkin_face_light", + recipe = {"farming:pumpkin_face", "default:torch"} +}) + +-- ========= BIG PUMPKIN ========= +minetest.register_node("farming:big_pumpkin", { + description = "Big Pumpkin", + paramtype2 = "facedir", + tiles = {"farming_pumpkin_big_side.png"}, + selection_box = { + type = "fixed", + fixed = { + {-1, -0.5, -1, 1, 1.5, 1} + } + }, + groups = {choppy=1, oddly_breakable_by_hand=1, flammable=2}, + sounds = default.node_sound_wood_defaults(), + + after_place_node = function(pos, placer) + for dx=-1,1 do + for dy=0,1 do + for dz=-1,1 do + pos.x = pos.x+dx + pos.y = pos.y+dy + pos.z = pos.z+dz + if dx ~= 0 or dy ~= 0 or dz ~= 0 then + if minetest.env:get_node(pos).name ~= "air" then + pos.x = pos.x-dx + pos.y = pos.y-dy + pos.z = pos.z-dz + minetest.env:remove_node(pos) + minetest.after(0.1, function(placer) + local inv = placer:get_inventory() + local index = placer:get_wield_index() + inv:set_stack("main", index, ItemStack("farming:big_pumpkin")) + end, placer) + return + end + end + pos.x = pos.x-dx + pos.y = pos.y-dy + pos.z = pos.z-dz + end + end + end + for dy=0,1 do + pos.y = pos.y+dy + pos.z = pos.z+1 + minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=2}) + pos.x = pos.x-1 + minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=2}) + pos.x = pos.x+1 + pos.z = pos.z-2 + minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=4}) + pos.x = pos.x+1 + minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=4}) + pos.z = pos.z+1 + minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=3}) + pos.z = pos.z+1 + minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=3}) + pos.z = pos.z-1 + pos.x = pos.x-2 + minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=1}) + pos.z = pos.z-1 + minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=1}) + pos.z = pos.z+1 + pos.x = pos.x+1 + pos.y = pos.y-dy + end + pos.y = pos.y+1 + minetest.env:set_node(pos, {name="farming:big_pumpkin_top"}) + end, + + after_destruct = function(pos, oldnode) + for dx=-1,1 do + for dy=0,1 do + for dz=-1,1 do + pos.x = pos.x+dx + pos.y = pos.y+dy + pos.z = pos.z+dz + local name = minetest.env:get_node(pos).name + if string.find(name, "farming:big_pumpkin") then + minetest.env:remove_node(pos) + end + pos.x = pos.x-dx + pos.y = pos.y-dy + pos.z = pos.z-dz + end + end + end + end +}) + +minetest.register_node("farming:big_pumpkin_side", { + paramtype = "light", + paramtype2 = "facedir", + tiles = {"farming_pumpkin_big_top_side.png", "farming_pumpkin_big_side.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, 0, 0.5, 0.5, 0.5} + } + }, + selection_box = { + type = "fixed", + fixed = { + {0, 0, 0, 0, 0, 0} + } + }, + groups = {not_in_creative_inventory=1}, +}) +minetest.register_node("farming:big_pumpkin_corner", { + paramtype = "light", + paramtype2 = "facedir", + tiles = {"farming_pumpkin_big_top_corner.png", "farming_pumpkin_big_side.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, 0, 0, 0.5, 0.5} + } + }, + selection_box = { + type = "fixed", + fixed = { + {0, 0, 0, 0, 0, 0} + } + }, + groups = {not_in_creative_inventory=1}, +}) + +minetest.register_node("farming:big_pumpkin_top", { + paramtype = "light", + tiles = {"farming_pumpkin_big_top.png"}, + selection_box = { + type = "fixed", + fixed = { + {0, 0, 0, 0, 0, 0} + } + }, + groups = {not_in_creative_inventory=1}, +}) + +minetest.register_craft({ + type = "shapeless", + output = "farming:big_pumpkin", + recipe = {"bucket:bucket_water", "farming:pumpkin"}, + replacements = { + {"bucket:bucket_water", "bucket:bucket_empty"} + } +}) + +-- ========= SCARECROW ========= +local box1 = { + {-1, -8, -1, 1, 8, 1}, +} + +local box2 = { + {-1, -8, -1, 1, 8, 1}, + {-12, -8, -1, 12, -7, 1}, + {-5, -2, -5, 5, 8, 5} +} + +for j,list in ipairs(box1) do + for i,int in ipairs(list) do + list[i] = int/16 + end + box1[j] = list +end + +for j,list in ipairs(box2) do + for i,int in ipairs(list) do + list[i] = int/16 + end + box2[j] = list +end + +minetest.register_node("farming:scarecrow", { + description = "Scarecrow", + paramtype = "light", + paramtype2 = "facedir", + tiles = {"farming_scarecrow_top.png", "farming_scarecrow_top.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_front.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = box2 + }, + selection_box = { + type = "fixed", + fixed = { + {-12/16, -1.5, -0.5, 12/16, 0.5, 0.5} + } + }, + groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2}, + + after_place_node = function(pos, placer) + local node = minetest.env:get_node(pos) + local param2 = node.param2 + pos.y = pos.y+1 + if minetest.env:get_node(pos).name ~= "air" then + pos.y = pos.y-1 + minetest.env:remove_node(pos) + minetest.after(0.1, function(placer) + local inv = placer:get_inventory() + local index = placer:get_wield_index() + inv:set_stack("main", index, ItemStack("farming:scarecrow")) + end, placer) + return + end + minetest.env:set_node(pos, node) + pos.y = pos.y-1 + node.name = "farming:scarecrow_bottom" + minetest.env:set_node(pos, node) + end, + + after_destruct = function(pos, oldnode) + pos.y = pos.y-1 + if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then + minetest.env:remove_node(pos) + end + end +}) + +minetest.register_node("farming:scarecrow_bottom", { + paramtype = "light", + paramtype2 = "facedir", + tiles = {"default_wood.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = box1 + }, + groups = {not_in_creative_inventory=1}, + selection_box = { + type = "fixed", + fixed = { + {0, 0, 0, 0, 0, 0} + } + } +}) + +minetest.register_craft({ + output = "farming:scarecrow", + recipe = { + {"", "farming:pumpkin_face", "",}, + {"default:stick", "default:stick", "default:stick",}, + {"", "default:stick", "",} + } +}) + +minetest.register_node("farming:scarecrow_light", { + description = "Scarecrow", + paramtype = "light", + paramtype2 = "facedir", + light_source = LIGHT_MAX-2, + tiles = {"farming_scarecrow_top.png", "farming_scarecrow_top.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_front_light.png"}, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = box2 + }, + selection_box = { + type = "fixed", + fixed = { + {-12/16, -1.5, -0.5, 12/16, 0.5, 0.5} + } + }, + groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2}, + + after_place_node = function(pos, placer) + local node = minetest.env:get_node(pos) + local param2 = node.param2 + pos.y = pos.y+1 + if minetest.env:get_node(pos).name ~= "air" then + pos.y = pos.y-1 + minetest.env:remove_node(pos) + minetest.after(0.1, function(placer) + local inv = placer:get_inventory() + local index = placer:get_wield_index() + inv:set_stack("main", index, ItemStack("farming:scarecrow_light")) + end, placer) + return + end + minetest.env:set_node(pos, node) + pos.y = pos.y-1 + node.name = "farming:scarecrow_bottom" + minetest.env:set_node(pos, node) + end, + + after_destruct = function(pos, oldnode) + pos.y = pos.y-1 + if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then + minetest.env:remove_node(pos) + end + end +}) + +minetest.register_craft({ + output = "farming:scarecrow_light", + recipe = { + {"", "farming:pumpkin_face_light", "",}, + {"default:stick", "default:stick", "default:stick",}, + {"", "default:stick", "",} + } +}) + +-- ========= FUEL ========= +minetest.register_craft({ + type = "fuel", + recipe = "farming:pumpkin_seed", + burntime = 1 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:pumpkin", + burntime = 5 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:pumpkin_face", + burntime = 5 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:pumpkin_face_light", + burntime = 7 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:big_pumpkin", + burntime = 10 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:scarecrow", + burntime = 5 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:scarecrow_light", + burntime = 5 +}) diff --git a/soil.lua b/soil.lua new file mode 100644 index 0000000..f800335 --- /dev/null +++ b/soil.lua @@ -0,0 +1,45 @@ +minetest.register_node("farming:soil", { + tiles = {"farming_soil.png", "default_dirt.png", "default_dirt.png", "default_dirt.png", "default_dirt.png", "default_dirt.png"}, + drop = "default:dirt", + groups = {crumbly=3, not_in_creative_inventory=1}, + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_node("farming:soil_wet", { + tiles = {"farming_soil_wet.png", "farming_soil_wet_side.png", "farming_soil_wet_side.png", "farming_soil_wet_side.png", "farming_soil_wet_side.png", "farming_soil_wet_side.png"}, + drop = "default:dirt", + groups = {crumbly=3, not_in_creative_inventory=1}, + sounds = default.node_sound_dirt_defaults({ + footstep = {name="default_grass_footstep", gain=0.4}, + }), +}) + +minetest.register_abm({ + nodenames = {"farming:soil"}, + interval = 15, + chance = 3, + action = function(pos, node) + if minetest.env:find_node_near(pos, 4, {"default:water_source", "default:water_flowing"}) then + node.name = "farming:soil_wet" + minetest.env:set_node(pos, node) + end + end, +}) + +-- ========= EXPERIMENTAL ========= +-- This will turn soil to dirt when walking over it +--[[minetest.register_abm({ + nodenames = {"farming:soil", "farming:soil_wet"}, + interval = 2, + chance = 2, + action = function(pos, node) + pos.y = pos.y+1 + if #(minetest.env:get_objects_inside_radius(pos, 0.8)) > 0 then + pos.y = pos.y-1 + node.name = "default:dirt" + minetest.env:set_node(pos, node) + end + end, +})]] diff --git a/textures/farming_bread.png b/textures/farming_bread.png new file mode 100644 index 0000000..6dca983 Binary files /dev/null and b/textures/farming_bread.png differ diff --git a/textures/farming_bread_pumpkin.png b/textures/farming_bread_pumpkin.png new file mode 100644 index 0000000..44db02e Binary files /dev/null and b/textures/farming_bread_pumpkin.png differ diff --git a/textures/farming_bucket_rubber.png b/textures/farming_bucket_rubber.png new file mode 100644 index 0000000..effdcac Binary files /dev/null and b/textures/farming_bucket_rubber.png differ diff --git a/textures/farming_cake_mix.png b/textures/farming_cake_mix.png new file mode 100644 index 0000000..5c4b197 Binary files /dev/null and b/textures/farming_cake_mix.png differ diff --git a/textures/farming_cake_mix_pumpkin.png b/textures/farming_cake_mix_pumpkin.png new file mode 100644 index 0000000..171e486 Binary files /dev/null and b/textures/farming_cake_mix_pumpkin.png differ diff --git a/textures/farming_cotton.png b/textures/farming_cotton.png new file mode 100644 index 0000000..8b8d367 Binary files /dev/null and b/textures/farming_cotton.png differ diff --git a/textures/farming_cotton_1.png b/textures/farming_cotton_1.png new file mode 100644 index 0000000..bc72c7e Binary files /dev/null and b/textures/farming_cotton_1.png differ diff --git a/textures/farming_cotton_2.png b/textures/farming_cotton_2.png new file mode 100644 index 0000000..70b6eef Binary files /dev/null and b/textures/farming_cotton_2.png differ diff --git a/textures/farming_cotton_seed.png b/textures/farming_cotton_seed.png new file mode 100644 index 0000000..4154062 Binary files /dev/null and b/textures/farming_cotton_seed.png differ diff --git a/textures/farming_flour.png b/textures/farming_flour.png new file mode 100644 index 0000000..7c302bf Binary files /dev/null and b/textures/farming_flour.png differ diff --git a/textures/farming_hoe_steel.png b/textures/farming_hoe_steel.png new file mode 100644 index 0000000..0d892b4 Binary files /dev/null and b/textures/farming_hoe_steel.png differ diff --git a/textures/farming_hoe_stone.png b/textures/farming_hoe_stone.png new file mode 100644 index 0000000..6b2da0b Binary files /dev/null and b/textures/farming_hoe_stone.png differ diff --git a/textures/farming_hoe_wood.png b/textures/farming_hoe_wood.png new file mode 100644 index 0000000..6b33f6e Binary files /dev/null and b/textures/farming_hoe_wood.png differ diff --git a/textures/farming_pumpkin_big_side.png b/textures/farming_pumpkin_big_side.png new file mode 100644 index 0000000..2651380 Binary files /dev/null and b/textures/farming_pumpkin_big_side.png differ diff --git a/textures/farming_pumpkin_big_top.png b/textures/farming_pumpkin_big_top.png new file mode 100644 index 0000000..581accc Binary files /dev/null and b/textures/farming_pumpkin_big_top.png differ diff --git a/textures/farming_pumpkin_big_top_corner.png b/textures/farming_pumpkin_big_top_corner.png new file mode 100644 index 0000000..ab1de28 Binary files /dev/null and b/textures/farming_pumpkin_big_top_corner.png differ diff --git a/textures/farming_pumpkin_big_top_side.png b/textures/farming_pumpkin_big_top_side.png new file mode 100644 index 0000000..e2eb1a7 Binary files /dev/null and b/textures/farming_pumpkin_big_top_side.png differ diff --git a/textures/farming_pumpkin_face.png b/textures/farming_pumpkin_face.png new file mode 100644 index 0000000..90c0f8a Binary files /dev/null and b/textures/farming_pumpkin_face.png differ diff --git a/textures/farming_pumpkin_face_light.png b/textures/farming_pumpkin_face_light.png new file mode 100644 index 0000000..cef4866 Binary files /dev/null and b/textures/farming_pumpkin_face_light.png differ diff --git a/textures/farming_pumpkin_seed.png b/textures/farming_pumpkin_seed.png new file mode 100644 index 0000000..6933bc3 Binary files /dev/null and b/textures/farming_pumpkin_seed.png differ diff --git a/textures/farming_pumpkin_side.png b/textures/farming_pumpkin_side.png new file mode 100644 index 0000000..3a3f9da Binary files /dev/null and b/textures/farming_pumpkin_side.png differ diff --git a/textures/farming_pumpkin_top.png b/textures/farming_pumpkin_top.png new file mode 100644 index 0000000..edef2d9 Binary files /dev/null and b/textures/farming_pumpkin_top.png differ diff --git a/textures/farming_scarecrow_front.png b/textures/farming_scarecrow_front.png new file mode 100644 index 0000000..364738f Binary files /dev/null and b/textures/farming_scarecrow_front.png differ diff --git a/textures/farming_scarecrow_front_light.png b/textures/farming_scarecrow_front_light.png new file mode 100644 index 0000000..b4b3cf2 Binary files /dev/null and b/textures/farming_scarecrow_front_light.png differ diff --git a/textures/farming_scarecrow_side.png b/textures/farming_scarecrow_side.png new file mode 100644 index 0000000..e22e84b Binary files /dev/null and b/textures/farming_scarecrow_side.png differ diff --git a/textures/farming_scarecrow_top.png b/textures/farming_scarecrow_top.png new file mode 100644 index 0000000..3a4addc Binary files /dev/null and b/textures/farming_scarecrow_top.png differ diff --git a/textures/farming_soil.png b/textures/farming_soil.png new file mode 100644 index 0000000..eac9843 Binary files /dev/null and b/textures/farming_soil.png differ diff --git a/textures/farming_soil_wet.png b/textures/farming_soil_wet.png new file mode 100644 index 0000000..398f727 Binary files /dev/null and b/textures/farming_soil_wet.png differ diff --git a/textures/farming_soil_wet_side.png b/textures/farming_soil_wet_side.png new file mode 100755 index 0000000..dd7f9b6 Binary files /dev/null and b/textures/farming_soil_wet_side.png differ diff --git a/textures/farming_string.png b/textures/farming_string.png new file mode 100644 index 0000000..f417ec4 Binary files /dev/null and b/textures/farming_string.png differ diff --git a/textures/farming_weed.png b/textures/farming_weed.png new file mode 100644 index 0000000..4667287 Binary files /dev/null and b/textures/farming_weed.png differ diff --git a/textures/farming_wheat.png b/textures/farming_wheat.png new file mode 100644 index 0000000..a508318 Binary files /dev/null and b/textures/farming_wheat.png differ diff --git a/textures/farming_wheat_1.png b/textures/farming_wheat_1.png new file mode 100644 index 0000000..007ecf3 Binary files /dev/null and b/textures/farming_wheat_1.png differ diff --git a/textures/farming_wheat_2.png b/textures/farming_wheat_2.png new file mode 100644 index 0000000..40956a7 Binary files /dev/null and b/textures/farming_wheat_2.png differ diff --git a/textures/farming_wheat_3.png b/textures/farming_wheat_3.png new file mode 100644 index 0000000..7dc89a7 Binary files /dev/null and b/textures/farming_wheat_3.png differ diff --git a/textures/farming_wheat_harvested.png b/textures/farming_wheat_harvested.png new file mode 100644 index 0000000..5abde6d Binary files /dev/null and b/textures/farming_wheat_harvested.png differ diff --git a/textures/farming_wheat_seed.png b/textures/farming_wheat_seed.png new file mode 100644 index 0000000..bf2ac77 Binary files /dev/null and b/textures/farming_wheat_seed.png differ diff --git a/weed.lua b/weed.lua new file mode 100644 index 0000000..55ed3ae --- /dev/null +++ b/weed.lua @@ -0,0 +1,39 @@ +minetest.register_node("farming:weed", { + description = "Weed", + paramtype = "light", + walkable = false, + drawtype = "plantlike", + tiles = {"farming_weed.png"}, + inventory_image = "farming_weed.png", + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.5+4/16, 0.5} + }, + }, + groups = {snappy=3, flammable=2}, + sounds = default.node_sound_leaves_defaults() +}) + +minetest.register_abm({ + nodenames = {"farming:soil_wet", "farming:soil"}, + interval = 50, + chance = 10, + action = function(pos, node) + if minetest.env:find_node_near(pos, 4, {"farming:scarecrow", "farming:scarecrow_light"}) ~= nil then + return + end + pos.y = pos.y+1 + if minetest.env:get_node(pos).name == "air" then + node.name = "farming:weed" + minetest.env:set_node(pos, node) + end + end +}) + +-- ========= FUEL ========= +minetest.register_craft({ + type = "fuel", + recipe = "farming:weed", + burntime = 1 +}) \ No newline at end of file diff --git a/wheat.lua b/wheat.lua new file mode 100644 index 0000000..e34675d --- /dev/null +++ b/wheat.lua @@ -0,0 +1,169 @@ +minetest.register_craftitem("farming:wheat_seed", { + description = "Wheat Seeds", + inventory_image = "farming_wheat_seed.png", + on_place = function(itemstack, placer, pointed_thing) + local above = minetest.env:get_node(pointed_thing.above) + if above.name == "air" then + above.name = "farming:wheat_1" + minetest.env:set_node(pointed_thing.above, above) + itemstack:take_item(1) + return itemstack + end + end +}) + +minetest.register_node("farming:wheat_1", { + paramtype = "light", + walkable = false, + drawtype = "plantlike", + drop = "", + tiles = {"farming_wheat_1.png"}, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.5+4/16, 0.5} + }, + }, + groups = {snappy=3, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("farming:wheat_2", { + paramtype = "light", + walkable = false, + drawtype = "plantlike", + drop = "", + tiles = {"farming_wheat_2.png"}, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.5+7/16, 0.5} + }, + }, + groups = {snappy=3, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("farming:wheat_3", { + paramtype = "light", + walkable = false, + drawtype = "plantlike", + drop = "", + tiles = {"farming_wheat_3.png"}, + selection_box = { + type = "fixed", + fixed = { + {-0.5, -0.5, -0.5, 0.5, -0.5+13/16, 0.5} + }, + }, + groups = {snappy=3, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +minetest.register_node("farming:wheat", { + paramtype = "light", + walkable = false, + drawtype = "plantlike", + tiles = {"farming_wheat.png"}, + drop = { + max_items = 4, + items = { + { items = {'farming:wheat_seed'} }, + { items = {'farming:wheat_seed'}, rarity = 2}, + { items = {'farming:wheat_seed'}, rarity = 5}, + { items = {'farming:wheat_harvested'} } + } + }, + groups = {snappy=3, flammable=2, not_in_creative_inventory=1}, + sounds = default.node_sound_leaves_defaults(), +}) + +farming:add_plant("farming:wheat", {"farming:wheat_1", "farming:wheat_2", "farming:wheat_3"}, 50, 20) + +minetest.register_craftitem("farming:wheat_harvested", { + description = "Harvested Wheat", + inventory_image = "farming_wheat_harvested.png", +}) + +minetest.register_craft({ + output = "farming:flour", + recipe = { + {"farming:wheat_harvested", } + } +}) + +minetest.register_craftitem("farming:flour", { + description = "Flour", + inventory_image = "farming_flour.png", +}) + +minetest.register_craft({ + output = "farming:cake_mix", + type = "shapeless", + recipe = {"farming:flour", "farming:flour", "farming:flour", "farming:flour", "bucket:bucket_water"}, + replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}} +}) + +minetest.register_craftitem("farming:cake_mix", { + description = "Cake Mix", + inventory_image = "farming_cake_mix.png", +}) + +minetest.register_craft({ + type = "cooking", + output = "farming:bread", + recipe = "farming:cake_mix", + cooktime = 10 +}) + +minetest.register_craftitem("farming:bread", { + description = "Bread", + inventory_image = "farming_bread.png", + stack_max = 1, + on_use = minetest.item_eat(10) +}) + +minetest.register_craftitem("farming:pumpkin_bread", { + description = "Pumpkin Bread", + inventory_image = "farming_bread_pumpkin.png", + stack_max = 1, + on_use = minetest.item_eat(20) +}) + +minetest.register_craftitem("farming:pumpkin_cake_mix", { + description = "Pumpkin Cake Mix", + inventory_image = "farming_cake_mix_pumpkin.png", +}) + +minetest.register_craft({ + output = "farming:pumpkin_cake_mix", + type = "shapeless", + recipe = {"farming:cake_mix", "farming:pumpkin"} +}) + +minetest.register_craft({ + type = "cooking", + output = "farming:pumpkin_bread", + recipe = "farming:pumpkin_cake_mix", + cooktime = 10 +}) + +minetest.register_alias("farming:corn_seed", "farming:wheat_seed") +minetest.register_alias("farming:corn_1", "farming:wheat_1") +minetest.register_alias("farming:corn_2", "farming:wheat_2") +minetest.register_alias("farming:corn_3", "farming:wheat_3") +minetest.register_alias("farming:corn", "farming:wheat") +minetest.register_alias("farming:corn_harvested", "farming:wheat_harvested") + +-- ========= FUEL ========= +minetest.register_craft({ + type = "fuel", + recipe = "farming:wheat_seed", + burntime = 1 +}) + +minetest.register_craft({ + type = "fuel", + recipe = "farming:wheat_harvested", + burntime = 2 +})