complete revision

This commit is contained in:
philipmi 2020-06-27 21:03:25 +02:00
parent abf06bd213
commit 2e9a878a7f
6 changed files with 54 additions and 155 deletions

View file

@ -1,17 +1,19 @@
Regrowing Fruits for Ethereal Mod Regrowing Fruits
=== ===
Info Info
---- ----
This mod causes fruits on ethereal trees to regrow like apples in the 0.5 release of Minetest Game. If you placed the fruits by hand or removed the tree leaves, the fruits don't regrow. This mod causes fruits on trees from other mods to regrow like apples in the 5.0 release of Minetest Game. If you placed the fruits by hand or removed the tree leaves, the fruits don't regrow.
In Minetest Settings you can disable the different types of regrowing fruits. Regrowing golden apples are disabled in default settings to keep them special fruits. Bananas, coconuts and oranges are all enabled. In the moment only ethereal mod is supported, but I'm sure there are other mods with this problem I do not use. Please tell me on Minetest Forum page!
There is also the possibility to enable regrowing apples in Minetest Settings. Notice that this is only necessary for older versions than MT 5.0.
Credits Credits
---- ----
This mod is based on "endless_apples" by Shara RedCat (2018). This mod is inspired on "endless_apples" by Shara RedCat (2018).
License License
---- ----

View file

@ -1,2 +1 @@
default default
ethereal

182
init.lua
View file

@ -1,144 +1,48 @@
local regrowing_bananas = minetest.settings:get_bool("regrowing_bananas", true) local regrowing_apples = minetest.settings:get_bool("regrowing_apples", true)
local regrowing_coconuts = minetest.settings:get_bool("regrowing_coconuts", true)
local regrowing_goldapples = minetest.settings:get_bool("regrowing_goldapples", true)
local regrowing_oranges = minetest.settings:get_bool("regrowing_oranges", true)
-- override ethereal fruits local add_fruit_regrowable = function(fruit, node, leaves)
if regrowing_bananas then
minetest.override_item("ethereal:banana", { -- override fruit
after_dig_node = function(pos, oldnode, oldmetadata, digger) minetest.override_item(node, {
if oldnode.param2 == 0 then after_dig_node = function(pos, oldnode, oldmetadata, digger)
minetest.set_node(pos, {name = "regrowing_fruits:banana_mark"}) if oldnode.param2 == 0 then
minetest.get_node_timer(pos):start(math.random(300, 1500)) minetest.set_node(pos, {name = "regrowing_fruits:"..fruit.."_mark"})
end minetest.get_node_timer(pos):start(math.random(300, 1500))
end, end
}) end,
})
-- air node to mark fruit pos
minetest.register_node("regrowing_fruits:"..fruit.."_mark", {
description = "Air!",
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
groups = {not_in_creative_inventory = 1},
on_timer = function(pos, elapsed)
if not minetest.find_node_near(pos, 1, leaves) then
minetest.remove_node(pos)
elseif minetest.get_node_light(pos) < 13 then
minetest.get_node_timer(pos):start(200)
else
minetest.set_node(pos, {name = node})
end
end
})
end end
if regrowing_coconuts then if regrowing_apples then
minetest.override_item("ethereal:coconut", { add_fruit_regrowable("apple", "default:apple", "default:leaves")
after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldnode.param2 == 0 then
minetest.set_node(pos, {name = "regrowing_fruits:coconut_mark"})
minetest.get_node_timer(pos):start(math.random(300, 1500))
end
end,
})
end end
if regrowing_goldapples then if minetest.get_modpath("ethereal") then
minetest.override_item("ethereal:golden_apple", { add_fruit_regrowable("banana","ethereal:banana", "ethereal:bananaleaves")
after_dig_node = function(pos, oldnode, oldmetadata, digger) add_fruit_regrowable("coconut", "ethereal:coconut", "ethereal:palmleaves")
if oldnode.param2 == 0 then add_fruit_regrowable("goldapple", "ethereal:golden_apple", "ethereal:yellowleaves")
minetest.set_node(pos, {name = "regrowing_fruits:goldapple_mark"}) add_fruit_regrowable("orange", "ethereal:orange", "ethereal:orange_leaves")
minetest.get_node_timer(pos):start(math.random(300, 1500)) end
end
end,
})
end
if regrowing_oranges then
minetest.override_item("ethereal:orange", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldnode.param2 == 0 then
minetest.set_node(pos, {name = "regrowing_fruits:orange_mark"})
minetest.get_node_timer(pos):start(math.random(300, 1500))
end
end,
})
end
-- air nodes to mark fruit pos
minetest.register_node("regrowing_fruits:banana_mark", {
description = "Air!",
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
groups = {not_in_creative_inventory = 1},
on_timer = function(pos, elapsed)
if not minetest.find_node_near(pos, 1, "ethereal:bananaleaves")
or not regrowing_bananas then
minetest.remove_node(pos)
elseif minetest.get_node_light(pos) < 13 then
minetest.get_node_timer(pos):start(200)
else
minetest.set_node(pos, {name = "ethereal:banana"})
end
end
})
minetest.register_node("regrowing_fruits:coconut_mark", {
description = "Air!",
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
groups = {not_in_creative_inventory = 1},
on_timer = function(pos, elapsed)
if not minetest.find_node_near(pos, 1, "ethereal:palmleaves")
or not regrowing_coconuts then
minetest.remove_node(pos)
elseif minetest.get_node_light(pos) < 13 then
minetest.get_node_timer(pos):start(200)
else
minetest.set_node(pos, {name = "ethereal:coconut"})
end
end
})
minetest.register_node("regrowing_fruits:goldapple_mark", {
description = "Air!",
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
groups = {not_in_creative_inventory = 1},
on_timer = function(pos, elapsed)
if not minetest.find_node_near(pos, 1, "ethereal:yellowleaves")
or not regrowing_goldapples then
minetest.remove_node(pos)
elseif not regrowing_goldapples then
return
elseif minetest.get_node_light(pos) < 13 then
minetest.get_node_timer(pos):start(200)
else
minetest.set_node(pos, {name = "ethereal:golden_apple"})
end
end
})
minetest.register_node("regrowing_fruits:orange_mark", {
description = "Air!",
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
buildable_to = true,
drop = "",
groups = {not_in_creative_inventory = 1},
on_timer = function(pos, elapsed)
if not minetest.find_node_near(pos, 1, "ethereal:orange_leaves")
or not regrowing_oranges then
minetest.remove_node(pos)
elseif minetest.get_node_light(pos) < 13 then
minetest.get_node_timer(pos):start(200)
else
minetest.set_node(pos, {name = "ethereal:orange"})
end
end
})

View file

@ -1,7 +1,7 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2020 philipmi, 2018 Shara RedCat Copyright (c) 2020 philipmi
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -1,4 +1,4 @@
name = regrowing_fruits name = regrowing_fruits
author = philipmi author = philipmi
description = Fruits on ethereal trees will regrow. description = Fruits on trees from other mods will regrow.
title = Regrowing Fruits for Ethereal Mod title = Regrowing Fruits

View file

@ -1,7 +1 @@
regrowing_bananas (Enable regrowing bananas) bool true regrowing_apples (Regrowing apples(unnecessary for MT 5.x)) bool false
regrowing_coconuts (Enable regrowing coconuts) bool true
regrowing_goldapples (Enable regrowing golden apples) bool false
regrowing_oranges (Enable regrowing oranges) bool true