commit 4a0ea38ec142a66d3aeccb749a207ebef1c103d0 Author: philipmi Date: Mon Apr 20 18:57:44 2020 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..caa32e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +*.iml \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5f879f3 --- /dev/null +++ b/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). diff --git a/depends.txt b/depends.txt new file mode 100644 index 0000000..205d2d3 --- /dev/null +++ b/depends.txt @@ -0,0 +1,2 @@ +default +ethereal diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..46e4900 --- /dev/null +++ b/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 +}) diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..612ea2b --- /dev/null +++ b/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. + diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..28174ca --- /dev/null +++ b/mod.conf @@ -0,0 +1,4 @@ +name = regrowing_fruits +author = philipmi +description = Fruits on ethereal trees will regrow. +title = Regrowing Fruits for Ethereal Mod diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..b37a96e Binary files /dev/null and b/screenshot.png differ diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..ad79562 --- /dev/null +++ b/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