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

View file

@ -3,7 +3,7 @@ minetest.register_chatcommand("armor", {
description = "Display your armor values",
privs = {},
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
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}
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
end

View file

@ -249,9 +249,11 @@ do
end
dofile(fun_caves.path .. "/deco_caves.lua")
--dofile(fun_caves.path.."/deco_dirt.lua")
dofile(fun_caves.path.."/deco_plants.lua")
dofile(fun_caves.path.."/deco_rocks.lua")
--dofile(fun_caves.path.."/deco_ferns.lua")
--dofile(fun_caves.path.."/deco_ferns_tree.lua")
if fun_caves.path then
dofile(fun_caves.path .. "/deco_caves.lua")
--dofile(fun_caves.path.."/deco_dirt.lua")
dofile(fun_caves.path.."/deco_plants.lua")
dofile(fun_caves.path.."/deco_rocks.lua")
--dofile(fun_caves.path.."/deco_ferns.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
local newnode = fun_caves.clone_node("default:sand")
newnode.description = "Black Sand"
@ -73,7 +75,7 @@ minetest.register_node("fun_caves:glowing_fungal_stone", {
description = "Glowing Fungal Stone",
tiles = {"default_stone.png^vmg_glowing_fungal.png",},
is_ground_content = true,
light_source = fun_caves.light_max - 4,
light_source = light_max - 4,
groups = {cracky=3, stone=1},
drop = {items={ {items={"default:cobble"},}, {items={"fun_caves:glowing_fungus",},},},},
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.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},
}
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.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},
})
@ -334,7 +336,7 @@ minetest.register_node("fun_caves:hot_stone", {
tiles = {"default_desert_stone.png^[colorize:#FF0000:150"},
is_ground_content = true,
groups = {crumbly=2, surface_hot=3},
light_source = fun_caves.light_max - 5,
light_source = light_max - 5,
damage_per_second = 1,
sounds = default.node_sound_stone_defaults({
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",
desc="Staghorn Coral",
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
groups = {cracky=3, stone=1, attached_node=1}
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.
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
end

View file

@ -90,7 +90,7 @@ mobs:register_mob("fun_caves:ice_demon", {
animation_speed = 30,
fly_in = 'fun_caves:freezing_vapor',
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
end
@ -114,8 +114,10 @@ mobs:register_mob("fun_caves:ice_demon", {
end,
})
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)
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"}, {'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
@ -171,7 +173,7 @@ local snow_demon = {
},
animation_speed = 30,
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
end
@ -194,23 +196,25 @@ local snow_demon = {
end,
}
fun_caves.register_status({
name = 'slow_cold',
start = function(player)
if not player then
return
end
if fun_caves.register_status then
fun_caves.register_status({
name = 'slow_cold',
start = function(player)
if not player then
return
end
player:set_physics_override({speed=0.3})
end,
terminate = function(player)
if not player then
return
end
player:set_physics_override({speed=0.3})
end,
terminate = function(player)
if not player then
return
end
player:set_physics_override({speed=1})
end,
})
player:set_physics_override({speed=1})
end,
})
end
if minetest.registered_entities["mobs_yeti:yeti"] then
snow_demon.arrow = "mobs_yeti:snowball"
@ -221,7 +225,9 @@ end
mobs:register_mob("fun_caves:snow_demon", snow_demon)
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)
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)
end
-- Magma Demon -- creates lava under player (!)

View file

@ -169,23 +169,130 @@ if count > 15 then
end
fun_caves.register_status({
name = 'breathe',
terminate = function(player)
if not player then
return
end
if fun_caves.register_status and fun_caves.set_status then
fun_caves.register_status({
name = 'breathe',
terminate = function(player)
if not player then
return
end
local player_name = player:get_player_name()
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'Your breathing becomes more difficult...'))
end,
})
local player_name = player:get_player_name()
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'Your breathing becomes more difficult...'))
end,
})
minetest.register_craftitem("fun_caves:elixir_breathe", {
description = 'Dr Robertson\'s Patented Easy Breathing Elixir',
inventory_image = "fun_caves_elixir_breathe.png",
on_use = function(itemstack, user, pointed_thing)
if not (itemstack and user) then
minetest.register_craftitem("fun_caves:elixir_breathe", {
description = 'Dr Robertson\'s Patented Easy Breathing Elixir',
inventory_image = "fun_caves_elixir_breathe.png",
on_use = function(itemstack, user, pointed_thing)
if not (itemstack and user) then
return
end
local player_name = user:get_player_name()
if not (player_name and type(player_name) == 'string' and player_name ~= '') then
return
end
fun_caves.set_status(player_name, 'breathe', elixir_duration)
minetest.chat_send_player(player_name, 'Your breathing becomes easier...')
itemstack:take_item()
return itemstack
end,
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_breathe',
recipe = {
'mobs_slimes:green_slimeball',
'fun_caves:coral_gem',
"vessels:glass_bottle",
},
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_breathe',
recipe = {
'fun_caves:syrup',
'fun_caves:coral_gem',
},
})
fun_caves.register_status({
name = 'damage_elixir',
terminate = function(player)
if not (player and fun_caves.db.status) then
return
end
local player_name = player:get_player_name()
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'You feel weaker...'))
fun_caves.db.status[player_name].damage_elixir = nil
end,
})
fun_caves.register_status({
name = 'armor_elixir',
terminate = function(player)
if not (player and fun_caves.db.status and fun_caves.display_armor) then
return
end
local player_name = player:get_player_name()
if not (player_name and type(player_name) == 'string' and player_name ~= '') then
return
end
local armor_elixir = fun_caves.db.status[player_name].armor_elixir
local factor = armor_elixir.factor
local armor = player:get_armor_groups()
if not (armor and armor.fleshy) then
return
end
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / factor)))
player:set_armor_groups(armor)
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'Your skin feels softer...'))
fun_caves.db.status[player_name].armor_elixir = nil
fun_caves.display_armor(player)
end,
})
if fun_caves.expire_elixir_on_death then
minetest.register_on_dieplayer(function(player)
if not (player and fun_caves.db.status and fun_caves.display_armor) then
return
end
local player_name = player:get_player_name()
if not (player_name and type(player_name) == 'string' and player_name ~= '') then
return
end
if fun_caves.db.status[player_name] and fun_caves.db.status[player_name].armor_elixir then
local factor = fun_caves.db.status[player_name].armor_elixir.factor
local armor = player:get_armor_groups()
if not (armor and armor.fleshy) then
return
end
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / factor)))
player:set_armor_groups(armor)
fun_caves.db.status[player_name].armor_elixir = nil
fun_caves.display_armor(player)
end
end)
end
local function increase_damage(user, bonus)
if not (user and fun_caves.set_status) then
return
end
@ -194,169 +301,117 @@ minetest.register_craftitem("fun_caves:elixir_breathe", {
return
end
fun_caves.set_status(player_name, 'breathe', elixir_duration)
minetest.chat_send_player(player_name, 'Your breathing becomes easier...')
itemstack:take_item()
return itemstack
end,
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_breathe',
recipe = {
'mobs_slimes:green_slimeball',
'fun_caves:coral_gem',
"vessels:glass_bottle",
},
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_breathe',
recipe = {
'fun_caves:syrup',
'fun_caves:coral_gem',
},
})
minetest.chat_send_player(player_name, 'You feel strong...')
fun_caves.set_status(player_name, 'damage_elixir', elixir_duration, {bonus = bonus})
end
fun_caves.register_status({
name = 'damage_elixir',
terminate = function(player)
if not player then
local function armor(user, factor)
if not (user and fun_caves.db.status and fun_caves.display_armor and fun_caves.set_status) then
return
end
local player_name = player:get_player_name()
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'You feel weaker...'))
fun_caves.db.status[player_name].damage_elixir = nil
end,
})
fun_caves.register_status({
name = 'armor_elixir',
terminate = function(player)
if not player then
return
end
local player_name = player:get_player_name()
local player_name = user:get_player_name()
if not (player_name and type(player_name) == 'string' and player_name ~= '') then
return
end
local armor_elixir = fun_caves.db.status[player_name].armor_elixir
local factor = armor_elixir.factor
local armor = player:get_armor_groups()
local armor = user:get_armor_groups()
if not (armor and armor.fleshy) then
return
end
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / factor)))
player:set_armor_groups(armor)
minetest.chat_send_player(player_name, minetest.colorize('#FF0000', 'Your skin feels softer...'))
fun_caves.db.status[player_name].armor_elixir = nil
fun_caves.display_armor(player)
end,
})
if fun_caves.expire_elixir_on_death then
minetest.register_on_dieplayer(function(player)
if not player then
return
if fun_caves.db.status[player_name].armor_elixir then
local old_factor = fun_caves.db.status[player_name].armor_elixir.factor
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / old_factor)))
end
local player_name = player:get_player_name()
if not (player_name and type(player_name) == 'string' and player_name ~= '') then
return
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy * factor)))
user:set_armor_groups(armor)
minetest.chat_send_player(player_name, 'Your skin feels harder...')
fun_caves.set_status(player_name, 'armor_elixir', elixir_duration, {factor = factor})
fun_caves.display_armor(user)
end
local descs = {
{'wood', 0.95, 'group:wood'},
{'stone', 0.9, 'group:stone'},
{'steel', 0.8, 'default:steel_ingot'},
{'copper', 0.85, 'default:copper_ingot'},
{'bronze', 0.7, 'default:bronze_ingot'},
{'gold', 0.6, 'default:gold_ingot'},
{'diamond', 0.5, 'default:diamond'},
{'silver', 0.4, 'fun_caves:silver_ingot'},
{'mese', 0.3, 'default:mese_crystal'},
--{'', 0.2, ''},
--{'adamant', 0.1, 'fun_caves:adamant'},
}
if fun_caves.elixir_armor then
for _, desc in pairs(descs) do
local name = desc[1]
local value = desc[2]
local cap = name:gsub('^%l', string.upper)
minetest.register_craftitem("fun_caves:liquid_"..name, {
description = 'Dr Robertson\'s Patented Liquid '..cap..' Elixir',
drawtype = "plantlike",
paramtype = "light",
tiles = {'fun_caves_liquid_'..name..'.png'},
inventory_image = 'fun_caves_liquid_'..name..'.png',
groups = {dig_immediate = 3, vessel = 1},
sounds = default.node_sound_glass_defaults(),
on_use = function(itemstack, user, pointed_thing)
if not (itemstack and user) then
return
end
armor(user, value)
itemstack:take_item()
return itemstack
end,
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:liquid_'..name,
recipe = {
'mobs_slimes:green_slimeball',
desc[3],
"vessels:glass_bottle",
},
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:liquid_'..name,
recipe = {
'fun_caves:syrup',
desc[3],
},
})
end
if fun_caves.db.status[player_name] and fun_caves.db.status[player_name].armor_elixir then
local factor = fun_caves.db.status[player_name].armor_elixir.factor
local armor = player:get_armor_groups()
if not (armor and armor.fleshy) then
return
end
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / factor)))
player:set_armor_groups(armor)
fun_caves.db.status[player_name].armor_elixir = nil
fun_caves.display_armor(player)
end
end)
end
local function increase_damage(user, bonus)
if not user then
return
end
local player_name = user:get_player_name()
if not (player_name and type(player_name) == 'string' and player_name ~= '') then
return
end
minetest.chat_send_player(player_name, 'You feel strong...')
fun_caves.set_status(player_name, 'damage_elixir', elixir_duration, {bonus = bonus})
end
local descs = {
{'boar', 2, 'fun_caves:meteorite'},
{'lion', 4, 'fun_caves:eternal_ice_crystal'},
{'grizzly', 6},
{'bull', 8},
{'rhino', 10},
{'elephant', 12},
}
local function armor(user, factor)
if not user then
return
end
local player_name = user:get_player_name()
if not (player_name and type(player_name) == 'string' and player_name ~= '') then
return
end
local armor = user:get_armor_groups()
if not (armor and armor.fleshy) then
return
end
if fun_caves.db.status[player_name].armor_elixir then
local old_factor = fun_caves.db.status[player_name].armor_elixir.factor
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy / old_factor)))
end
armor.fleshy = math.min(100, math.max(1, math.ceil(armor.fleshy * factor)))
user:set_armor_groups(armor)
minetest.chat_send_player(player_name, 'Your skin feels harder...')
fun_caves.set_status(player_name, 'armor_elixir', elixir_duration, {factor = factor})
fun_caves.display_armor(user)
end
local descs = {
{'wood', 0.95, 'group:wood'},
{'stone', 0.9, 'group:stone'},
{'steel', 0.8, 'default:steel_ingot'},
{'copper', 0.85, 'default:copper_ingot'},
{'bronze', 0.7, 'default:bronze_ingot'},
{'gold', 0.6, 'default:gold_ingot'},
{'diamond', 0.5, 'default:diamond'},
{'silver', 0.4, 'fun_caves:silver_ingot'},
{'mese', 0.3, 'default:mese_crystal'},
--{'', 0.2, ''},
--{'adamant', 0.1, 'fun_caves:adamant'},
}
if fun_caves.elixir_armor then
for _, desc in pairs(descs) do
local name = desc[1]
local value = desc[2]
local cap = name:gsub('^%l', string.upper)
minetest.register_craftitem("fun_caves:liquid_"..name, {
description = 'Dr Robertson\'s Patented Liquid '..cap..' Elixir',
local uname = name:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end)
local bonus = desc[2]
minetest.register_craftitem("fun_caves:elixir_strength_"..name, {
description = 'Dr Robertson\'s Patented '..uname..' Strength Elixir',
drawtype = "plantlike",
paramtype = "light",
tiles = {'fun_caves_liquid_'..name..'.png'},
inventory_image = 'fun_caves_liquid_'..name..'.png',
tiles = {'fun_caves_elixir_strength_'..name..'.png'},
inventory_image = 'fun_caves_elixir_strength_'..name..'.png',
groups = {dig_immediate = 3, vessel = 1},
sounds = default.node_sound_glass_defaults(),
on_use = function(itemstack, user, pointed_thing)
@ -364,84 +419,31 @@ if fun_caves.elixir_armor then
return
end
armor(user, value)
increase_damage(user, bonus)
itemstack:take_item()
return itemstack
end,
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:liquid_'..name,
recipe = {
'mobs_slimes:green_slimeball',
desc[3],
"vessels:glass_bottle",
},
})
if desc[3] then
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_strength_'..name,
recipe = {
'mobs_slimes:green_slimeball',
desc[3],
"vessels:glass_bottle",
},
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:liquid_'..name,
recipe = {
'fun_caves:syrup',
desc[3],
},
})
end
end
local descs = {
{'boar', 2, 'fun_caves:meteorite'},
{'lion', 4, 'fun_caves:eternal_ice_crystal'},
{'grizzly', 6},
{'bull', 8},
{'rhino', 10},
{'elephant', 12},
}
for _, desc in pairs(descs) do
local name = desc[1]
local uname = name:gsub("(%l)(%w*)", function(a,b) return string.upper(a)..b end)
local bonus = desc[2]
minetest.register_craftitem("fun_caves:elixir_strength_"..name, {
description = 'Dr Robertson\'s Patented '..uname..' Strength Elixir',
drawtype = "plantlike",
paramtype = "light",
tiles = {'fun_caves_elixir_strength_'..name..'.png'},
inventory_image = 'fun_caves_elixir_strength_'..name..'.png',
groups = {dig_immediate = 3, vessel = 1},
sounds = default.node_sound_glass_defaults(),
on_use = function(itemstack, user, pointed_thing)
if not (itemstack and user) then
return
end
increase_damage(user, bonus)
itemstack:take_item()
return itemstack
end,
})
if desc[3] then
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_strength_'..name,
recipe = {
'mobs_slimes:green_slimeball',
desc[3],
"vessels:glass_bottle",
},
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_strength_'..name,
recipe = {
'fun_caves:syrup',
desc[3],
},
})
minetest.register_craft({
type = "shapeless",
output = 'fun_caves:elixir_strength_'..name,
recipe = {
'fun_caves:syrup',
desc[3],
},
})
end
end
end

