fix debug crash in older MT (5.4)
parent
fb789e0848
commit
8ef4130bd5
44
cottages.lua
44
cottages.lua
|
@ -35,8 +35,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
|||
|
||||
if dg and dg.dungeon and #dg.dungeon > 1 then
|
||||
local cur_dg = vector.new(dg.dungeon[#dg.dungeon])
|
||||
witches.debug("dungeon registered of size " .. #dg.dungeon .. " at " ..
|
||||
vector.to_string(cur_dg))
|
||||
witches.debug("dungeon registered of size " .. #dg.dungeon .. " at " ..minetest.pos_to_string(cur_dg))
|
||||
-- check depth
|
||||
local mindd = dungeon_cellar_depth_min or 2
|
||||
local maxdd = dungeon_cellar_depth_max or 5 -- max dungeon depth
|
||||
|
@ -52,12 +51,12 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
|
|||
table.insert(dungeons, vector.new(cur_dg))
|
||||
-- print(#dungeons)
|
||||
end
|
||||
witches.debug("current: " .. vector.to_string(cur_dg))
|
||||
witches.debug("last: " .. vector.to_string(dungeons[#dungeons]))
|
||||
witches.debug("current: " .. minetest.pos_to_string(cur_dg))
|
||||
witches.debug("last: " .. minetest.pos_to_string(dungeons[#dungeons]))
|
||||
local distance = vector.distance(cur_dg, dungeons[#dungeons])
|
||||
if distance > 50 and air_check and #air_check >= 20 and #air_check - 20 >
|
||||
mindd then
|
||||
-- print("Distance: "..math.round(distance).." new surface dungeon (" ..#dungeons..") found at" ..(vector.to_string(cur_dg)))
|
||||
-- print("Distance: "..math.round(distance).." new surface dungeon (" ..#dungeons..") found at" ..(minetest.pos_to_string(cur_dg)))
|
||||
local surface = vector.new(vector.add(pos_ck, vector.new(0, 20 +
|
||||
maxdd -
|
||||
#air_check,
|
||||
|
@ -130,7 +129,7 @@ function witches.grounding(pos, vol_vec, required_list, exception_list,
|
|||
|
||||
if #exceptions and #exceptions >= 1 then
|
||||
|
||||
witches.debug("exceptions count = " .. #exceptions.." at "..vector.to_string(pos))
|
||||
witches.debug("exceptions count = " .. #exceptions.." at "..minetest.pos_to_string(pos))
|
||||
return
|
||||
elseif protected_area then
|
||||
witches.debug("protected area found at " .. mtpts(protected_area))
|
||||
|
@ -201,7 +200,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
|
|||
pos1 = vector.round(pos1)
|
||||
pos2 = vector.round(pos2)
|
||||
local wp = working_parameters
|
||||
local witch_spawn_pos ={}
|
||||
local witch_spawn_pos = {}
|
||||
|
||||
if params then -- get defaults for any missing params
|
||||
-- print("default params: "..minetest.serialize(default_params))
|
||||
|
@ -802,12 +801,12 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
|
|||
meta:set_string("infotext",
|
||||
"Sealed chest of " .. secret_name)
|
||||
else
|
||||
meta:set_string("owner", vector.to_string(f_pos1))
|
||||
meta:set_string("secret_name", vector.to_string(f_pos1))
|
||||
meta:set_string("owner", minetest.pos_to_string(f_pos1))
|
||||
meta:set_string("secret_name", minetest.pos_to_string(f_pos1))
|
||||
meta:set_string("infotext",
|
||||
"This chest is magically sealed!")
|
||||
witches.debug("Unclaimed chest: "..vector.to_string(f_pos1))
|
||||
witch_spawn_pos = f_pos1
|
||||
witches.debug("Unclaimed chest: "..minetest.pos_to_string(f_pos1))
|
||||
witch_spawn_pos = vector.new(f_pos1)
|
||||
end
|
||||
|
||||
if minetest.get_modpath("fireflies") then
|
||||
|
@ -829,7 +828,7 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
|
|||
minetest.set_node(f_pos1, {
|
||||
name = f_name,
|
||||
paramtype2 = "facedir",
|
||||
param2 = f_facedir1
|
||||
param2 = f_facedir1
|
||||
})
|
||||
if mr(1,2) == 1 then
|
||||
witches.debug("placing bottle!")
|
||||
|
@ -1251,20 +1250,19 @@ function witches.generate_cottage(pos1, pos2, params, secret_name)
|
|||
local cottage_va = VoxelArea:new{MinEdge = c_area1, MaxEdge = c_area2}
|
||||
-- print(mts(VoxelArea))
|
||||
|
||||
witches.debug("Attempting spawning cottage witch")
|
||||
--minetest.add_entity(minetest.find_node_near(f_pos1, 3, "air"), "witches:witch_cottage")
|
||||
if witch_spawn_pos and mobs:add_mob(minetest.find_node_near(witch_spawn_pos, 3, "air"),{
|
||||
name = "witches:witch_cottage",
|
||||
ignore_count = true
|
||||
})
|
||||
then
|
||||
witches.debug("SUCCESS: spawning cottage witch")
|
||||
else
|
||||
witches.debug("FAILED: spawning cottage witch"..vector.to_string(witch_spawn_pos))
|
||||
|
||||
if witch_spawn_pos and mobs:add_mob(witch_spawn_pos,{
|
||||
name = "witches:witch_cottage",
|
||||
ignore_count = true
|
||||
})
|
||||
then
|
||||
witches.debug("SUCCESS: spawning cottage witch")
|
||||
else
|
||||
witches.debug("FAILED: spawning cottage witch"..minetest.pos_to_string(witch_spawn_pos))
|
||||
|
||||
end
|
||||
|
||||
return l_pos
|
||||
--return witches_spawn_pos
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -161,11 +161,18 @@ function witches.special_gifts(self, pname, drop_chance, max_drops)
|
|||
if not drop_chance then drop_chance = 1000 end
|
||||
if not max_drops then max_drops = 1 end
|
||||
local rares = {}
|
||||
local drop_num = 1
|
||||
|
||||
for k, v in pairs(self.drops) do
|
||||
-- print_s(dump(v.name).." and "..dump(v.chance))
|
||||
if v.chance >= drop_chance then
|
||||
table.insert(rares, v.name)
|
||||
end
|
||||
if v.max and v.min and v.max > 1 then
|
||||
----NEED TO FIX THIS :P
|
||||
drop_num = math.random(v.min,v.max)
|
||||
max_drops = drop_num
|
||||
end
|
||||
end
|
||||
if #rares > 0 then
|
||||
-- print_s("rares = "..dump(rares))
|
||||
|
@ -187,8 +194,9 @@ function witches.special_gifts(self, pname, drop_chance, max_drops)
|
|||
})
|
||||
--]]
|
||||
local item_wear = math.random(8000, 10000)
|
||||
local stack = ItemStack({name = v, wear = item_wear})
|
||||
local stack = ItemStack({name = v, wear = item_wear })
|
||||
local org_desc = minetest.registered_items[v].description
|
||||
stack:set_count(drop_num)
|
||||
local meta = stack:get_meta()
|
||||
-- boost the stats!
|
||||
local capabilities = stack:get_tool_capabilities()
|
||||
|
@ -243,14 +251,16 @@ function witches.special_gifts(self, pname, drop_chance, max_drops)
|
|||
})
|
||||
local reward_text = {}
|
||||
local reward = {}
|
||||
|
||||
for i, _ in pairs(inv:get_lists()) do
|
||||
-- print(i.." = "..dump(v))
|
||||
if i == "main" and stack and inv:room_for_item(i, stack) then
|
||||
reward_text =
|
||||
S("You are rewarded with @1",
|
||||
meta:get_string("description"))
|
||||
S("You are rewarded with @1 @2",
|
||||
drop_num, meta:get_string("description"))
|
||||
-- print("generated text: "..reward_text)
|
||||
local reward_item = stack:get_name()
|
||||
stack:set_count(drop_num)
|
||||
-- print("generated:"..stack:get_name())
|
||||
reward = {
|
||||
r_text = reward_text,
|
||||
|
@ -261,13 +271,13 @@ function witches.special_gifts(self, pname, drop_chance, max_drops)
|
|||
end
|
||||
end
|
||||
reward_text = S(
|
||||
"You are rewarded with @1, but you cannot carry it",
|
||||
meta:get_string("description"))
|
||||
"You are rewarded with @1 @2, but you cannot carry it",
|
||||
drop_num, meta:get_string("description"))
|
||||
-- print("generated text: "..reward_text)
|
||||
local reward_item = stack:get_name()
|
||||
-- print("generated:"..stack:get_name())
|
||||
reward = {r_text = reward_text, r_item = reward_item}
|
||||
minetest.add_item(pos, stack)
|
||||
minetest.add_item(pos, stack )
|
||||
-- print("generated text: "..reward_text)
|
||||
return reward
|
||||
end
|
||||
|
|
20
witches.lua
20
witches.lua
|
@ -5,14 +5,14 @@ local hair_colors = witches.hair_colors
|
|||
|
||||
local spawning = {
|
||||
cottage = {
|
||||
nodes = {"group:wood", "default:mossycobble", "default:cobble"},
|
||||
neighbors = {"air", "witches:chest_locked", "doors:wood_witch_a"},
|
||||
nodes = {"witches:chest_locked", "doors:wood_witch_a"},
|
||||
neighbors = {"air", },
|
||||
min_light = 5,
|
||||
max_light = 15,
|
||||
interval = 100,
|
||||
chance = 500,
|
||||
interval = 30,
|
||||
chance = 1000,
|
||||
active_object_count = 2,
|
||||
min_height = 0,
|
||||
min_height = -10,
|
||||
max_height = 200,
|
||||
day_toggle = nil,
|
||||
on_spawn = function(self)
|
||||
|
@ -24,14 +24,14 @@ local spawning = {
|
|||
},
|
||||
|
||||
generic = {
|
||||
nodes = {"group:wood", "default:mossycobble", "default:cobble"},
|
||||
neighbors = {"air", "default:chest"},
|
||||
nodes = {"group:wood", "default:mossycobble", },
|
||||
neighbors = {"air"},
|
||||
min_light = 5,
|
||||
max_light = 15,
|
||||
interval = 300,
|
||||
interval = 30,
|
||||
chance = 1000,
|
||||
active_object_count = 1,
|
||||
min_height = 0,
|
||||
min_height = -10,
|
||||
max_height = 200,
|
||||
day_toggle = nil,
|
||||
on_spawn = function(self)
|
||||
|
@ -103,7 +103,7 @@ witches.witch_types = {
|
|||
|
||||
cottage_builder = {
|
||||
description = "Eremitant Artifician",
|
||||
lore = "The Eremitant have found homes for themselves, who would bother them?",
|
||||
lore = "The Eremitant Artificians scout the land for dungeons upon which their cottages may be built",
|
||||
additional_properties = {
|
||||
special_follow = {
|
||||
"default:diamond", "default:gold_lump", "default:apple",
|
||||
|
|
Loading…
Reference in New Issue