regrow mod simplified and customized, for info cHECK mod readme inside
This commit is contained in:
parent
532c9c35b3
commit
a07989e040
@ -38,14 +38,16 @@ To download you can play this game with the following minetest engines:
|
|||||||
#### Mods
|
#### Mods
|
||||||
|
|
||||||
* minetest default
|
* minetest default
|
||||||
* minetest Auth Redux as `auth_rx` [mods/auth_rx](mods/auth_rx) from https://codeberg.org/minenux/minetest-mod-auth_rx
|
* sorceredkid auth mod
|
||||||
|
* minetest Auth Redux as `auth_rx` [mods/auth_rx](mods/auth_rx) from https://codeberg.org/minenux/minetest-mod-auth_rx
|
||||||
* so then minetest Formspecs as `formspecs` [mods/formspecs](mods/formspecs) from https://codeberg.org/minenux/minetest-mod-formspecs
|
* so then minetest Formspecs as `formspecs` [mods/formspecs](mods/formspecs) from https://codeberg.org/minenux/minetest-mod-formspecs
|
||||||
* minetest Random Spawn as `rspawn` [mods/rspawn](mods/rspawn) from https://codeberg.org/minenux/minetest-mod-rspawn
|
* minetest Random Spawn as `rspawn` [mods/rspawn](mods/rspawn) from https://codeberg.org/minenux/minetest-mod-rspawn
|
||||||
* so then default beds as `beds` [mods/beds](mods/beds) from default 0.4
|
* so then default beds as `beds` [mods/beds](mods/beds) from default 0.4
|
||||||
* minetest floatlands as `floatlands` [mods/floatlands](mods/floatlands) derived from Floatlands Realm made to this servers, as https://codeberg.org/minenux/minetest-mod-floatland
|
* minetest floatlands as `floatlands` [mods/floatlands](mods/floatlands) derived from Floatlands Realm made to this servers, as https://codeberg.org/minenux/minetest-mod-floatland
|
||||||
* so then default flowers as `flowers` are need. Later this will need ethereal modifications.
|
* so then default flowers as `flowers` are need. Later this will need ethereal modifications.
|
||||||
* tenplus1 simple skins as `skins` [mods/skins](mods/skins) from https://codeberg.org/minenux/minetest-mod-simple_skins
|
* tenplus1 customized mods
|
||||||
* customized so this was renamed to mantain consistency and simplification, also some settiungs were minimalized
|
* simple_skins as `skins` [mods/skins](mods/skins) from https://codeberg.org/minenux/minetest-mod-simple_skins
|
||||||
|
* regrow as `regrow` [mods/regrow](mods/regrow) from https://codeberg.org/minenux/minetest-mod-regrow
|
||||||
|
|
||||||
## Licensing
|
## Licensing
|
||||||
|
|
||||||
|
1
mods/regrow/description.txt
Normal file
1
mods/regrow/description.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
FRUIT regrow instead of replanting saplings
|
146
mods/regrow/init.lua
Normal file
146
mods/regrow/init.lua
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
|
||||||
|
regrow = {
|
||||||
|
-- get custom min and max growth intervals from settings
|
||||||
|
min_interval = tonumber(minetest.settings:get("regrow_min_interval")) or 600,
|
||||||
|
max_interval = tonumber(minetest.settings:get("regrow_max_interval")) or 1200
|
||||||
|
}
|
||||||
|
|
||||||
|
local is_51 = minetest.has_feature("formspec_version_element") or nil
|
||||||
|
|
||||||
|
-- hidden node that runs timer and regrows fruit stored in meta
|
||||||
|
minetest.register_node("regrow:hidden", {
|
||||||
|
drawtype = "airlike",
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
|
pointable = false,
|
||||||
|
diggable = false,
|
||||||
|
buildable_to = true,
|
||||||
|
drop = "",
|
||||||
|
groups = {not_in_creative_inventory = 1},
|
||||||
|
|
||||||
|
-- once placed start random timer between min and max interval setting
|
||||||
|
on_construct = function(pos)
|
||||||
|
|
||||||
|
local time = math.random(regrow.min_interval, regrow.max_interval)
|
||||||
|
|
||||||
|
minetest.get_node_timer(pos):start(time)
|
||||||
|
end,
|
||||||
|
|
||||||
|
-- when timer reached check which fruit to place if tree still exists
|
||||||
|
on_timer = function(pos, elapsed)
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
if not meta then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local fruit = meta:get_string("fruit") or ""
|
||||||
|
local leaf = meta:get_string("leaf") or ""
|
||||||
|
local p2 = meta:get_int("p2") or 0
|
||||||
|
|
||||||
|
if fruit == "" or leaf == ""
|
||||||
|
or not minetest.find_node_near(pos, 1, leaf) then
|
||||||
|
fruit = "air"
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.set_node(pos, {name = fruit, param2 = p2})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- helper function to register fruit nodes
|
||||||
|
regrow.add_fruit = function(nodename, leafname, ignore_param2)
|
||||||
|
|
||||||
|
-- does node actually exist ?
|
||||||
|
if not minetest.registered_nodes[nodename] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- change attached_node values so fruits regrow instead of dropping
|
||||||
|
local groups = minetest.registered_nodes[nodename].groups
|
||||||
|
groups.attached_node = 0
|
||||||
|
|
||||||
|
minetest.override_item(nodename, {
|
||||||
|
|
||||||
|
-- override on_dig to remove any special functions
|
||||||
|
on_dig = minetest.node_dig,
|
||||||
|
|
||||||
|
-- override after_dig_node to start regrowth
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
|
||||||
|
-- if node has been placed by player then do not regrow
|
||||||
|
if ignore_param2 ~= true and oldnode.param2 > 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- replace fruit with regrowth node, set fruit & leaf name
|
||||||
|
minetest.set_node(pos, {name = "regrow:hidden"})
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
|
meta:set_string("fruit", nodename)
|
||||||
|
meta:set_string("leaf", leafname)
|
||||||
|
meta:set_int("p2", oldnode.param2 or 0)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
regrow.regrow = function()
|
||||||
|
-- default
|
||||||
|
regrow.add_fruit("default:apple", "default:leaves")
|
||||||
|
|
||||||
|
-- ethereal
|
||||||
|
regrow.add_fruit("ethereal:banana", "ethereal:bananaleaves")
|
||||||
|
regrow.add_fruit("ethereal:banana_bunch", "ethereal:bananaleaves")
|
||||||
|
regrow.add_fruit("ethereal:orange", "ethereal:orange_leaves")
|
||||||
|
regrow.add_fruit("ethereal:coconut", "ethereal:palmleaves")
|
||||||
|
regrow.add_fruit("ethereal:lemon", "ethereal:lemon_leaves")
|
||||||
|
regrow.add_fruit("ethereal:olive", "ethereal:olive_leaves")
|
||||||
|
-- regrow.add_fruit("ethereal:golden_apple", "ethereal:yellowleaves") -- too OP
|
||||||
|
|
||||||
|
-- cool trees
|
||||||
|
regrow.add_fruit("cacaotree:pod", "cacaotree:trunk", true)
|
||||||
|
regrow.add_fruit("cherrytree:cherries", "cherrytree:blossom_leaves")
|
||||||
|
regrow.add_fruit("clementinetree:clementine", "clementinetree:leaves")
|
||||||
|
regrow.add_fruit("ebony:persimmon", "ebony:leaves")
|
||||||
|
regrow.add_fruit("lemontree:lemon", "lemontree:leaves")
|
||||||
|
regrow.add_fruit("oak:acorn", "oak:leaves")
|
||||||
|
regrow.add_fruit("palm:coconut", "palm:leaves")
|
||||||
|
-- regrow.add_fruit("plumtree:plum", "plumtree:leaves") -- regrows already
|
||||||
|
regrow.add_fruit("pomegranate:pomegranate", "pomegranate:leaves")
|
||||||
|
|
||||||
|
-- farming plus
|
||||||
|
regrow.add_fruit("farming_plus:cocoa", "farming_plus:cocoa_leaves")
|
||||||
|
regrow.add_fruit("farming_plus:banana", "farming_plus:banana_leaves")
|
||||||
|
|
||||||
|
-- aotearoa
|
||||||
|
regrow.add_fruit("aotearoa:karaka_fruit", "aotearoa:karaka_leaves")
|
||||||
|
regrow.add_fruit("aotearoa:miro_fruit", "aotearoa:miro_leaves")
|
||||||
|
regrow.add_fruit("aotearoa:tawa_fruit", "aotearoa:tawa_leaves")
|
||||||
|
regrow.add_fruit("aotearoa:hinau_fruit", "aotearoa:hinau_leaves")
|
||||||
|
regrow.add_fruit("aotearoa:kawakawa_fruit", "aotearoa:kawakawa_leaves")
|
||||||
|
|
||||||
|
-- australia
|
||||||
|
regrow.add_fruit("australia:cherry", "australia:cherry_leaves")
|
||||||
|
regrow.add_fruit("australia:lilly_pilly_berries", "australia:lilly_pilly_leaves")
|
||||||
|
regrow.add_fruit("australia:macadamia", "australia:macadamia_leaves")
|
||||||
|
regrow.add_fruit("australia:mangrove_apple", "australia:mangrove_apple_leaves")
|
||||||
|
regrow.add_fruit("australia:moreton_bay_fig", "australia:moreton_bay_fig_leaves")
|
||||||
|
regrow.add_fruit("australia:quandong", "australia:quandong_leaves")
|
||||||
|
|
||||||
|
-- more trees
|
||||||
|
regrow.add_fruit("moretrees:acorn", "moretrees:oak_leaves")
|
||||||
|
regrow.add_fruit("moretrees:cedar_cone", "moretrees:cedar_leaves")
|
||||||
|
regrow.add_fruit("moretrees:fir_cone", "moretrees:fir_leaves")
|
||||||
|
regrow.add_fruit("moretrees:spruce_cone", "moretrees:spruce_leaves")
|
||||||
|
end
|
||||||
|
|
||||||
|
if is_51 then
|
||||||
|
-- wait until mods are loaded to save dependency mess
|
||||||
|
minetest.register_on_mods_loaded(regrow.regrow)
|
||||||
|
else
|
||||||
|
minetest.after(0.1, regrow.regrow)
|
||||||
|
end
|
||||||
|
|
||||||
|
print("[MOD] Regrow loaded")
|
21
mods/regrow/license.txt
Normal file
21
mods/regrow/license.txt
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018 TenPlus1
|
||||||
|
|
||||||
|
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
mods/regrow/mod.conf
Normal file
4
mods/regrow/mod.conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
name = regrow
|
||||||
|
depends =
|
||||||
|
optional_depends =
|
||||||
|
description = FRUIT regrow instead of replanting saplings.
|
118
mods/regrow/readme.MD
Normal file
118
mods/regrow/readme.MD
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
minetest mod REGROW
|
||||||
|
===================
|
||||||
|
|
||||||
|
Mod to regrow fruits with self-contained API
|
||||||
|
|
||||||
|
## Information
|
||||||
|
-----------
|
||||||
|
|
||||||
|
This mod helps to regrow tree fruits instead of the need for replanting
|
||||||
|
saplings each time.
|
||||||
|
|
||||||
|
|
||||||
|
![screenshot.jpg](screenshot.jpg)
|
||||||
|
|
||||||
|
|
||||||
|
## Technical info
|
||||||
|
--------------
|
||||||
|
|
||||||
|
This mod is named `regrow` a simplified optimized version
|
||||||
|
of fruits nodes to reappears on place after dig using timer parameters.
|
||||||
|
|
||||||
|
#### Dependences
|
||||||
|
|
||||||
|
none, core minetest api, the mod has a node detection inside the api function
|
||||||
|
so its secure to use no matter if the corresponding node exits or not.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
Each fruit will grow depending of the minimun and maximun value,
|
||||||
|
the time the fruit appears is random between the two configured values:
|
||||||
|
|
||||||
|
| setting name | description | type | default | observations |
|
||||||
|
| ------------------- | ----------------------- | --- | ------- | ----------- |
|
||||||
|
| regrow_min_interval | Minimum Regrow Interval | int | 600 | Seconds |
|
||||||
|
| regrow_max_interval | Maximum Regrow Interval | int | 1200 | seconds |
|
||||||
|
|
||||||
|
### Overview:
|
||||||
|
|
||||||
|
Based on "endless_apples" by Shara RedCat (2018). Its starting
|
||||||
|
at https://forum.minetest.net/viewtopic.php?p=379158#p379158 to solve
|
||||||
|
an issue over growing fruits and now is mantained.
|
||||||
|
|
||||||
|
The mod works as is but can be used for other mods, currently the mod
|
||||||
|
has support for `ethereal`, `farming_plus`, `australia`, `aotearoa`,
|
||||||
|
and `moretrees`. It also support some special others.
|
||||||
|
|
||||||
|
#### Nodes
|
||||||
|
|
||||||
|
| MOD supported | Fruit to regrow (node) | Sustitute when growing (node) |
|
||||||
|
| ------------- | ---------------------- | ----------------------------- |
|
||||||
|
| default | default:apple | default:leaves |
|
||||||
|
| ethereal | ethereal:banana | ethereal:bananaleaves |
|
||||||
|
| ethereal | ethereal:banana_bunch | ethereal:bananaleaves |
|
||||||
|
| ethereal | ethereal:orange | ethereal:orange_leaves |
|
||||||
|
| ethereal | ethereal:coconut | ethereal:palmleaves |
|
||||||
|
| ethereal | ethereal:lemon | ethereal:lemon_leaves |
|
||||||
|
| ethereal | ethereal:olive | ethereal:olive_leaves |
|
||||||
|
| ethereal | ethereal:golden_apple | ethereal:yellowleaves (disabled) |
|
||||||
|
| cool_trees | cacaotree:pod | cacaotree:trunk (override) |
|
||||||
|
| cool_trees | cherrytree:cherries | cherrytree:blossom_leaves |
|
||||||
|
| cool_trees | clementinetree:clementine | clementinetree:leaves |
|
||||||
|
| cool_trees | ebony:persimmon | ebony:leaves |
|
||||||
|
| cool_trees | lemontree:lemon | lemontree:leaves |
|
||||||
|
| cool_trees | oak:acorn | oak:leaves |
|
||||||
|
| cool_trees | palm:coconut | palm:leaves |
|
||||||
|
| cool_trees | pomegranate:pomegranate | pomegranate:leaves |
|
||||||
|
| farming_plus | farming_plus:cocoa | farming_plus:cocoa_leaves |
|
||||||
|
| farming_plus | farming_plus:banana | farming_plus:banana_leaves |
|
||||||
|
| aotearoa | aotearoa:karaka_fruit | aotearoa:karaka_leaves |
|
||||||
|
| aotearoa | aotearoa:miro_fruit | aotearoa:miro_leaves |
|
||||||
|
| aotearoa | aotearoa:tawa_fruit | aotearoa:tawa_leaves |
|
||||||
|
| aotearoa | aotearoa:hinau_fruit | aotearoa:hinau_leaves |
|
||||||
|
| aotearoa | aotearoa:kawakawa_fruit | aotearoa:kawakawa_leaves |
|
||||||
|
| australia | australia:cherry | australia:cherry_leaves |
|
||||||
|
| australia | australia:lilly_pilly_berries | australia:lilly_pilly_leaves |
|
||||||
|
| australia | australia:macadamia | australia:macadamia_leaves |
|
||||||
|
| australia | australia:mangrove_apple | australia:mangrove_apple_leaves |
|
||||||
|
| australia | australia:moreton_bay_fig | australia:moreton_bay_fig_leaves |
|
||||||
|
| australia | australia:quandong | australia:quandong_leaves |
|
||||||
|
| moretrees | moretrees:acorn | moretrees:oak_leaves |
|
||||||
|
| moretrees | moretrees:cedar_cone | moretrees:cedar_leaves |
|
||||||
|
| moretrees | moretrees:fir_cone | moretrees:fir_leaves |
|
||||||
|
| moretrees | moretrees:spruce_cone | moretrees:spruce_leaves |
|
||||||
|
|
||||||
|
#### API usage
|
||||||
|
|
||||||
|
The `regrow.add_fruit()` function is used to override each fruits `after_dig_node`
|
||||||
|
function so that an placeholder node (nostly leaves) is placed once it is taken, then a timer is
|
||||||
|
started that will regrow the fruit on completion (unless tree is chopped down).
|
||||||
|
|
||||||
|
#### Definition
|
||||||
|
|
||||||
|
`regrow.add_fruit(fruit_node, leaves_node, param2_check_override)`
|
||||||
|
|
||||||
|
#### Examples:
|
||||||
|
|
||||||
|
```
|
||||||
|
regrow.add_fruit("default:apple", "default:leaves")
|
||||||
|
regrow.add_fruit("cacaotree:pod", "cacaotree:trunk", true)
|
||||||
|
```
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
---------
|
||||||
|
|
||||||
|
- 0.1 - Initial upload.
|
||||||
|
- 0.2 - Add checks for player placed fruit and tree's nearby.
|
||||||
|
- 0.3 - Make add_fruit a global function for other mods to use.
|
||||||
|
- 0.4 - Add check for fruit tree leaf type before re-growing.
|
||||||
|
- 0.5 - Ethereal Lemons and Olives can now regrow.
|
||||||
|
- 0.6 - Add support for cool_trees, farming_plus, aotearoa, australia and moretrees
|
||||||
|
- 0.7 - Add param2 override for cacao with placement param2 check
|
||||||
|
- 0.8 - Add custom min and max time regrow interval settings (defaults are 600 and 1200)
|
||||||
|
|
||||||
|
|
||||||
|
## LICENSE
|
||||||
|
|
||||||
|
MIT see [license.txt](license.txt) file.
|
||||||
|
|
BIN
mods/regrow/screenshot.jpg
Normal file
BIN
mods/regrow/screenshot.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
5
mods/regrow/settingtypes.txt
Normal file
5
mods/regrow/settingtypes.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Minimum interval in seconds it takes to regrow fruits
|
||||||
|
regrow_min_interval (Minimum Regrow Interval) int 600
|
||||||
|
|
||||||
|
# Maximum interval in seconds it takes to regrow fruits
|
||||||
|
regrow_max_interval (Maximum Regrow Interval) int 1200
|
Loading…
x
Reference in New Issue
Block a user