Debug output made optional in settings

master
francisco athens 2022-02-13 15:33:07 -08:00
parent 26a2749bfc
commit 0b504e9cb4
10 changed files with 62 additions and 61 deletions

View File

@ -13,11 +13,11 @@ Witches inhabit the land! They are currently in development but, can already:
* Witches have magic! They will defend themselves and each other against aggressive players and mobs! * Witches have magic! They will defend themselves and each other against aggressive players and mobs!
* If you are repeatedly helpful to a witch... * If you are repeatedly helpful to a witch something good is likely to happen!
* New Witch cottage code with no additional mod requirements! * New Witch cottage code with no additional mod requirements!
* If Protection mod is available and enabled, Witches will no build in these areas! * If protector (or similar) mod is available and enabled, Witches will no build in these areas!
* Some cottages will spawn over a dungeon if they are near the surface * Some cottages will spawn over a dungeon if they are near the surface
@ -39,7 +39,7 @@ Witches inhabit the land! They are currently in development but, can already:
* Mobs Redo git repository: https://notabug.org/TenPlus1/mobs_redo * Mobs Redo git repository: https://notabug.org/TenPlus1/mobs_redo
## Optional Mods: ## Optional Mods:
* Protection to prevent Witches from placing cottages in protected areas! * protector (or similar) - to prevent Witches from placing cottages in protected areas!
* Any mobs from any mobs mod attacking Witches may be turned into a sheep! * Any mobs from any mobs mod attacking Witches may be turned into a sheep!

View File

@ -1,4 +1,5 @@
2022/02/12: Witches honor protected nodes ("protection" mod support) 2022/02/13: Debug output can be enabled from game Settings tab > All Settings > Mods > witches
2022/02/12: Witches honor protected nodes ("protector" mod support)
2020/08/10: Testing new cottage building code. 2020/08/10: Testing new cottage building code.
2020/08/06: Fixed witches not registered when handle_schematics is not loaded! D'oh! 2020/08/06: Fixed witches not registered when handle_schematics is not loaded! D'oh!
2020/08/01: Witches have two new wands from Damon and Simone! 2020/08/01: Witches have two new wands from Damon and Simone!

View File

