Remove logging and clean up

This commit is contained in:
ancientmarinerdev 2023-03-16 20:22:52 +00:00 committed by Gitea
parent e7449a65d8
commit bd579314ba
2 changed files with 49 additions and 78 deletions

View File

@ -662,7 +662,9 @@ local function spawn_check(pos, spawn_def)
local mob_type = mob_def.type
local gotten_node = get_node(pos).name
local gotten_biome = minetest.get_biome_data(pos)
if not gotten_node or not gotten_biome then return end
gotten_biome = get_biome_name(gotten_biome.biome) --makes it easier to work with
local is_ground = minetest.get_item_group(gotten_node,"solid") ~= 0
@ -683,27 +685,32 @@ local function spawn_check(pos, spawn_def)
and spawn_def.dimension == dimension
and biome_check(spawn_def.biomes, gotten_biome) then
--minetest.log("Level 1 spawn check passed")
--mcl_log("Level 1 spawn check passed")
--minetest.log("Mob: " .. mob_def.name)
minetest.log("Mob: " .. mob_def.name)
if (is_ground or spawn_def.type_of_spawning ~= "ground")
and (spawn_def.type_of_spawning ~= "ground" or not is_leaf)
and has_room(mob_def,pos)
and (spawn_def.check_position and spawn_def.check_position(pos) or spawn_def.check_position == nil)
and (not is_farm_animal(spawn_def.name) or is_grass)
and (spawn_def.type_of_spawning ~= "water" or is_water)
and ( not spawn_protected or not minetest.is_protected(pos, "") )
and not is_bedrock then
and not is_bedrock
and has_room(mob_def,pos)
and (spawn_def.check_position and spawn_def.check_position(pos) or spawn_def.check_position == nil)
and ( not spawn_protected or not minetest.is_protected(pos, "") ) then
minetest.log("Level 2 spawn check passed")
--mcl_log("Level 2 spawn check passed")
--only need to poll for node light if everything else worked
local gotten_light = get_node_light(pos)
if gotten_light >= spawn_def.min_light and gotten_light <= spawn_def.max_light then
minetest.log("Level 3 spawn check passed")
--mcl_log("Level 3 spawn check passed")
return true
else
mcl_log("Spawn check level 3 failed")
end
else
mcl_log("Spawn check level 2 failed")
end
else
mcl_log("Spawn check level 1 failed")
end
return false
end
@ -1024,7 +1031,7 @@ if mobs_spawn then
end
end
else
mcl_log("Spawn check failed")
--mcl_log("Spawn check failed")
end
else
mcl_log("Cap space full")

View File

