Browse Source

initial commit

master
philipmi 2 years ago
commit
4a0ea38ec1
  1. 2
      .gitignore
  2. 19
      README.md
  3. 2
      depends.txt
  4. 144
      init.lua
  5. 23
      license.txt
  6. 4
      mod.conf
  7. BIN
      screenshot.png
  8. 7
      settingtypes.txt

2
.gitignore vendored

@ -0,0 +1,2 @@
.idea/
*.iml

19
README.md

@ -0,0 +1,19 @@
Regrowing Fruits for Ethereal Mod
===
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.
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.
Credits
----
This mod is based on "endless_apples" by Shara RedCat (2018).
License
----
Code for this mod is released under MIT (https://opensource.org/licenses/MIT).

2
depends.txt

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

144
init.lua

@ -0,0 +1,144 @@
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)
-- 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,
})
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,
})
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
})

23
license.txt

@ -0,0 +1,23 @@
The MIT License (MIT)
Copyright (c) 2020 philipmi, 2018 Shara RedCat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

4
mod.conf

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

BIN
screenshot.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

7
settingtypes.txt

@ -0,0 +1,7 @@
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
Loading…
Cancel
Save