@ -65,13 +65,13 @@ function witches.grounding(self,vol_vec,required_list,exception_list,replacement
local protected_area = minetest.is_area_protected(ck_pos1, ck_pos2, "", 2) local protected_area = minetest.is_area_protected(ck_pos1, ck_pos2, "", 2)
if #exceptions and #exceptions >= 1 then if #exceptions and #exceptions >= 1 then
print("exceptions count = "..#exceptions) witches.debug("exceptions count = "..#exceptions)
return return
elseif protected_area then elseif protected_area then
print("protected area found at "..mtpts(protected_area)) witches.debug("protected area found at "..mtpts(protected_area))
return return
else else
print("SUCCESS!".."pos1 = ".. mtpts(pos1).."pos2 = ".. mtpts(pos2)) witches.debug("SUCCESS!".."pos1 = ".. mtpts(pos1).."pos2 = ".. mtpts(pos2))
local volume = {pos1,pos2} local volume = {pos1,pos2}
local ck_volume = {ck_pos1,ck_pos2} local ck_volume = {ck_pos1,ck_pos2}
@ -366,10 +366,10 @@ function witches.generate_cottage(pos1,pos2,params)
--local door_pos= p_door_pos --local door_pos= p_door_pos
print("door: "..mts(door_pos)) witches.debug("door: "..mts(door_pos))
for k,v in pairs(door_pos) do for k,v in pairs(door_pos) do
print(mts(v)) witches.debug(mts(v))
local f_pos1 = vector.new(v) local f_pos1 = vector.new(v)
--get the offsets --get the offsets
f_pos1[v.fp[1] ] = f_pos1[v.fp[1] ] + v.fp[2] f_pos1[v.fp[1] ] = f_pos1[v.fp[1] ] + v.fp[2]
@ -418,7 +418,7 @@ function witches.generate_cottage(pos1,pos2,params)
local window_pos = {w ={},n={},e={},s={}} local window_pos = {w ={},n={},e={},s={}}
local az = math.floor((area.z-2)/2) local az = math.floor((area.z-2)/2)
local ax = math.floor((area.x-2)/2) local ax = math.floor((area.x-2)/2)
print("az/ax= "..az.." "..ax) witches.debug("az/ax= "..az.." "..ax)
for i=1, az do for i=1, az do
local wz = {x = ffpos1.x, z = ffpos1.z+math.random(2,area.z-2), y = ffpos1.y+2, p= "z", fp = {"x", 1} } local wz = {x = ffpos1.x, z = ffpos1.z+math.random(2,area.z-2), y = ffpos1.y+2, p= "z", fp = {"x", 1} }
table.insert(window_pos.w,wz) table.insert(window_pos.w,wz)
@ -431,18 +431,18 @@ function witches.generate_cottage(pos1,pos2,params)
local sx = {x = ffpos1.x+math.random(2,area.x-2), z = ffpos1.z, y = ffpos1.y+2, p= "x", fp = {"z", 1} } local sx = {x = ffpos1.x+math.random(2,area.x-2), z = ffpos1.z, y = ffpos1.y+2, p= "x", fp = {"z", 1} }
table.insert(window_pos.s,sx) table.insert(window_pos.s,sx)
end end
print(mts(window_pos)) witches.debug(mts(window_pos))
for k,v in pairs(door_pos) do for k,v in pairs(door_pos) do
--v is the door pos vector table --v is the door pos vector table
for i=v[v.p]+1,v[v.p]-1,-1 do --start with lateral axis (p) pos on either side of door for i=v[v.p]+1,v[v.p]-1,-1 do --start with lateral axis (p) pos on either side of door
print("doorpos "..v.p.." "..i) witches.debug("doorpos "..v.p.." "..i)
for j,_ in ipairs(window_pos[k]) do --we want the vector table value of each for j,_ in ipairs(window_pos[k]) do --we want the vector table value of each
print("windowpos "..mts(window_pos[k][j]).." vs "..i) witches.debug("windowpos "..mts(window_pos[k][j]).." vs "..i)
if window_pos[k][j] and i == window_pos[k][j][v.p] then if window_pos[k][j] and i == window_pos[k][j][v.p] then
print("windowpos "..window_pos[k][j][v.p].." vs "..i) witches.debug("windowpos "..window_pos[k][j][v.p].." vs "..i)
print("removing window_pos[k][j][v.p] = ".. mtpts(window_pos[k][j])) witches.debug("removing window_pos[k][j][v.p] = ".. mtpts(window_pos[k][j]))
--table.remove(window_pos[k],j) --table.remove(window_pos[k],j)
window_pos[k][j] = nil window_pos[k][j] = nil
end end
@ -457,7 +457,7 @@ function witches.generate_cottage(pos1,pos2,params)
for i=1,window_height do for i=1,window_height do
print("window set: "..mtpts(v)) witches.debug("window set: "..mtpts(v))
minetest.set_node({x= v.x, y=v.y-1+i, z=v.z},{ minetest.set_node({x= v.x, y=v.y-1+i, z=v.z},{
name=window_node name=window_node
}) })
@ -494,7 +494,7 @@ function witches.generate_cottage(pos1,pos2,params)
if math.random() < .5 then if math.random() < .5 then
local ck = minetest.get_node(ck_pos1) local ck = minetest.get_node(ck_pos1)
print("ck: "..ck.name) witches.debug("ck: "..ck.name)
if ck.name ~= window_node then if ck.name ~= window_node then
minetest.set_node(t_pos1,{ minetest.set_node(t_pos1,{
name="default:torch_wall", name="default:torch_wall",
@ -505,7 +505,7 @@ function witches.generate_cottage(pos1,pos2,params)
end end
else else
local ck = minetest.get_node(ck_pos2) local ck = minetest.get_node(ck_pos2)
print("ck: "..ck.name) witches.debug("ck: "..ck.name)
if ck.name ~= window_node then if ck.name ~= window_node then
minetest.set_node(t_pos2,{ minetest.set_node(t_pos2,{
name="default:torch_wall", name="default:torch_wall",
@ -529,8 +529,8 @@ function witches.generate_cottage(pos1,pos2,params)
f_pos1[v.fp[1] ] = f_pos1[v.fp[1] ]+v.fp[2] f_pos1[v.fp[1] ] = f_pos1[v.fp[1] ]+v.fp[2]
f_pos1.y = f_pos1.y-1 f_pos1.y = f_pos1.y-1
print("window:"..mtpts(v)) witches.debug("window:"..mtpts(v))
print("furniture:"..mtpts(f_pos1)) witches.debug("furniture:"..mtpts(f_pos1))
local dir1=vector.direction(f_pos1,v) local dir1=vector.direction(f_pos1,v)
local dir2=vector.direction(v,f_pos1) local dir2=vector.direction(v,f_pos1)
local f_facedir1 = minetest.dir_to_facedir(dir1) local f_facedir1 = minetest.dir_to_facedir(dir1)
@ -555,8 +555,8 @@ function witches.generate_cottage(pos1,pos2,params)
paramtype2 = "facedir", paramtype2 = "facedir",
param2 = f_facedir2 param2 = f_facedir2
}) })
print("bed1:"..mtpts(f_pos1)) witches.debug("bed1:"..mtpts(f_pos1))
print("bed2:"..mtpts(f_pos2)) witches.debug("bed2:"..mtpts(f_pos2))
minetest.set_node(f_pos2,{ minetest.set_node(f_pos2,{
name=f_name, name=f_name,
paramtype2 = "facedir", paramtype2 = "facedir",
@ -793,7 +793,7 @@ local stovepipe_pos = {}
end end
end end
print("ladder l_pos: "..mts(l_pos)) witches.debug("ladder l_pos: "..mts(l_pos))
--extend the stovepipe --extend the stovepipe
if furnace_pos and furnace_pos.x then if furnace_pos and furnace_pos.x then
--print("furnace pos: "..mtpts(furnace_pos)) --print("furnace pos: "..mtpts(furnace_pos))
@ -809,7 +809,7 @@ local stovepipe_pos = {}
end end
--drop a ladder from the center of the gable, avoiding any doors or windows --drop a ladder from the center of the gable, avoiding any doors or windows
print("door: ".. mts(door_pos)) witches.debug("door: ".. mts(door_pos))
if door_pos and l_pos then if door_pos and l_pos then
for _,d in pairs(door_pos) do for _,d in pairs(door_pos) do
for k,l in pairs(l_pos) do for k,l in pairs(l_pos) do
@ -824,10 +824,10 @@ local stovepipe_pos = {}
for v,_ in pairs(window_pos) do for v,_ in pairs(window_pos) do
for _,w in ipairs(window_pos[v]) do for _,w in ipairs(window_pos[v]) do
for k,l in pairs(l_pos) do for k,l in pairs(l_pos) do
print("possible window before check: ".. mtpts(w)) witches.debug("possible window before check: ".. mtpts(w))
print("possible ladder before check: ".. mtpts(l)) witches.debug("possible ladder before check: ".. mtpts(l))
if math.ceil(l.x) == w.x and math.ceil(l.z) == w.z then if math.ceil(l.x) == w.x and math.ceil(l.z) == w.z then
print("removing".. mtpts(l_pos[k])) witches.debug("removing".. mtpts(l_pos[k]))
table.remove(l_pos,k) table.remove(l_pos,k)
end end
end end
@ -835,7 +835,7 @@ local stovepipe_pos = {}
end end
end end
print("possible ladder: ".. mts(l_pos)) witches.debug("possible ladder: ".. mts(l_pos))
if l_pos and #l_pos >= 1 then if l_pos and #l_pos >= 1 then
local lpn = math.random(#l_pos) local lpn = math.random(#l_pos)
@ -850,7 +850,7 @@ local stovepipe_pos = {}
local dir1=vector.direction(fpos,lpc) local dir1=vector.direction(fpos,lpc)
local dir1_wm = minetest.dir_to_wallmounted(dir1) local dir1_wm = minetest.dir_to_wallmounted(dir1)
print("ladder chosen: ".. mts(lpc)) witches.debug("ladder chosen: ".. mts(lpc))
lpc[ lpc.fp[1] ] = lpc[ lpc.fp[1] ] + lpc.fp[2] lpc[ lpc.fp[1] ] = lpc[ lpc.fp[1] ] + lpc.fp[2]
--l_pos.y = l_pos.y-1 --l_pos.y = l_pos.y-1
@ -863,18 +863,18 @@ local stovepipe_pos = {}
end end
print("ladder: "..mtpts(lpc)) witches.debug("ladder: "..mtpts(lpc))
else else
local loftpos1 = {x= sfpos1.x+2, y = sfpos1.y+1, z=sfpos1.z+1} local loftpos1 = {x= sfpos1.x+2, y = sfpos1.y+1, z=sfpos1.z+1}
local loftpos2 = {x= sfpos2.x-2, y = sfpos1.y+1, z=sfpos2.z-1} local loftpos2 = {x= sfpos2.x-2, y = sfpos1.y+1, z=sfpos2.z-1}
local loftarea = vector.subtract(loftpos2,loftpos1) local loftarea = vector.subtract(loftpos2,loftpos1)
print(dump(loftpos1)) witches.debug(dump(loftpos1))
print(dump(loftpos2)) witches.debug(dump(loftpos2))
print(dump(loftarea)) witches.debug(dump(loftarea))
for i=1, loftarea.z+1 do for i=1, loftarea.z+1 do
for j=1, loftarea.x+1 do for j=1, loftarea.x+1 do
local pos = {x= loftpos1.x-1 + j, y = loftpos1.y, z = loftpos1.z-1 + i} local pos = {x= loftpos1.x-1 + j, y = loftpos1.y, z = loftpos1.z-1 + i}
print(mts(pos)) witches.debug(mts(pos))
minetest.set_node(pos, {name = "air"}) minetest.set_node(pos, {name = "air"})
end end
end end

View File

@ -1,6 +1,6 @@
default default
mobs mobs
handle_schematics? protector?
fireflies? fireflies?
mobs_monster? mobs_monster?
doors? doors?

View File

@ -5,7 +5,7 @@
local path = minetest.get_modpath("witches") local path = minetest.get_modpath("witches")
witches = {} witches = {}
witches.version = "20220212" witches.version = "20220213"
print("This is Witches "..witches.version.."!") print("This is Witches "..witches.version.."!")
-- Strips any kind of escape codes (translation, colors) from a string -- Strips any kind of escape codes (translation, colors) from a string
@ -41,12 +41,20 @@ local function print_s(input)
end end
local S = minetest.get_translator("witches") local S = minetest.get_translator("witches")
local settings = minetest.settings
function witches.debug(input)
local witches_debug = settings:get_bool("witches_debug")
if witches_debug then
print_s(input)
end
end
local witches_version = witches.version local witches_version = witches.version
if mobs.version then if mobs.version then
if tonumber(mobs.version) >= tonumber(20200516) then if tonumber(mobs.version) >= tonumber(20200516) then
print_s(S("Mobs Redo 20200516 or greater found!")) print_s(S("Mobs Redo 20200516 or greater found! ("..mobs.version..")"))
else else
print_s(S("You should find a more recent version of Mobs Redo!")) print_s(S("You should find a more recent version of Mobs Redo!"))
print_s(S("https://notabug.org/TenPlus1/mobs_redo")) print_s(S("https://notabug.org/TenPlus1/mobs_redo"))
@ -87,7 +95,7 @@ function witches.generate(witch_types,witch_template)
g_template[x] = g_type[x] g_template[x] = g_type[x]
end end
print_s("Registering the "..g_template.description..": witches:witch_"..k) witches.debug("Registering the "..g_template.description..": witches:witch_"..k)
if g_template.lore then print_s(" "..g_template.lore) end if g_template.lore then print_s(" "..g_template.lore) end
--print_s("resulting template: " ..dump(g_template)) --print_s("resulting template: " ..dump(g_template))
mobs:register_mob("witches:witch_"..k, g_template) mobs:register_mob("witches:witch_"..k, g_template)

View File

@ -54,7 +54,7 @@ minetest.register_entity("witches:witch_tool_wand_sp",witch_tool_wand_sp)
minetest.register_tool("witches:witch_wand_btb", { minetest.register_tool("witches:witch_wand_btb", {
description = "Better Thank Bacon!", description = "Better Than Bacon!",
inventory_image = "witches_wand_better_than_bacon.png", inventory_image = "witches_wand_better_than_bacon.png",
tool_capabilities = { tool_capabilities = {
full_punch_interval = 1.2, full_punch_interval = 1.2,

View File

@ -1,4 +1,4 @@
name = witches name = witches
descriptions = adds witches and their cottages descriptions = adds witches and their cottages
depends = default, mobs depends = default, mobs
optional_depends = protection optional_depends = protector

View File

@ -1,16 +1,8 @@
#maximum number of houses per mapchunk # debug mode
witches_house_max_per_mapchunk (maximum number of houses per mapchunk) int 2 witches_debug (enable debug) bool false
#average number of houses to mapchunks over the world
witches_houses_wanted_per_mapchunk (average number of houses to mapchunks over the world) float .05
# chance (1-99) of a witch house spawning over a dungeon instead of anywhere else (requires Sokomines handle_schematics mod!)
witches_dungeon_cellar_chance (chance as decimal like .5 of a witch house spawning over a dungeon instead of anywhere else) float .5
# depth (1-20) maximum depth of a dungeon to spawn a witch house over (requires Sokomines handle_schematics mod!)
witches_dungeon_cellar_depth (maximum depth 0 to -20 of a dungeon to spawn a witch house over) int -5

View File

@ -44,7 +44,7 @@ local function quest_dialogs(self)
S("Why must my task require the @1? ",self.item_request.item.desc), S("Why must my task require the @1? ",self.item_request.item.desc),
S("Is it so difficult to find the @1? ",self.item_request.item.desc), S("Is it so difficult to find the @1? ",self.item_request.item.desc),
S("Wherefor about this land art the @1? ",self.item_request.item.desc), S("Wherefor about this land art the @1? ",self.item_request.item.desc),
S("Must there be but a few of the @1 about? ",self.item_request.item.desc), S("Must not there be but a few of the @1 about? ",self.item_request.item.desc),
S("Could I trouble you for some kind of @1? ",self.item_request.item.desc), S("Could I trouble you for some kind of @1? ",self.item_request.item.desc),
S("The @1 would make my collection complete! ",self.item_request.item.desc), S("The @1 would make my collection complete! ",self.item_request.item.desc),
S("I sense the @1 are not far away...",self.item_request.item.desc), S("I sense the @1 are not far away...",self.item_request.item.desc),
@ -234,11 +234,11 @@ end
function witches.gift(self, pname, drop_chance_min, drop_chance_max, item_wear ) function witches.gift(self, pname, drop_chance_min, drop_chance_max, item_wear )
if not pname then if not pname then
print("no player defined!") witches.debug("no player defined!")
return return
end end
if not self.drops then if not self.drops then
print("no droplist defined in this mob!") witches.debug("no droplist defined in this mob!")
return return
end end
local list = {} local list = {}
@ -355,7 +355,7 @@ function witches.claim_witches_chest(self)
-- if sn then print(sn) end -- if sn then print(sn) end
local o = meta:get_string("owner") local o = meta:get_string("owner")
if o and sn and sn == o then if o and sn and sn == o then
print("unbound chest: "..sn) witches.debug("unbound chest: "..sn)
meta:set_string("owner", self.secret_name) meta:set_string("owner", self.secret_name)
meta:set_string("infotext", self.secret_name.."'s sealed chest of ".. sn) meta:set_string("infotext", self.secret_name.."'s sealed chest of ".. sn)
@ -523,7 +523,7 @@ function witches.quests(self, clicker)
if var1 == var2 then if var1 == var2 then
self.dev_mode = pname self.dev_mode = pname
print("dev mode active for: "..pname) witches.debug("dev mode active for: "..pname)
end end
--print("we are holding a "..dump(item:get_name())) --print("we are holding a "..dump(item:get_name()))

View File

@ -17,7 +17,7 @@ local spawning = {
day_toggle = nil, day_toggle = nil,
on_spawn = function(self) on_spawn = function(self)
local pos = self.object:get_pos() local pos = self.object:get_pos()
print(self.secret_name.." spawned at ".. minetest.pos_to_string(vector.round(pos))) witches.debug(self.secret_name.." spawned at ".. minetest.pos_to_string(vector.round(pos)))
end, end,
}, },
@ -34,7 +34,7 @@ local spawning = {
day_toggle = nil, day_toggle = nil,
on_spawn = function(self) on_spawn = function(self)
local pos = self.object:get_pos() local pos = self.object:get_pos()
print(self.secret_name.." spawned at ".. minetest.pos_to_string(vector.round(pos))) witches.debug(self.secret_name.." spawned at ".. minetest.pos_to_string(vector.round(pos)))
end end
@ -88,7 +88,7 @@ witches.witch_types = {
local volume = witches.grounding(self) local volume = witches.grounding(self)
if volume then if volume then
print("volume passed: "..dump(volume)) witches.debug("volume passed: "..dump(volume))
local pos = self.object:get_pos() local pos = self.object:get_pos()
pos.y = pos.y+3 pos.y = pos.y+3
@ -296,7 +296,7 @@ witches.witch_template = { --your average witch,
--self.item_request.text = witches.generate_name(witches.quest_dialogs, {"item_request"}) --self.item_request.text = witches.generate_name(witches.quest_dialogs, {"item_request"})
--print(self.secret_name.." has spawned") --print(self.secret_name.." has spawned")
--print("self: "..dump(self.follow)) --print("self: "..dump(self.follow))
-- print("self properties "..dump(self.object:get_properties())) --print("self properties "..dump(self.object:get_properties()))
--self.follow = {} --self.follow = {}
if not self.follow or #self.follow < 1 or type(self.follow) == string then if not self.follow or #self.follow < 1 or type(self.follow) == string then
self.follow = {} self.follow = {}