Update Fork #9

Merged
chmodsayshello merged 403 commits from MineClone5/MineClone5:master into master 2022-08-02 15:50:37 +02:00
4 changed files with 50 additions and 17 deletions
Showing only changes of commit 40c17d288b - Show all commits

View File

@ -1,14 +1,20 @@
local refresh_interval = .63 local refresh_interval = .63
local huds = {} local huds = {}
local default_debug = 3 local default_debug = 5
local after = minetest.after local after = minetest.after
local get_connected_players = minetest.get_connected_players local get_connected_players = minetest.get_connected_players
local get_biome_name = minetest.get_biome_name local get_biome_name = minetest.get_biome_name
local get_biome_data = minetest.get_biome_data local get_biome_data = minetest.get_biome_data
local get_node = minetest.get_node
local format = string.format local format = string.format
local table_concat = table.concat
local floor = math.floor
local minetest_get_gametime = minetest.get_gametime
local get_voxel_manip = minetest.get_voxel_manip
local min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end_.min, mcl_mapgen.nether.min local min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end_.min, mcl_mapgen.nether.min
local max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end_.max, mcl_mapgen.nether.max + 128 local max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end_.max, mcl_mapgen.nether.max + 128
local CS = mcl_mapgen.CS_NODES
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
@ -17,6 +23,7 @@ local storage = minetest.get_mod_storage()
local player_dbg = minetest.deserialize(storage:get_string("player_dbg") or "return {}") or {} local player_dbg = minetest.deserialize(storage:get_string("player_dbg") or "return {}") or {}
local function get_text(pos, bits) local function get_text(pos, bits)
local pos = pos
local bits = bits local bits = bits
if bits == 0 then return "" end if bits == 0 then return "" end
local y = pos.y local y = pos.y
@ -27,16 +34,42 @@ local function get_text(pos, bits)
elseif y >= min2 and y <= max2 then elseif y >= min2 and y <= max2 then
y = y - min2 y = y - min2
end end
local biome_data = get_biome_data(pos)
local biome_name = biome_data and get_biome_name(biome_data.biome) or "No biome" local will_show_mapgen_status = bits % 8 > 3
local text local will_show_coordinates = bits % 4 > 1
if bits == 1 then local will_show_biome_name = bits % 2 > 0
text = biome_name local will_be_shown = {}
elseif bits == 2 then
text = format("x:%.1f y:%.1f z:%.1f", pos.x, y, pos.z) if will_show_biome_name then
elseif bits == 3 then local biome_data = get_biome_data(pos)
text = format("%s x:%.1f y:%.1f z:%.1f", biome_name, pos.x, y, pos.z) local biome_name = biome_data and get_biome_name(biome_data.biome) or "No biome"
will_be_shown[#will_be_shown + 1] = biome_name
end end
if will_show_coordinates then
local coordinates = format("x:%.1f y:%.1f z:%.1f", pos.x, y, pos.z)
will_be_shown[#will_be_shown + 1] = coordinates
end
if will_show_mapgen_status then
local pos_x = floor(pos.x)
local pos_y = floor(pos.y)
local pos_z = floor(pos.z)
local c = 0
for x = pos_x - CS, pos_x + CS, CS do
for y = pos_y - CS, pos_y + CS, CS do
for z = pos_z - CS, pos_z + CS, CS do
local pos = {x = x, y = y, z = z}
get_voxel_manip():read_from_map(pos, pos)
local node = get_node(pos)
if node.name ~= "ignore" then c = c + 1 end
end
end
end
local p = floor(c / 27 * 100 + 0.5)
local status = format("Generated %u%% (%u/27 chunks)", p, c)
will_be_shown[#will_be_shown + 1] = status
end
local text = table_concat(will_be_shown, ' ')
return text return text
end end
@ -82,11 +115,11 @@ minetest.register_on_authplayer(function(name, ip, is_success)
end) end)
minetest.register_chatcommand("debug",{ minetest.register_chatcommand("debug",{
description = S("Set debug bit mask: 0 = disable, 1 = biome name, 2 = coordinates, 3 = all"), description = S("Set debug bit mask: 0 = disable, 1 = biome name, 2 = coordinates, 4 = mapgen status, 7 = all"),
func = function(name, params) func = function(name, params)
local dbg = math.floor(tonumber(params) or default_debug) local dbg = math.floor(tonumber(params) or default_debug)
if dbg < 0 or dbg > 3 then if dbg < 0 or dbg > 7 then
minetest.chat_send_player(name, S("Error! Possible values are integer numbers from @1 to @2", 0, 3)) minetest.chat_send_player(name, S("Error! Possible values are integer numbers from @1 to @2", 0, 7))
return return
end end
if dbg == default_debug then if dbg == default_debug then

View File

@ -1,4 +1,4 @@
# textdomain: mcl_info # textdomain: mcl_info
Set debug bit mask: 0 @= disable, 1 @= biome name, 2 @= coordinates, 3 @= all=Réglage du masque de débugage : 0 @= désactiver, 1 @= nom de biome, 2 @= coordonnées, 3 @= tout= Set debug bit mask: 0 @= disable, 1 @= biome name, 2 @= coordinates, 4 @= mapgen status, 7 @= all=Réglage du masque de débugage : 0 @= désactiver, 1 @= nom de biome, 2 @= coordonnées, 4 @= mapgen status, 7 @= tout=
Error! Possible values are integer numbers from @1 to @2=Erreur ! Les valeurs autorisées sont des nombres entiers de @1 à @2 Error! Possible values are integer numbers from @1 to @2=Erreur ! Les valeurs autorisées sont des nombres entiers de @1 à @2
Debug bit mask set to @1=Masque de débugage réglé à @1 Debug bit mask set to @1=Masque de débugage réglé à @1

View File

@ -1,4 +1,4 @@
# textdomain: mcl_info # textdomain: mcl_info
Set debug bit mask: 0 @= disable, 1 @= biome name, 2 @= coordinates, 3 @= all=Установка отладочной битовой маски: 0 @= отключить, 1 @= биом, 2 @= координаты, 3 @= всё Set debug bit mask: 0 @= disable, 1 @= biome name, 2 @= coordinates, 4 @= mapgen status, 7 @= all=Установка отладочной битовой маски: 0 @= отключить, 1 @= биом, 2 @= координаты, 4 @= состояние мапгена, 7 @= всё
Error! Possible values are integer numbers from @1 to @2=Ошибка! Допустимые значения - целые числа от @1 до @2 Error! Possible values are integer numbers from @1 to @2=Ошибка! Допустимые значения - целые числа от @1 до @2
Debug bit mask set to @1=Отладочной битовой маске присвоено значение @1 Debug bit mask set to @1=Отладочной битовой маске присвоено значение @1

View File

@ -1,4 +1,4 @@
# textdomain: mcl_info # textdomain: mcl_info
Set debug bit mask: 0 @= disable, 1 @= biome name, 2 @= coordinates, 3 @= all= Set debug bit mask: 0 @= disable, 1 @= biome name, 2 @= coordinates, 4 @= mapgen status, 7 @= all=
Error! Possible values are integer numbers from @1 to @2= Error! Possible values are integer numbers from @1 to @2=
Debug bit mask set to @1= Debug bit mask set to @1=