Extra error checking: global variables

This commit is contained in:
Duane 2016-07-15 04:18:54 -05:00
parent bf26b8bee1
commit 1648bc459f
17 changed files with 362 additions and 323 deletions

View file

@ -16,6 +16,9 @@ local players_in_orbit = {}
local mushrooms = {"flowers:mushroom_brown", "flowers:mushroom_red"} local mushrooms = {"flowers:mushroom_brown", "flowers:mushroom_red"}
local time_factor = (fun_caves.time_factor or 10)
local light_max = (fun_caves.light_max or 10)
-- fungal tree nodes -- fungal tree nodes
local fungal_tree_leaves = {} local fungal_tree_leaves = {}
@ -36,6 +39,9 @@ fungal_nodes[#fungal_nodes+1] = {name = 'fun_caves:fungal_tree_fruit'}
local fungi_to_explode = {} -- see below local fungi_to_explode = {} -- see below
local exploding_fungi = fun_caves.exploding_fungi local exploding_fungi = fun_caves.exploding_fungi
if not exploding_fungi then
exploding_fungi = {}
end
-- hot spike parameters -- hot spike parameters
@ -100,6 +106,10 @@ minetest.register_globalstep(function(dtime)
return return
end end
if not (fun_caves.db.status and fun_caves.registered_status) then
return
end
local time = minetest.get_gametime() local time = minetest.get_gametime()
if not (time and type(time) == 'number') then if not (time and type(time) == 'number') then
return return
@ -122,6 +132,10 @@ minetest.register_globalstep(function(dtime)
-- Promote mobs based on spawn position -- Promote mobs based on spawn position
local is_fortress = fun_caves.is_fortress local is_fortress = fun_caves.is_fortress
if not is_fortress then
return
end
for _, mob in pairs(minetest.luaentities) do for _, mob in pairs(minetest.luaentities) do
if not mob.initial_promotion then if not mob.initial_promotion then
local pos = mob.object:getpos() local pos = mob.object:getpos()
@ -276,7 +290,7 @@ minetest.register_globalstep(function(dtime)
end end
-- ... from hunger (even less often). -- ... from hunger (even less often).
if dps_count % hunger_delay == 0 then if dps_count % hunger_delay == 0 and fun_caves.hunger_change then
fun_caves.hunger_change(player, -1) fun_caves.hunger_change(player, -1)
end end
end end
@ -319,7 +333,7 @@ minetest.register_abm({
-- Exploding fungal fruit -- Exploding fungal fruit
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:fungal_tree_fruit"}, nodenames = {"fun_caves:fungal_tree_fruit"},
interval = 2 * fun_caves.time_factor, interval = 2 * time_factor,
chance = 150, chance = 150,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
@ -335,7 +349,7 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:fungal_tree_fruit"}, nodenames = {"fun_caves:fungal_tree_fruit"},
neighbors = {"fire:basic_flame"}, neighbors = {"fire:basic_flame"},
interval = fun_caves.time_factor, interval = time_factor,
chance = 50, chance = 50,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
@ -352,7 +366,7 @@ minetest.register_abm({
-- since it only checks below the node. -- since it only checks below the node.
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:giant_mushroom_cap", "fun_caves:huge_mushroom_cap"}, nodenames = {"fun_caves:giant_mushroom_cap", "fun_caves:huge_mushroom_cap"},
interval = fun_caves.time_factor, interval = time_factor,
chance = 25, chance = 25,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -371,14 +385,14 @@ minetest.register_abm({
-- Destroy mushroom caps in the light. -- Destroy mushroom caps in the light.
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:giant_mushroom_cap", "fun_caves:huge_mushroom_cap"}, nodenames = {"fun_caves:giant_mushroom_cap", "fun_caves:huge_mushroom_cap"},
interval = 2 * fun_caves.time_factor, interval = 2 * time_factor,
chance = 110, chance = 110,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
return return
end end
if (minetest.get_node_light(pos, nil) or 99) >= fun_caves.light_max + 2 then if (minetest.get_node_light(pos, nil) or 99) >= light_max + 2 then
minetest.remove_node(pos) minetest.remove_node(pos)
return return
end end
@ -391,7 +405,7 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:leaves"}, nodenames = {"default:leaves"},
interval = 10 * fun_caves.time_factor, interval = 10 * time_factor,
chance = 100, chance = 100,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
@ -409,7 +423,7 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:apple"}, nodenames = {"default:apple"},
interval = fun_caves.time_factor, interval = time_factor,
chance = 40, chance = 40,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
@ -425,7 +439,7 @@ minetest.register_abm({
local ice_node = {name = 'default:ice'} local ice_node = {name = 'default:ice'}
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:freezing_vapor"}, nodenames = {"fun_caves:freezing_vapor"},
interval = fun_caves.time_factor, interval = time_factor,
chance = 10, chance = 10,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -440,7 +454,7 @@ local no_tree_grow = {'fun_caves:bark', 'fun_caves:leaves'}
local wood_nodes = {{name = 'fun_caves:diamondwood'}, {name = 'fun_caves:ironwood'}, {name = 'fun_caves:sap'}, {name = 'fun_caves:tree'}} local wood_nodes = {{name = 'fun_caves:diamondwood'}, {name = 'fun_caves:ironwood'}, {name = 'fun_caves:sap'}, {name = 'fun_caves:tree'}}
minetest.register_abm({ minetest.register_abm({
neighbors = {'air'}, neighbors = {'air'},
interval = 5 * fun_caves.time_factor, interval = 5 * time_factor,
chance = 900, chance = 900,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
@ -476,7 +490,7 @@ local air_list = {'air'}
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:vacuum"}, nodenames = {"fun_caves:vacuum"},
neighbors = {"air"}, neighbors = {"air"},
interval = fun_caves.time_factor, interval = time_factor,
chance = 10, chance = 10,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -509,7 +523,7 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = fungal_tree_leaves, nodenames = fungal_tree_leaves,
neighbors = {"air", "group:liquid"}, neighbors = {"air", "group:liquid"},
interval = fun_caves.time_factor, interval = time_factor,
chance = 50, chance = 50,
catch_up = false, catch_up = false,
action = function(pos, node) action = function(pos, node)
@ -517,7 +531,7 @@ minetest.register_abm({
return return
end end
if (minetest.get_node_light(pos, nil) or 99) >= fun_caves.light_max + 2 then if (minetest.get_node_light(pos, nil) or 99) >= light_max + 2 then
minetest.remove_node(pos) minetest.remove_node(pos)
return return
end end
@ -531,7 +545,7 @@ minetest.register_abm({
grow_pos = {x=math.random(-1,1)+pos.x, y=math.random(-1,1)+pos.y, z=math.random(-1,1)+pos.z} grow_pos = {x=math.random(-1,1)+pos.x, y=math.random(-1,1)+pos.y, z=math.random(-1,1)+pos.z}
grow_node = minetest.get_node_or_nil(grow_pos) grow_node = minetest.get_node_or_nil(grow_pos)
if grow_node and grow_node.name == "air" and (minetest.get_node_light(grow_pos, nil) or 99) <= fun_caves.light_max then if grow_node and grow_node.name == "air" and (minetest.get_node_light(grow_pos, nil) or 99) <= light_max then
minetest.set_node(grow_pos, node) minetest.set_node(grow_pos, node)
return return
elseif grow_node and is_fungal_leaf[grow_node.name] and grow_node.name ~= node.name then elseif grow_node and is_fungal_leaf[grow_node.name] and grow_node.name ~= node.name then
@ -555,7 +569,7 @@ minetest.register_abm({
local huge_mushroom_cap_node = {name = 'fun_caves:huge_mushroom_cap'} local huge_mushroom_cap_node = {name = 'fun_caves:huge_mushroom_cap'}
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:giant_mushroom_stem"}, nodenames = {"fun_caves:giant_mushroom_stem"},
interval = 2 * fun_caves.time_factor, interval = 2 * time_factor,
chance = 75, chance = 75,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -568,7 +582,7 @@ minetest.register_abm({
return return
end end
if (minetest.get_node_light(pos_up, nil) or 99) <= fun_caves.light_max then if (minetest.get_node_light(pos_up, nil) or 99) <= light_max then
minetest.set_node(pos_up, huge_mushroom_cap_node) minetest.set_node(pos_up, huge_mushroom_cap_node)
end end
end end
@ -582,7 +596,7 @@ end
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:dirt"}, nodenames = {"default:dirt"},
neighbors = {"air"}, neighbors = {"air"},
interval = 2 * fun_caves.time_factor, interval = 2 * time_factor,
chance = 75, chance = 75,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -596,7 +610,7 @@ minetest.register_abm({
local grow_pos = {x=pos.x, y=pos.y+1, z=pos.z} local grow_pos = {x=pos.x, y=pos.y+1, z=pos.z}
local grow_node = minetest.get_node_or_nil(grow_pos) local grow_node = minetest.get_node_or_nil(grow_pos)
if grow_node and grow_node.name == "air" if grow_node and grow_node.name == "air"
and (minetest.get_node_light(grow_pos, nil) or 99) <= fun_caves.light_max then and (minetest.get_node_light(grow_pos, nil) or 99) <= light_max then
if math.random(4) == 1 then if math.random(4) == 1 then
minetest.set_node(grow_pos, fungal_nodes[math.random(#fungal_nodes - 1)]) minetest.set_node(grow_pos, fungal_nodes[math.random(#fungal_nodes - 1)])
else else
@ -610,7 +624,7 @@ minetest.register_abm({
local giant_mushroom_stem_node = {name = 'fun_caves:giant_mushroom_stem'} local giant_mushroom_stem_node = {name = 'fun_caves:giant_mushroom_stem'}
minetest.register_abm({ minetest.register_abm({
nodenames = mushrooms, nodenames = mushrooms,
interval = 5 * fun_caves.time_factor, interval = 5 * time_factor,
chance = 375, chance = 375,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -631,7 +645,7 @@ minetest.register_abm({
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z}) local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z})
if not node_under if not node_under
or minetest.get_item_group(node_under.name, "soil") == 0 or minetest.get_item_group(node_under.name, "soil") == 0
or (minetest.get_node_light(pos_up, nil) or 99) > fun_caves.light_max then or (minetest.get_node_light(pos_up, nil) or 99) > light_max then
return return
end end
@ -644,7 +658,7 @@ minetest.register_abm({
local giant_mushroom_cap_node = {name = "fun_caves:giant_mushroom_cap"} local giant_mushroom_cap_node = {name = "fun_caves:giant_mushroom_cap"}
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:huge_mushroom_cap"}, nodenames = {"fun_caves:huge_mushroom_cap"},
interval = 9 * fun_caves.time_factor, interval = 9 * time_factor,
chance = 1000, chance = 1000,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -661,7 +675,7 @@ minetest.register_abm({
local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 2, z = pos.z}) local node_under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 2, z = pos.z})
if not node_under if not node_under
or minetest.get_item_group(node_under.name, "soil") == 0 or minetest.get_item_group(node_under.name, "soil") == 0
or (minetest.get_node_light(pos_up, nil) or 99) > fun_caves.light_max then or (minetest.get_node_light(pos_up, nil) or 99) > light_max then
return return
end end
@ -673,16 +687,17 @@ minetest.register_abm({
-- Spike spread and death -- Spike spread and death
minetest.register_abm({ minetest.register_abm({
nodenames = fun_caves.hot_spikes, nodenames = fun_caves.hot_spikes,
interval = 3 * fun_caves.time_factor, interval = 3 * time_factor,
chance = 300, chance = 300,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
return return
end end
if not fun_caves.hot_spike then if not (fun_caves.hot_spike and fun_caves.hot_spikes) then
return return
end end
local spike_num = fun_caves.hot_spike[node.name] local spike_num = fun_caves.hot_spike[node.name]
if not spike_num then if not spike_num then
return return
@ -721,7 +736,7 @@ minetest.register_abm({
minetest.register_abm({ minetest.register_abm({
nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'}, nodenames = {"default:dirt_with_grass", "default:dirt_with_dry_grass", 'default:dirt_with_snow'},
neighbors = {"air", 'default:snow'}, neighbors = {"air", 'default:snow'},
interval = 25 * fun_caves.time_factor, interval = 25 * time_factor,
catch_up = false, catch_up = false,
chance = 32767, chance = 32767,
action = function(pos, node) action = function(pos, node)
@ -760,7 +775,7 @@ minetest.register_abm({
-- Remove old craters. -- Remove old craters.
minetest.register_abm({ minetest.register_abm({
nodenames = {"fun_caves:meteorite_crater"}, nodenames = {"fun_caves:meteorite_crater"},
interval = 3 * fun_caves.time_factor, interval = 3 * time_factor,
chance = 330, chance = 330,
action = function(pos, node) action = function(pos, node)
if not (pos and node) then if not (pos and node) then
@ -968,10 +983,10 @@ end
-- Mushroom spread and death -- Mushroom spread and death
--minetest.register_abm({ --minetest.register_abm({
-- nodenames = mushrooms, -- nodenames = mushrooms,
-- interval = 1 * fun_caves.time_factor, -- interval = 1 * time_factor,
-- chance = 50, -- chance = 50,
-- action = function(pos, node) -- action = function(pos, node)
-- if minetest.get_node_light(pos, nil) >= fun_caves.light_max + 2 then -- if minetest.get_node_light(pos, nil) >= light_max + 2 then
-- minetest.remove_node(pos) -- minetest.remove_node(pos)
-- return -- return
-- end -- end
@ -992,8 +1007,8 @@ end
-- --
-- if (minetest.get_item_group(node_under.name, "soil") ~= 0 or -- if (minetest.get_item_group(node_under.name, "soil") ~= 0 or
-- minetest.get_item_group(node_under.name, "tree") ~= 0) and -- minetest.get_item_group(node_under.name, "tree") ~= 0) and
-- minetest.get_node_light(pos, 0.5) <= fun_caves.light_max and -- minetest.get_node_light(pos, 0.5) <= light_max and
-- minetest.get_node_light(random, 0.5) <= fun_caves.light_max then -- minetest.get_node_light(random, 0.5) <= light_max then
-- minetest.set_node(random, {name = node.name}) -- minetest.set_node(random, {name = node.name})
-- end -- end
-- end -- end

View file

@ -19,7 +19,7 @@ ground_nodes[minetest.get_content_id('default:dirt_with_dry_grass')] = true
fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone) fun_caves.cavegen = function(minp, maxp, data, area, node, heightmap, underzone)
if not (minp and maxp and data and area and node and type(data) == 'table') then if not (minp and maxp and data and area and node and type(data) == 'table' and fun_caves.underzones) then
return return
end end

View file

@ -3,7 +3,7 @@ minetest.register_chatcommand("armor", {
description = "Display your armor values", description = "Display your armor values",
privs = {}, privs = {},
func = function(player_name, param) func = function(player_name, param)
if not (player_name and type(player_name) == 'string' and player_name ~= '') then if not (player_name and type(player_name) == 'string' and player_name ~= '' and fun_caves.db.status) then
return return
end end

View file

@ -123,7 +123,7 @@ local plant_noise = {offset = 0.0, scale = 1.0, spread = {x = 200, y = 200, z =
local biome_noise = {offset = 0.0, scale = 1.0, spread = {x = 400, y = 400, z = 400}, seed = -1471, octaves = 3, persist = 0.5, lacunarity = 2.0} local biome_noise = {offset = 0.0, scale = 1.0, spread = {x = 400, y = 400, z = 400}, seed = -1471, octaves = 3, persist = 0.5, lacunarity = 2.0}
fun_caves.cloudgen = function(minp, maxp, data, p2data, area, node) fun_caves.cloudgen = function(minp, maxp, data, p2data, area, node)
if not (minp and maxp and data and p2data and area and node and type(data) == 'table' and type(p2data) == 'table') then if not (minp and maxp and data and p2data and area and node and type(data) == 'table' and type(p2data) == 'table' and fun_caves.place_schematic and fun_caves.schematics and fun_caves.surround) then
return return
end end

View file

@ -249,9 +249,11 @@ do
end end
if fun_caves.path then
dofile(fun_caves.path .. "/deco_caves.lua") dofile(fun_caves.path .. "/deco_caves.lua")
--dofile(fun_caves.path.."/deco_dirt.lua") --dofile(fun_caves.path.."/deco_dirt.lua")
dofile(fun_caves.path.."/deco_plants.lua") dofile(fun_caves.path.."/deco_plants.lua")
dofile(fun_caves.path.."/deco_rocks.lua") dofile(fun_caves.path.."/deco_rocks.lua")
--dofile(fun_caves.path.."/deco_ferns.lua") --dofile(fun_caves.path.."/deco_ferns.lua")
--dofile(fun_caves.path.."/deco_ferns_tree.lua") --dofile(fun_caves.path.."/deco_ferns_tree.lua")
end

View file

@ -1,3 +1,5 @@
local light_max = fun_caves.light_max or 10
-- black (oily) sand -- black (oily) sand
local newnode = fun_caves.clone_node("default:sand") local newnode = fun_caves.clone_node("default:sand")
newnode.description = "Black Sand" newnode.description = "Black Sand"
@ -73,7 +75,7 @@ minetest.register_node("fun_caves:glowing_fungal_stone", {
description = "Glowing Fungal Stone", description = "Glowing Fungal Stone",
tiles = {"default_stone.png^vmg_glowing_fungal.png",}, tiles = {"default_stone.png^vmg_glowing_fungal.png",},
is_ground_content = true, is_ground_content = true,
light_source = fun_caves.light_max - 4, light_source = light_max - 4,
groups = {cracky=3, stone=1}, groups = {cracky=3, stone=1},
drop = {items={ {items={"default:cobble"},}, {items={"fun_caves:glowing_fungus",},},},}, drop = {items={ {items={"default:cobble"},}, {items={"fun_caves:glowing_fungus",},},},},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
@ -149,7 +151,7 @@ local cap = {
{-0.4, -0.5, -0.5, 0.4, -0.25, -0.4}, {-0.4, -0.5, -0.5, 0.4, -0.25, -0.4},
{-0.4, -0.5, 0.4, 0.4, -0.25, 0.5}, {-0.4, -0.5, 0.4, 0.4, -0.25, 0.5},
} }, } },
light_source = fun_caves.light_max, light_source = light_max,
groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1}, groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1},
} }
minetest.register_node("fun_caves:giant_mushroom_cap", cap) minetest.register_node("fun_caves:giant_mushroom_cap", cap)
@ -168,7 +170,7 @@ minetest.register_node("fun_caves:huge_mushroom_cap", {
{-0.33, -0.5, -0.33, 0.33, -0.33, -0.5}, {-0.33, -0.5, -0.33, 0.33, -0.33, -0.5},
{-0.33, -0.33, -0.33, 0.33, -0.17, 0.33}, {-0.33, -0.33, -0.33, 0.33, -0.17, 0.33},
} }, } },
light_source = fun_caves.light_max, light_source = light_max,
groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1}, groups = {fleshy=1, dig_immediate=3, flammable=2, plant=1},
}) })
@ -334,7 +336,7 @@ minetest.register_node("fun_caves:hot_stone", {
tiles = {"default_desert_stone.png^[colorize:#FF0000:150"}, tiles = {"default_desert_stone.png^[colorize:#FF0000:150"},
is_ground_content = true, is_ground_content = true,
groups = {crumbly=2, surface_hot=3}, groups = {crumbly=2, surface_hot=3},
light_source = fun_caves.light_max - 5, light_source = light_max - 5,
damage_per_second = 1, damage_per_second = 1,
sounds = default.node_sound_stone_defaults({ sounds = default.node_sound_stone_defaults({
footstep = {name="default_stone_footstep", gain=0.25}, footstep = {name="default_stone_footstep", gain=0.25},

View file

@ -36,7 +36,7 @@ minetest.register_node("fun_caves:dragon_eye", {
}) })
fun_caves.plantlist = { plantlist = {
{name="staghorn_coral", {name="staghorn_coral",
desc="Staghorn Coral", desc="Staghorn Coral",
water=true, water=true,
@ -85,7 +85,7 @@ fun_caves.plantlist = {
} }
for _, plant in ipairs(fun_caves.plantlist) do for _, plant in ipairs(plantlist) do
if plant.coral then if plant.coral then
groups = {cracky=3, stone=1, attached_node=1} groups = {cracky=3, stone=1, attached_node=1}
else else

View file

@ -26,7 +26,7 @@ local plant_noise = {offset = 0.0, scale = 1.0, spread = {x = 200, y = 200, z =
-- Air needs to be placed prior to decorations. -- Air needs to be placed prior to decorations.
fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, biomemap, biome_ids, underzone) fun_caves.decogen = function(minp, maxp, data, p2data, area, node, heightmap, biomemap, biome_ids, underzone)
if not (minp and maxp and data and p2data and area and node and type(data) == 'table' and type(p2data) == 'table') then if not (minp and maxp and data and p2data and area and node and type(data) == 'table' and type(p2data) == 'table' and fun_caves.underzones and fun_caves.cave_biomes and fun_caves.place_schematic and fun_caves.schematics and fun_caves.make_fungal_tree and fun_caves.surround and fun_caves.water_plants) then
return return
end end

View file

@ -90,7 +90,7 @@ mobs:register_mob("fun_caves:ice_demon", {
animation_speed = 30, animation_speed = 30,
fly_in = 'fun_caves:freezing_vapor', fly_in = 'fun_caves:freezing_vapor',
do_custom = function(self) do_custom = function(self)
if not self then if not (self and fun_caves.surface_damage and fun_caves.search_replace and fun_caves.custom_ready) then
return return
end end
@ -114,8 +114,10 @@ mobs:register_mob("fun_caves:ice_demon", {
end, end,
}) })
if fun_caves.underzones then
mobs:spawn_specific("fun_caves:ice_demon", {"default:ice"}, nil, -1, 10, 300, 3000, 2, fun_caves.underzones['Caina'].lower_bound, fun_caves.underzones['Caina'].upper_bound) mobs:spawn_specific("fun_caves:ice_demon", {"default:ice"}, nil, -1, 10, 300, 3000, 2, fun_caves.underzones['Caina'].lower_bound, fun_caves.underzones['Caina'].upper_bound)
mobs:spawn_specific("fun_caves:ice_demon", {"default:ice"}, {'default:torch'}, -1, 20, 100, 300, 2, fun_caves.underzones['Caina'].lower_bound, fun_caves.underzones['Caina'].upper_bound) mobs:spawn_specific("fun_caves:ice_demon", {"default:ice"}, {'default:torch'}, -1, 20, 100, 300, 2, fun_caves.underzones['Caina'].lower_bound, fun_caves.underzones['Caina'].upper_bound)
end
-- Blizzard Demon -- storm that slows players -- Blizzard Demon -- storm that slows players
@ -171,7 +173,7 @@ local snow_demon = {
}, },
animation_speed = 30, animation_speed = 30,
do_custom = function(self) do_custom = function(self)
if not self then if not (self and fun_caves.set_status and fun_caves.custom_ready and fun_caves.surface_damage) then
return return
end end
@ -194,6 +196,7 @@ local snow_demon = {
end, end,
} }
if fun_caves.register_status then
fun_caves.register_status({ fun_caves.register_status({
name = 'slow_cold', name = 'slow_cold',
start = function(player) start = function(player)
@ -211,6 +214,7 @@ fun_caves.register_status({
player:set_physics_override({speed=1}) player:set_physics_override({speed=1})
end, end,
}) })
end
if minetest.registered_entities["mobs_yeti:yeti"] then if minetest.registered_entities["mobs_yeti:yeti"] then
snow_demon.arrow = "mobs_yeti:snowball" snow_demon.arrow = "mobs_yeti:snowball"
@ -221,7 +225,9 @@ end
mobs:register_mob("fun_caves:snow_demon", snow_demon) mobs:register_mob("fun_caves:snow_demon", snow_demon)
if fun_caves.underzones then
mobs:spawn_specific("fun_caves:snow_demon", {"default:ice"}, nil, -1, 10, 300, 3000, 2, fun_caves.underzones['Caina'].lower_bound, fun_caves.underzones['Caina'].upper_bound) mobs:spawn_specific("fun_caves:snow_demon", {"default:ice"}, nil, -1, 10, 300, 3000, 2, fun_caves.underzones['Caina'].lower_bound, fun_caves.underzones['Caina'].upper_bound)
end
-- Magma Demon -- creates lava under player (!) -- Magma Demon -- creates lava under player (!)

View file

@ -169,6 +169,7 @@ if count > 15 then
end end
if fun_caves.register_status and fun_caves.set_status then
fun_caves.register_status({ fun_caves.register_status({
name = 'breathe', name = 'breathe',
terminate = function(player) terminate = function(player)
@ -224,7 +225,7 @@ minetest.register_craft({
fun_caves.register_status({ fun_caves.register_status({
name = 'damage_elixir', name = 'damage_elixir',
terminate = function(player) terminate = function(player)
if not player then if not (player and fun_caves.db.status) then
return return
end end
@ -238,7 +239,7 @@ fun_caves.register_status({
fun_caves.register_status({ fun_caves.register_status({
name = 'armor_elixir', name = 'armor_elixir',
terminate = function(player) terminate = function(player)
if not player then if not (player and fun_caves.db.status and fun_caves.display_armor) then
return return
end end
@ -265,7 +266,7 @@ fun_caves.register_status({
if fun_caves.expire_elixir_on_death then if fun_caves.expire_elixir_on_death then
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)
if not player then if not (player and fun_caves.db.status and fun_caves.display_armor) then
return return
end end
@ -291,7 +292,7 @@ end
local function increase_damage(user, bonus) local function increase_damage(user, bonus)
if not user then if not (user and fun_caves.set_status) then
return return
end end
@ -306,7 +307,7 @@ end
local function armor(user, factor) local function armor(user, factor)
if not user then if not (user and fun_caves.db.status and fun_caves.display_armor and fun_caves.set_status) then
return return
end end
@ -445,3 +446,4 @@ for _, desc in pairs(descs) do
}) })
end end
end end
end

View file

@ -3,8 +3,10 @@ local cells = 10
local cell_size = 60 / cells local cell_size = 60 / cells
if fun_caves.path then
dofile(fun_caves.path .. "/trophies.lua") dofile(fun_caves.path .. "/trophies.lua")
dofile(fun_caves.path .. "/tesseract.lua") dofile(fun_caves.path .. "/tesseract.lua")
end
-- dungeon floor, basic -- dungeon floor, basic

View file

@ -61,7 +61,7 @@ local traps = {
local function goblin_do(self) local function goblin_do(self)
if not (self and fun_caves.custom_ready(self)) then if not (self and fun_caves.custom_ready and fun_caves.search_replace and fun_caves.surface_damage and fun_caves.custom_ready(self)) then
return return
end end

View file

@ -399,6 +399,10 @@ local function generate(p_minp, p_maxp, seed)
local write = false local write = false
local write_p2, write_p4 = false, false local write_p2, write_p4 = false, false
local underzone local underzone
if not fun_caves.underzones then
return
end
for _, uz in pairs(fun_caves.underzones) do for _, uz in pairs(fun_caves.underzones) do
local avg = (minp.y + maxp.y) / 2 local avg = (minp.y + maxp.y) / 2
if avg <= uz.upper_bound and avg >= uz.lower_bound then if avg <= uz.upper_bound and avg >= uz.lower_bound then
@ -409,18 +413,18 @@ local function generate(p_minp, p_maxp, seed)
local aster = false local aster = false
if minp.y > 17200 then if minp.y > 17200 then
-- nop -- nop
elseif minp.y > 11000 then elseif minp.y > 11000 and fun_caves.asteroids then
write = fun_caves.asteroids(minp, maxp, data, p2data, area, node) write = fun_caves.asteroids(minp, maxp, data, p2data, area, node)
aster = true aster = true
elseif minp.y > 8400 then elseif minp.y > 8400 and fun_caves.skysea then
write = fun_caves.skysea(minp, maxp, data, p2data, area, node) write = fun_caves.skysea(minp, maxp, data, p2data, area, node)
elseif minp.y > 4000 then elseif minp.y > 4000 and fun_caves.cloudgen then
write = fun_caves.cloudgen(minp, maxp, data, p2data, area, node) write = fun_caves.cloudgen(minp, maxp, data, p2data, area, node)
elseif not underzone and fun_caves.is_fortress(minp, csize) then elseif not underzone and fun_caves.is_fortress(minp, csize) and fun_caves.fortress then
--if not underzone then --if not underzone then
fun_caves.fortress(minp, maxp, data, area, node) fun_caves.fortress(minp, maxp, data, area, node)
write = true write = true
else elseif fun_caves.cavegen and fun_caves.decogen and fun_caves.treegen then
local write1, write2, write3, write4, write5, h2 local write1, write2, write3, write4, write5, h2
write1, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone) write1, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone)
if h2 then if h2 then
@ -434,10 +438,10 @@ local function generate(p_minp, p_maxp, seed)
write2, write_p2 = fun_caves.decogen(minp, maxp, data, p2data, area, node, heightmap, biomemap, biome_ids, underzone) write2, write_p2 = fun_caves.decogen(minp, maxp, data, p2data, area, node, heightmap, biomemap, biome_ids, underzone)
write3 = fun_caves.treegen(minp, maxp, data, p2data, area, node) write3 = fun_caves.treegen(minp, maxp, data, p2data, area, node)
if not write3 then if not write3 and fun_caves.pyramid then
write4, write_p4 = fun_caves.pyramid(minp, maxp, data, p2data, area, biomemap, biome_ids, node, heightmap) write4, write_p4 = fun_caves.pyramid(minp, maxp, data, p2data, area, biomemap, biome_ids, node, heightmap)
end end
if fun_caves.use_villages and biomemap and not (write3 or write4) then if fun_caves.use_villages and biomemap and not (write3 or write4) and fun_caves.village then
local biome = biome_ids[biomemap[40*80+40]] local biome = biome_ids[biomemap[40*80+40]]
write5 = fun_caves.village(minp, maxp, data, p2data, area, node, biome, heightmap) write5 = fun_caves.village(minp, maxp, data, p2data, area, node, biome, heightmap)
end end
@ -475,6 +479,7 @@ local function generate(p_minp, p_maxp, seed)
end end
if fun_caves.path then
dofile(fun_caves.path .. "/asteroids.lua") dofile(fun_caves.path .. "/asteroids.lua")
dofile(fun_caves.path .. "/cavegen.lua") dofile(fun_caves.path .. "/cavegen.lua")
dofile(fun_caves.path .. "/cloudgen.lua") dofile(fun_caves.path .. "/cloudgen.lua")
@ -484,6 +489,7 @@ dofile(fun_caves.path .. "/pyramid.lua")
dofile(fun_caves.path .. "/treegen.lua") dofile(fun_caves.path .. "/treegen.lua")
dofile(fun_caves.path .. "/village.lua") dofile(fun_caves.path .. "/village.lua")
dofile(fun_caves.path .. "/skyseagen.lua") dofile(fun_caves.path .. "/skyseagen.lua")
end
-- Inserting helps to ensure that fun_caves operates first. -- Inserting helps to ensure that fun_caves operates first.

View file

@ -819,9 +819,11 @@ if minetest.registered_entities["mobs_sharks:shark_lg"] then
mobs:register_egg("fun_caves:shark_md", "Shark (giant)", "mob_shark_shark_item.png", 0) mobs:register_egg("fun_caves:shark_md", "Shark (giant)", "mob_shark_shark_item.png", 0)
end end
if fun_caves.path then
dofile(fun_caves.path.."/zombie.lua") dofile(fun_caves.path.."/zombie.lua")
dofile(fun_caves.path.."/goblin.lua") dofile(fun_caves.path.."/goblin.lua")
dofile(fun_caves.path.."/demon.lua") dofile(fun_caves.path.."/demon.lua")
end
fun_caves.fortress_spawns = {} fun_caves.fortress_spawns = {}
local t_mobs = { local t_mobs = {

View file

@ -1,7 +1,7 @@
local max_depth = 31000 local max_depth = 31000
local function teleporter(user, area, power) local function teleporter(user, area, power)
if not (user and area and power and type(power) == 'number') then if not (user and area and power and type(power) == 'number' and fun_caves.world and fun_caves.db and fun_caves.db.teleport_data and fun_caves.underzones and fun_caves.is_fortress and fun_caves.cave_noise_1 and fun_caves.cave_noise_2 and fun_caves.cave_width) then
return return
end end
@ -323,7 +323,7 @@ minetest.register_craft({
local function translocate(pos, node, clicker, itemstack, pointed_thing) local function translocate(pos, node, clicker, itemstack, pointed_thing)
if not (pos and clicker) then if not (pos and clicker and fun_caves.db.translocators) then
return return
end end
@ -394,7 +394,7 @@ local function trans_use(itemstack, user, pointed_thing)
end end
local function trans_place(itemstack, placer, pointed_thing) local function trans_place(itemstack, placer, pointed_thing)
if not (itemstack and placer and pointed_thing) then if not (itemstack and placer and pointed_thing and fun_caves.db.translocators) then
return return
end end
@ -431,7 +431,7 @@ local function trans_place(itemstack, placer, pointed_thing)
end end
local function trans_dig(pos, node, digger) local function trans_dig(pos, node, digger)
if not (pos and node and digger) then if not (pos and node and digger and fun_caves.db.translocators) then
return return
end end
@ -485,7 +485,7 @@ local function trans_dig(pos, node, digger)
end end
local function trans_dest(pos) local function trans_dest(pos)
if not pos then if not (pos and fun_caves.db.translocators) then
return return
end end
@ -560,7 +560,7 @@ for _, gem in pairs(gems) do
end end
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
if not (itemstack and player and itemstack:get_name() == "fun_caves:translocator") then if not (itemstack and player and fun_caves.db.translocators and itemstack:get_name() == "fun_caves:translocator") then
return return
end end

View file

@ -182,7 +182,7 @@ newnode = fun_caves.clone_node("default:tree")
newnode.description = "Glowing Fungal Wood" newnode.description = "Glowing Fungal Wood"
newnode.tiles = {"fun_caves_tree.png^vmg_glowing_fungal.png",} newnode.tiles = {"fun_caves_tree.png^vmg_glowing_fungal.png",}
newnode.drop = {items={ {items={"default:wood"},}, {items={"fun_caves:glowing_fungus",},},},} newnode.drop = {items={ {items={"default:wood"},}, {items={"fun_caves:glowing_fungus",},},},}
newnode.light_source = fun_caves.light_max - 4 newnode.light_source = (fun_caves.light_max or 10) - 4
minetest.register_node("fun_caves:glowing_fungal_wood", newnode) minetest.register_node("fun_caves:glowing_fungal_wood", newnode)

View file

@ -23,13 +23,15 @@ if mobs and mobs.mod == "redo" then
for i = 1, 5 do for i = 1, 5 do
food[#food+1] = 'default:grass_'..i food[#food+1] = 'default:grass_'..i
end end
if farming then if farming then
for i = 5, 8 do for i = 5, 8 do
food[#food+1] = 'farming:wheat_'..i food[#food+1] = 'farming:wheat_'..i
end end
end end
local function savage_gathering(self) local function savage_gathering(self)
if not (self and fun_caves.custom_ready(self)) then if not (self and fun_caves.custom_ready and fun_caves.search_replace and fun_caves.surface_damage and fun_caves.custom_ready(self)) then
return return
end end