View file

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

View file

@ -61,7 +61,7 @@ local traps = {
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
end

View file

@ -399,6 +399,10 @@ local function generate(p_minp, p_maxp, seed)
local write = false
local write_p2, write_p4 = false, false
local underzone
if not fun_caves.underzones then
return
end
for _, uz in pairs(fun_caves.underzones) do
local avg = (minp.y + maxp.y) / 2
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
if minp.y > 17200 then
-- 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)
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)
elseif minp.y > 4000 then
elseif minp.y > 4000 and fun_caves.cloudgen then
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
fun_caves.fortress(minp, maxp, data, area, node)
write = true
else
elseif fun_caves.cavegen and fun_caves.decogen and fun_caves.treegen then
local write1, write2, write3, write4, write5, h2
write1, h2 = fun_caves.cavegen(minp, maxp, data, area, node, heightmap, underzone)
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)
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)
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]]
write5 = fun_caves.village(minp, maxp, data, p2data, area, node, biome, heightmap)
end
@ -475,15 +479,17 @@ local function generate(p_minp, p_maxp, seed)
end
dofile(fun_caves.path .. "/asteroids.lua")
dofile(fun_caves.path .. "/cavegen.lua")
dofile(fun_caves.path .. "/cloudgen.lua")
dofile(fun_caves.path .. "/decogen.lua")
dofile(fun_caves.path .. "/fortress.lua")
dofile(fun_caves.path .. "/pyramid.lua")
dofile(fun_caves.path .. "/treegen.lua")
dofile(fun_caves.path .. "/village.lua")
dofile(fun_caves.path .. "/skyseagen.lua")
if fun_caves.path then
dofile(fun_caves.path .. "/asteroids.lua")
dofile(fun_caves.path .. "/cavegen.lua")
dofile(fun_caves.path .. "/cloudgen.lua")
dofile(fun_caves.path .. "/decogen.lua")
dofile(fun_caves.path .. "/fortress.lua")
dofile(fun_caves.path .. "/pyramid.lua")
dofile(fun_caves.path .. "/treegen.lua")
dofile(fun_caves.path .. "/village.lua")
dofile(fun_caves.path .. "/skyseagen.lua")
end
-- 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)
end
dofile(fun_caves.path.."/zombie.lua")
dofile(fun_caves.path.."/goblin.lua")
dofile(fun_caves.path.."/demon.lua")
if fun_caves.path then
dofile(fun_caves.path.."/zombie.lua")
dofile(fun_caves.path.."/goblin.lua")
dofile(fun_caves.path.."/demon.lua")
end
fun_caves.fortress_spawns = {}
local t_mobs = {

View file

@ -1,7 +1,7 @@
local max_depth = 31000
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
end
@ -323,7 +323,7 @@ minetest.register_craft({
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
end
@ -394,7 +394,7 @@ local function trans_use(itemstack, user, pointed_thing)
end
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
end
@ -431,7 +431,7 @@ local function trans_place(itemstack, placer, pointed_thing)
end
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
end
@ -485,7 +485,7 @@ local function trans_dig(pos, node, digger)
end
local function trans_dest(pos)
if not pos then
if not (pos and fun_caves.db.translocators) then
return
end
@ -560,7 +560,7 @@ for _, gem in pairs(gems) do
end
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
end

View file

@ -182,7 +182,7 @@ newnode = fun_caves.clone_node("default:tree")
newnode.description = "Glowing Fungal Wood"
newnode.tiles = {"fun_caves_tree.png^vmg_glowing_fungal.png",}
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)

View file

@ -23,13 +23,15 @@ if mobs and mobs.mod == "redo" then
for i = 1, 5 do
food[#food+1] = 'default:grass_'..i
end
if farming then
for i = 5, 8 do
food[#food+1] = 'farming:wheat_'..i
end
end
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
end