forked from mtcontrib/farming
tweak code, fix straw recipe
This commit is contained in:
parent
e409fe9ecb
commit
45dd32c102
73
init.lua
73
init.lua
@ -1,6 +1,5 @@
|
|||||||
--[[
|
--[[
|
||||||
Farming Redo Mod
|
Farming Redo Mod by TenPlus1
|
||||||
by TenPlus1
|
|
||||||
NEW growing routine by prestidigitator
|
NEW growing routine by prestidigitator
|
||||||
auto-refill by crabman77
|
auto-refill by crabman77
|
||||||
]]
|
]]
|
||||||
@ -8,18 +7,14 @@
|
|||||||
-- Translation support
|
-- Translation support
|
||||||
local S = minetest.get_translator("farming")
|
local S = minetest.get_translator("farming")
|
||||||
|
|
||||||
-- set global
|
-- global
|
||||||
|
|
||||||
farming = {
|
farming = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20240812",
|
version = "20240812",
|
||||||
path = minetest.get_modpath("farming"),
|
path = minetest.get_modpath("farming"),
|
||||||
select = {
|
select = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}},
|
||||||
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
|
select_final = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -2.5/16, 0.5}},
|
||||||
},
|
|
||||||
select_final = {
|
|
||||||
type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -2.5/16, 0.5}
|
|
||||||
},
|
|
||||||
registered_plants = {},
|
registered_plants = {},
|
||||||
min_light = 12,
|
min_light = 12,
|
||||||
max_light = 15,
|
max_light = 15,
|
||||||
@ -172,8 +167,6 @@ farming.plant_stages = plant_stages
|
|||||||
-- @return - The (possibly zero) number of stages of growth the plant will go through
|
-- @return - The (possibly zero) number of stages of growth the plant will go through
|
||||||
-- before being fully grown, or nil if not a plant.
|
-- before being fully grown, or nil if not a plant.
|
||||||
|
|
||||||
local register_plant_node
|
|
||||||
|
|
||||||
-- Recursive helper
|
-- Recursive helper
|
||||||
|
|
||||||
local function reg_plant_stages(plant_name, stage, force_last)
|
local function reg_plant_stages(plant_name, stage, force_last)
|
||||||
@ -251,9 +244,8 @@ local register_plant_node = function(node)
|
|||||||
if plant_name then
|
if plant_name then
|
||||||
|
|
||||||
local stages = reg_plant_stages(plant_name, stage, false)
|
local stages = reg_plant_stages(plant_name, stage, false)
|
||||||
|
|
||||||
return stages and #stages.stages_left
|
return stages and #stages.stages_left
|
||||||
else
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -291,14 +283,6 @@ function farming.handle_growth(pos, node)
|
|||||||
if stages_left then set_growing(pos, stages_left) end
|
if stages_left then set_growing(pos, stages_left) end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.after(0, function()
|
|
||||||
|
|
||||||
for _, node_def in pairs(minetest.registered_nodes) do
|
|
||||||
register_plant_node(node_def)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Just in case a growing type or added node is missed (also catches existing
|
-- Just in case a growing type or added node is missed (also catches existing
|
||||||
-- nodes added to map before timers were incorporated).
|
-- nodes added to map before timers were incorporated).
|
||||||
|
|
||||||
@ -319,8 +303,7 @@ minetest.register_abm({
|
|||||||
|
|
||||||
if def and def.groups and def.groups.seed then
|
if def and def.groups and def.groups.seed then
|
||||||
|
|
||||||
-- start node timer if found
|
if def.on_timer then -- start node timer if found
|
||||||
if def.on_timer then
|
|
||||||
|
|
||||||
farming.start_seed_timer(pos)
|
farming.start_seed_timer(pos)
|
||||||
|
|
||||||
@ -331,24 +314,24 @@ minetest.register_abm({
|
|||||||
|
|
||||||
def = minetest.registered_nodes[next_stage]
|
def = minetest.registered_nodes[next_stage]
|
||||||
|
|
||||||
-- switch seed without timer to stage_1 of crop
|
if def then -- switch seed without timer to stage_1 of crop
|
||||||
if def then
|
|
||||||
|
|
||||||
local p2 = def.place_param2 or 1
|
local p2 = def.place_param2 or 1
|
||||||
|
|
||||||
minetest.set_node(pos, {name = next_stage, param2 = p2})
|
minetest.set_node(pos, {name = next_stage, param2 = p2})
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- start normal crop timer
|
farming.handle_growth(pos, node) -- start normal crop timer
|
||||||
farming.handle_growth(pos, node)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- default check if on wet soil
|
-- default check crop is on wet soil
|
||||||
|
|
||||||
farming.can_grow = function(pos)
|
farming.can_grow = function(pos)
|
||||||
|
|
||||||
local below = minetest.get_node({x = pos.x, y = pos.y -1, z = pos.z})
|
local below = minetest.get_node({x = pos.x, y = pos.y -1, z = pos.z})
|
||||||
|
|
||||||
return minetest.get_item_group(below.name, "soil") >= 3
|
return minetest.get_item_group(below.name, "soil") >= 3
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -367,13 +350,11 @@ function farming.plant_growth_timer(pos, elapsed, node_name)
|
|||||||
local chk1 = minetest.registered_nodes[node_name].growth_check -- old
|
local chk1 = minetest.registered_nodes[node_name].growth_check -- old
|
||||||
local chk2 = minetest.registered_nodes[node_name].can_grow -- new
|
local chk2 = minetest.registered_nodes[node_name].can_grow -- new
|
||||||
|
|
||||||
-- custom farming redo growth_check function
|
if chk1 then -- custom farming redo growth_check function
|
||||||
if chk1 then
|
|
||||||
|
|
||||||
if not chk1(pos, node_name) then return true end
|
if not chk1(pos, node_name) then return true end
|
||||||
|
|
||||||
-- custom mt 5.9x farming can_grow function
|
elseif chk2 then -- custom mt 5.9x farming can_grow function
|
||||||
elseif chk2 then
|
|
||||||
|
|
||||||
if not chk2(pos) then return true end
|
if not chk2(pos) then return true end
|
||||||
|
|
||||||
@ -434,11 +415,7 @@ end
|
|||||||
|
|
||||||
function farming.refill_plant(player, plantname, index)
|
function farming.refill_plant(player, plantname, index)
|
||||||
|
|
||||||
if not player then return end
|
local inv = player and player:get_inventory() ; if not inv then return end
|
||||||
|
|
||||||
local inv = player:get_inventory()
|
|
||||||
|
|
||||||
if not inv then return end
|
|
||||||
|
|
||||||
local old_stack = inv:get_stack("main", index)
|
local old_stack = inv:get_stack("main", index)
|
||||||
|
|
||||||
@ -703,9 +680,7 @@ farming.rice = true
|
|||||||
|
|
||||||
local input = io.open(farming.path .. "/farming.conf", "r")
|
local input = io.open(farming.path .. "/farming.conf", "r")
|
||||||
|
|
||||||
if input then
|
if input then dofile(farming.path .. "/farming.conf") ; input:close() end
|
||||||
dofile(farming.path .. "/farming.conf") ; input:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- load new world-specific settings if found inside world folder
|
-- load new world-specific settings if found inside world folder
|
||||||
|
|
||||||
@ -713,9 +688,7 @@ local worldpath = minetest.get_worldpath()
|
|||||||
|
|
||||||
input = io.open(worldpath .. "/farming.conf", "r")
|
input = io.open(worldpath .. "/farming.conf", "r")
|
||||||
|
|
||||||
if input then
|
if input then dofile(worldpath .. "/farming.conf") ; input:close() end
|
||||||
dofile(worldpath .. "/farming.conf") ; input:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- helper function to add {eatable} group to food items, also {flammable}
|
-- helper function to add {eatable} group to food items, also {flammable}
|
||||||
|
|
||||||
@ -737,7 +710,7 @@ end
|
|||||||
|
|
||||||
dofile(farming.path .. "/item_list.lua")
|
dofile(farming.path .. "/item_list.lua")
|
||||||
|
|
||||||
-- important items
|
-- setup soil, register hoes, override grass
|
||||||
|
|
||||||
if minetest.get_modpath("default") then
|
if minetest.get_modpath("default") then
|
||||||
dofile(farming.path .. "/soil.lua")
|
dofile(farming.path .. "/soil.lua")
|
||||||
@ -746,14 +719,6 @@ end
|
|||||||
|
|
||||||
dofile(farming.path.."/grass.lua")
|
dofile(farming.path.."/grass.lua")
|
||||||
|
|
||||||
-- default crops
|
|
||||||
|
|
||||||
if not farming.mcl then
|
|
||||||
dofile(farming.path.."/crops/wheat.lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
dofile(farming.path.."/crops/cotton.lua")
|
|
||||||
|
|
||||||
-- disable crops Mineclone already has
|
-- disable crops Mineclone already has
|
||||||
|
|
||||||
if farming.mcl then
|
if farming.mcl then
|
||||||
@ -764,8 +729,12 @@ if farming.mcl then
|
|||||||
farming.beetroot = nil
|
farming.beetroot = nil
|
||||||
farming.sunflower = nil
|
farming.sunflower = nil
|
||||||
farming.pumpkin = nil
|
farming.pumpkin = nil
|
||||||
|
else
|
||||||
|
dofile(farming.path.."/crops/wheat.lua") -- default crop outwith mineclone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
dofile(farming.path.."/crops/cotton.lua") -- default crop
|
||||||
|
|
||||||
-- helper function
|
-- helper function
|
||||||
|
|
||||||
local function ddoo(file, check)
|
local function ddoo(file, check)
|
||||||
|
@ -1211,7 +1211,7 @@ minetest.register_craft( {
|
|||||||
|
|
||||||
-- straw
|
-- straw
|
||||||
|
|
||||||
local tmp = "group:food_wheat"
|
local tmp = farming.mcl and "farming:rye" or "farming:wheat"
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "farming:straw 3",
|
output = "farming:straw 3",
|
||||||
@ -1223,7 +1223,7 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "farming:wheat 3",
|
output = tmp .. " 3",
|
||||||
recipe = {{"farming:straw"}}
|
recipe = {{"farming:straw"}}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user