add hops.lua and init.lua
parent
669111aa07
commit
f6fb24e718
|
@ -0,0 +1,81 @@
|
|||
minetest.register_craftitem("farming:hops_seed", {
|
||||
description = "hops Seeds",
|
||||
inventory_image = "farming_hops_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:hops_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming:hops_1", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_hops_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:hops_2", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_hops_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:hops", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_hops.png"},
|
||||
drop = {
|
||||
max_items = 6,
|
||||
items = {
|
||||
{ items = {'farming:hops_seed'} },
|
||||
{ items = {'farming:hops_seed'}, rarity = 2},
|
||||
{ items = {'farming:hops_seed'}, rarity = 5},
|
||||
{ items = {'beer:cone'} },
|
||||
{ items = {'beer:cone'}, rarity = 2 },
|
||||
{ items = {'beer:cone'}, rarity = 5 }
|
||||
}
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
farming:add_plant("farming:hops", {"farming:hops_1", "farming:hops_2"}, 50, 20)
|
||||
|
||||
|
||||
|
||||
-- ========= FUEL =========
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:hops_seed",
|
||||
burntime = 1
|
||||
})
|
||||
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
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 not minetest.env:get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
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 not minetest.env:get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
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:hops_seed"]=60,
|
||||
}
|
||||
|
||||
-- ========= 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")
|
||||
|
||||
-- ========= PUMPKIN =========
|
||||
dofile(minetest.get_modpath("farming").."/pumpkin.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")
|
||||
|
||||
-- ========= HOPS =========
|
||||
dofile(minetest.get_modpath("farming").."/hops.lua")
|
||||
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.log("action", "farming loaded")
|
||||
end
|
Loading…
Reference in New Issue