complete revision
This commit is contained in:
parent
abf06bd213
commit
2e9a878a7f
6 changed files with 54 additions and 155 deletions
10
README.md
10
README.md
|
@ -1,17 +1,19 @@
|
|||
Regrowing Fruits for Ethereal Mod
|
||||
Regrowing Fruits
|
||||
===
|
||||
|
||||
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
|
||||
----
|
||||
|
||||
This mod is based on "endless_apples" by Shara RedCat (2018).
|
||||
This mod is inspired on "endless_apples" by Shara RedCat (2018).
|
||||
|
||||
License
|
||||
----
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
default
|
||||
ethereal
|
||||
default
|
182
init.lua
182
init.lua
|
@ -1,144 +1,48 @@
|
|||
local regrowing_bananas = minetest.settings:get_bool("regrowing_bananas", 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)
|
||||
local regrowing_apples = minetest.settings:get_bool("regrowing_apples", true)
|
||||
|
||||
-- override ethereal fruits
|
||||
if regrowing_bananas then
|
||||
minetest.override_item("ethereal:banana", {
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if oldnode.param2 == 0 then
|
||||
minetest.set_node(pos, {name = "regrowing_fruits:banana_mark"})
|
||||
minetest.get_node_timer(pos):start(math.random(300, 1500))
|
||||
end
|
||||
end,
|
||||
})
|
||||
local add_fruit_regrowable = function(fruit, node, leaves)
|
||||
|
||||
-- override fruit
|
||||
minetest.override_item(node, {
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if oldnode.param2 == 0 then
|
||||
minetest.set_node(pos, {name = "regrowing_fruits:"..fruit.."_mark"})
|
||||
minetest.get_node_timer(pos):start(math.random(300, 1500))
|
||||
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
|
||||
|
||||
if regrowing_coconuts then
|
||||
minetest.override_item("ethereal:coconut", {
|
||||
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,
|
||||
})
|
||||
if regrowing_apples then
|
||||
add_fruit_regrowable("apple", "default:apple", "default:leaves")
|
||||
end
|
||||
|
||||
if regrowing_goldapples then
|
||||
minetest.override_item("ethereal:golden_apple", {
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
if oldnode.param2 == 0 then
|
||||
minetest.set_node(pos, {name = "regrowing_fruits:goldapple_mark"})
|
||||
minetest.get_node_timer(pos):start(math.random(300, 1500))
|
||||
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
|
||||
})
|
||||
if minetest.get_modpath("ethereal") then
|
||||
add_fruit_regrowable("banana","ethereal:banana", "ethereal:bananaleaves")
|
||||
add_fruit_regrowable("coconut", "ethereal:coconut", "ethereal:palmleaves")
|
||||
add_fruit_regrowable("goldapple", "ethereal:golden_apple", "ethereal:yellowleaves")
|
||||
add_fruit_regrowable("orange", "ethereal:orange", "ethereal:orange_leaves")
|
||||
end
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
4
mod.conf
4
mod.conf
|
@ -1,4 +1,4 @@
|
|||
name = regrowing_fruits
|
||||
author = philipmi
|
||||
description = Fruits on ethereal trees will regrow.
|
||||
title = Regrowing Fruits for Ethereal Mod
|
||||
description = Fruits on trees from other mods will regrow.
|
||||
title = Regrowing Fruits
|
||||
|
|
|
@ -1,7 +1 @@
|
|||
regrowing_bananas (Enable regrowing bananas) bool true
|
||||
|
||||
regrowing_coconuts (Enable regrowing coconuts) bool true
|
||||
|
||||
regrowing_goldapples (Enable regrowing golden apples) bool false
|
||||
|
||||
regrowing_oranges (Enable regrowing oranges) bool true
|
||||
regrowing_apples (Regrowing apples(unnecessary for MT 5.x)) bool false
|
Loading…
Reference in a new issue