@ -81,57 +81,33 @@ end
local seed = minetest.get_mapgen_setting("seed")
--local chunk_size = minetest.get_mapgen_setting("chunksize")
local MAPBLOCK_SIZE = 16
--local MAPBLOCK_SIZE = 3 * chunk_size
local slime_chunk_match
local x_modifier
local z_modifier
--Seed: "16002933932875202103"
--Seed: "16002933932875202103" == random seed
--Seed: "1807191622654296300" == cheese
--Seed: "1" = 1
local function process_seed (seed)
--minetest.log("chunk_size: " .. chunk_size)
minetest.log("seed: " .. seed)
--minetest.log("seed: " .. seed)
local split_chars = split_by_char(tostring(seed), nil, 10)
minetest.log("Number of chars: " .. tostring(#split_chars))
--minetest.log("Number of chars: " .. tostring(#split_chars))
slime_chunk_match = split_chars[1]
x_modifier = split_chars[2]
z_modifier = split_chars[3]
minetest.log("x_modifier: " .. tostring(x_modifier))
minetest.log("z_modifier: " .. tostring(z_modifier))
minetest.log("slime_chunk_match: " .. tostring(slime_chunk_match))
-- floor(x_or_z / chunk_size) + modifier
--minetest.log("x_modifier: " .. tostring(x_modifier))
--minetest.log("z_modifier: " .. tostring(z_modifier))
--minetest.log("slime_chunk_match: " .. tostring(slime_chunk_match))
end
local processed = process_seed (seed)
--process_seed (seed)
-- Seed numbers are 0 - 9. Adding 1, and doubling it converts this to 2 - 20 (even numbers).
-- This averages at roughly 10, so 1 in 10 chunks, or 10% is how frequent slime chunks are
-- We then multiply by chunk_size * 1.8 (8) to map to co-ords, because if the lowest value is 2, then multiplied by 8 gives a chunk size of 16
-- 2 * 8 = 16
-- 4 * 8 = 32
-- 6 * 8 = 48
local function convert_to_chunk_value_old (input)
local total = 0
if input then
for _, v in pairs(input) do
v = (v + 1) * 2 * chunk_size * 1.8
total = total + v
minetest.log("v: " .. tostring(v))
end
end
minetest.log("total: " .. tostring(total))
minetest.log("average: " .. tostring(total/10))
end
local MAPBLOCK_SIZE = 16
--local MAPBLOCK_SIZE = 3 * chunk_size
local function convert_to_chunk_value (co_ord, modifier)
local converted = math.floor(math.abs(co_ord) / MAPBLOCK_SIZE)
@ -139,13 +115,13 @@ local function convert_to_chunk_value (co_ord, modifier)
if modifier then
converted = (converted + modifier) % 10
minetest.log("with modifier: " .. converted)
--minetest.log("with modifier: " .. converted)
else
minetest.log("converted: " .. converted)
--minetest.log("converted: " .. converted)
end
converted = converted % 10
minetest.log("converted: " .. converted)
--minetest.log("converted: " .. converted)
return converted
end
@ -164,22 +140,9 @@ assert(convert_to_chunk_value(1600) == 0, "Incorrect convert_to_chunk_value resu
assert(convert_to_chunk_value(0,9) == 9, "Incorrect convert_to_chunk_value result")
assert(convert_to_chunk_value(16,5) == 6, "Incorrect convert_to_chunk_value result")
assert(convert_to_chunk_value(1599,4) == 3, "Incorrect convert_to_chunk_value result")
-- 0, -1, -15
-- convert_to_chunk_value_2(0)
--[[
convert_to_chunk_value(-16)
convert_to_chunk_value(-15)
convert_to_chunk_value(-14)
convert_to_chunk_value(-1)
convert_to_chunk_value(0)
convert_to_chunk_value(1)
convert_to_chunk_value(14)
convert_to_chunk_value(15)
convert_to_chunk_value(16)
convert_to_chunk_value(29)
convert_to_chunk_value(30)
convert_to_chunk_value(31)
convert_to_chunk_value(1500,9)
convert_to_chunk_value(1501,9)
convert_to_chunk_value(1516,9)
@ -190,7 +153,6 @@ convert_to_chunk_value(1649,9)
local function calculate_chunk_value (pos, x_mod, z_mod)
local chunk_val = math.abs(convert_to_chunk_value(pos.x, x_mod) - convert_to_chunk_value(pos.z, z_mod)) % 10
minetest.log("chunk_val: " .. tostring(chunk_val))
return chunk_val
end
@ -209,29 +171,31 @@ assert(calculate_chunk_value(vector.new(-160,0,-160)) == 0, "calculate_chunk_val
local function is_slime_chunk(pos)
if not pos then return end
minetest.log("x: " ..pos.x .. ", z:" .. pos.z)
--minetest.log("x: " ..pos.x .. ", z:" .. pos.z)
local chunk_val = calculate_chunk_value (pos, x_modifier, z_modifier)
local slime_chunk = chunk_val == slime_chunk_match
minetest.log("Is slime chunk: " .. tostring(slime_chunk))
--minetest.log("seed slime_chunk_match: " .. tostring(slime_chunk_match))
--minetest.log("chunk_val: " .. tostring(chunk_val))
--minetest.log("Is slime chunk: " .. tostring(slime_chunk))
return slime_chunk
end
is_slime_chunk(vector.new(64,0,16))
is_slime_chunk(vector.new(16,0,64))
is_slime_chunk(vector.new(0,0,16))
is_slime_chunk(vector.new(15,0,31))
is_slime_chunk(vector.new(32,0,32))
is_slime_chunk(vector.new(15,0,15))
is_slime_chunk(vector.new(0,0,0))
is_slime_chunk(vector.new(-150,0,-150))
--is_slime_chunk(vector.new(64,0,16))
--is_slime_chunk(vector.new(16,0,64))
--is_slime_chunk(vector.new(0,0,16))
--is_slime_chunk(vector.new(15,0,31))
--is_slime_chunk(vector.new(32,0,32))
--is_slime_chunk(vector.new(15,0,15))
--is_slime_chunk(vector.new(0,0,0))
--is_slime_chunk(vector.new(-150,0,-150))
local check_position = function (pos)
minetest.log("Trying to spawn slime at pos: " .. dump(pos))
--minetest.log("Trying to spawn slime at pos: " .. dump(pos))
local slime_chunk = is_slime_chunk(pos)
minetest.log("spawn_position check: " .. dump(slime_chunk))
--minetest.log("Slime spawn_position check: " .. dump(slime_chunk))
return slime_chunk
end