forked from mtcontrib/farming
check for old wheat/cotton seeds and grow to stage_1 via abm
This commit is contained in:
parent
02cf5688fa
commit
b5f71d8025
@ -8,15 +8,16 @@ minetest.register_node("farming:seed_barley", {
|
|||||||
inventory_image = "farming_barley_seed.png",
|
inventory_image = "farming_barley_seed.png",
|
||||||
wield_image = "farming_barley_seed.png",
|
wield_image = "farming_barley_seed.png",
|
||||||
drawtype = "signlike",
|
drawtype = "signlike",
|
||||||
groups = {seed = 1, snappy = 3, attached_node = 1},
|
groups = {seed = 1, snappy = 3, attached_node = 1, growing = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
next_plant = "farming:barley_1",
|
||||||
selection_box = farming.select,
|
selection_box = farming.select,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
-- on_place = function(itemstack, placer, pointed_thing)
|
||||||
return farming.place_seed(itemstack, placer, pointed_thing, "farming:barley_1")
|
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:barley_1")
|
||||||
end
|
-- end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- harvested barley
|
-- harvested barley
|
||||||
|
@ -34,15 +34,16 @@ minetest.register_node("farming:seed_cotton", {
|
|||||||
inventory_image = "farming_cotton_seed.png",
|
inventory_image = "farming_cotton_seed.png",
|
||||||
wield_image = "farming_cotton_seed.png",
|
wield_image = "farming_cotton_seed.png",
|
||||||
drawtype = "signlike",
|
drawtype = "signlike",
|
||||||
groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4},
|
groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4, growing = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = farming.select,
|
selection_box = farming.select,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
next_plant = "farming:cotton_1",
|
||||||
return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
|
-- on_place = function(itemstack, placer, pointed_thing)
|
||||||
end
|
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
|
||||||
|
-- end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- cotton
|
-- cotton
|
||||||
|
@ -8,15 +8,16 @@ minetest.register_node("farming:seed_hemp", {
|
|||||||
inventory_image = "farming_hemp_seed.png",
|
inventory_image = "farming_hemp_seed.png",
|
||||||
wield_image = "farming_hemp_seed.png",
|
wield_image = "farming_hemp_seed.png",
|
||||||
drawtype = "signlike",
|
drawtype = "signlike",
|
||||||
groups = {seed = 1, snappy = 3, attached_node = 1},
|
groups = {seed = 1, snappy = 3, attached_node = 1, growing = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = farming.select,
|
selection_box = farming.select,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
next_plant = "farming:hemp_1",
|
||||||
return farming.place_seed(itemstack, placer, pointed_thing, "farming:hemp_1")
|
-- on_place = function(itemstack, placer, pointed_thing)
|
||||||
end
|
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:hemp_1")
|
||||||
|
-- end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- harvested hemp
|
-- harvested hemp
|
||||||
|
@ -8,15 +8,16 @@ minetest.register_node("farming:seed_wheat", {
|
|||||||
inventory_image = "farming_wheat_seed.png",
|
inventory_image = "farming_wheat_seed.png",
|
||||||
wield_image = "farming_wheat_seed.png",
|
wield_image = "farming_wheat_seed.png",
|
||||||
drawtype = "signlike",
|
drawtype = "signlike",
|
||||||
groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4},
|
groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4, growing = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = farming.select,
|
selection_box = farming.select,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
next_plant = "farming:wheat_1",
|
||||||
return farming.place_seed(itemstack, placer, pointed_thing, "farming:wheat_1")
|
-- on_place = function(itemstack, placer, pointed_thing)
|
||||||
end
|
-- return farming.place_seed(itemstack, placer, pointed_thing, "farming:wheat_1")
|
||||||
|
-- end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- harvested wheat
|
-- harvested wheat
|
||||||
|
61
init.lua
61
init.lua
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
farming = {
|
farming = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230122",
|
version = "20230407",
|
||||||
path = minetest.get_modpath("farming"),
|
path = minetest.get_modpath("farming"),
|
||||||
select = {
|
select = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
@ -198,30 +198,30 @@ local function reg_plant_stages(plant_name, stage, force_last)
|
|||||||
local old_constr = node_def.on_construct
|
local old_constr = node_def.on_construct
|
||||||
local old_destr = node_def.on_destruct
|
local old_destr = node_def.on_destruct
|
||||||
|
|
||||||
minetest.override_item(node_name,
|
minetest.override_item(node_name, {
|
||||||
{
|
|
||||||
on_construct = function(pos)
|
|
||||||
|
|
||||||
if old_constr then
|
on_construct = function(pos)
|
||||||
old_constr(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
farming.handle_growth(pos)
|
if old_constr then
|
||||||
end,
|
old_constr(pos)
|
||||||
|
end
|
||||||
|
|
||||||
on_destruct = function(pos)
|
farming.handle_growth(pos)
|
||||||
|
end,
|
||||||
|
|
||||||
minetest.get_node_timer(pos):stop()
|
on_destruct = function(pos)
|
||||||
|
|
||||||
if old_destr then
|
minetest.get_node_timer(pos):stop()
|
||||||
old_destr(pos)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_timer = function(pos, elapsed)
|
if old_destr then
|
||||||
return farming.plant_growth_timer(pos, elapsed, node_name)
|
old_destr(pos)
|
||||||
end,
|
end
|
||||||
})
|
end,
|
||||||
|
|
||||||
|
on_timer = function(pos, elapsed)
|
||||||
|
return farming.plant_growth_timer(pos, elapsed, node_name)
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif force_last then
|
elseif force_last then
|
||||||
@ -313,7 +313,22 @@ minetest.register_abm({
|
|||||||
chance = 1,
|
chance = 1,
|
||||||
catch_up = false,
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
farming.handle_growth(pos, node)
|
|
||||||
|
-- check if group:growing node is a seed
|
||||||
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
|
||||||
|
if def.groups and def.groups.seed then
|
||||||
|
|
||||||
|
local next_stage = def.next_plant
|
||||||
|
local p2 = def.place_param2
|
||||||
|
|
||||||
|
-- change seed to stage_1 or crop
|
||||||
|
if next_stage then
|
||||||
|
minetest.set_node(pos, {name = next_stage, param2 = p2})
|
||||||
|
end
|
||||||
|
else
|
||||||
|
farming.handle_growth(pos, node)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -542,7 +557,7 @@ farming.register_plant = function(name, def)
|
|||||||
inventory_image = def.inventory_image,
|
inventory_image = def.inventory_image,
|
||||||
wield_image = def.inventory_image,
|
wield_image = def.inventory_image,
|
||||||
drawtype = "signlike",
|
drawtype = "signlike",
|
||||||
groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 2},
|
groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 2, growing = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
walkable = false,
|
walkable = false,
|
||||||
@ -552,8 +567,8 @@ farming.register_plant = function(name, def)
|
|||||||
next_plant = mname .. ":" .. pname .. "_1",
|
next_plant = mname .. ":" .. pname .. "_1",
|
||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
return farming.place_seed(itemstack, placer,
|
return farming.place_seed(itemstack, placer, pointed_thing,
|
||||||
pointed_thing, mname .. ":" .. pname .. "_1")
|
mname .. ":" .. pname .. "_1")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user