Make settings configurable in minetest

fixes #2 of LoneWolfHT
This commit is contained in:
Hybrid Dog 2017-11-01 14:17:04 +01:00
parent 618ab67d16
commit ba789f575c
2 changed files with 20 additions and 6 deletions

View File

@ -1,10 +1,11 @@
local load_time_start = minetest.get_us_time()
NYANLAND_HEIGHT=30688
NYANCAT_PROP=1
NYANLAND_TREESIZE=2
local info = minetest.is_singleplayer()
NYANLAND_HEIGHT = tonumber(minetest.settings:get"nyanland.height") or 30688
NYANCAT_PROP = (tonumber(minetest.settings:get"nyanland.nyancat_prop")
or 100.0) / 100.0
NYANLAND_TREESIZE = tonumber(minetest.settings:get"nyanland.tree_size") or 2
local info = minetest.settings:get_bool"nyanland.enable_debug_messages"
local nyanland={}
@ -150,7 +151,7 @@ minetest.register_abm({
nodenames = {"nyanland:healstone"},
interval = 1.0,
chance = 1,
action = function(pos)
action = function(pos,_,r,re)
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 3)) do
local hp = obj:get_hp()
if hp >= 20 then return end
@ -306,7 +307,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
--vm:update_liquids()
vm:write_to_map()
if math.random(NYANCAT_PROP)==1 then
if math.random() <= NYANCAT_PROP then
local nyan_headpos = {
x = minp.x + pr:next(1, 80),
y = ypse + pr:next(1, 20) + 10,

13
settingtypes.txt Normal file
View File

@ -0,0 +1,13 @@
# Show how much time map generation took in chat and infostream
nyanland.enable_debug_messages (Show debug messages) bool false
# The y coordinate of the nyanland
# You likely don't want to change this if the world is explored
nyanland.height (Height) int 30688 -32000 32000
# The radius of the nyanland tree heads
nyanland.tree_size (Tree head size) int 2 0 80
# The change of generating a nyancat in a mapchunk
# Value in percent (default 100%)
nyanland.nyancat_prop (Nyancat probability) float 100 0 100