1
0
Fork 0

fix mistakes from mcl5 import, clean up output

This commit is contained in:
cora 2022-06-06 11:40:31 +02:00
parent d5b2e60e32
commit 00ef88e01c
2 changed files with 12 additions and 23 deletions

View File

@ -7,8 +7,8 @@ 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 format = string.format local format = string.format
local min1, min2, min3 = mcl_mapgen.overworld.min, mcl_mapgen.end_.min, mcl_mapgen.nether.min local min1, min2, min3 = mcl_vars.mg_overworld_min, mcl_vars.mg_end_min, mcl_vars.mg_nether_min
local max1, max2, max3 = mcl_mapgen.overworld.max, mcl_mapgen.end_.max, mcl_mapgen.nether.max + 128 local max1, max2, max3 = mcl_vars.mg_overworld_max, mcl_vars.mg_end_max, mcl_vars.mg_nether_max + 128
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
@ -19,25 +19,13 @@ local player_dbg = minetest.deserialize(storage:get_string("player_dbg") or "ret
local function get_text(pos, bits) local function get_text(pos, bits)
local bits = bits local bits = bits
if bits == 0 then return "" end if bits == 0 then return "" end
local y = pos.y
if y >= min1 then
y = y - min1
elseif y >= min3 and y <= max3 then
y = y - min3
elseif y >= min2 and y <= max2 then
y = y - min2
end
local biome_data = get_biome_data(pos) local biome_data = get_biome_data(pos)
local biome_name = biome_data and get_biome_name(biome_data.biome) or "No biome" local biome_name = biome_data and get_biome_name(biome_data.biome) or "No biome"
local text local biome = format("%s (%s), Humidity: %.1f, Temperature: %.1f",biome_name, biome_data.biome, biome_data.humidity, biome_data.heat)
if bits == 1 then local coord = format("x:%.1f y:%.1f z:%.1f", pos.x, pos.y, pos.z)
text = biome_name --local pointed =
elseif bits == 2 then return biome.."\n"..coord
text = format("x:%.1f y:%.1f z:%.1f", pos.x, y, pos.z)
elseif bits == 3 then
text = format("%s x:%.1f y:%.1f z:%.1f", biome_name, pos.x, y, pos.z)
end
return text
end end
local function info() local function info()
@ -51,7 +39,7 @@ local function info()
hud_elem_type = "text", hud_elem_type = "text",
alignment = {x = 1, y = -1}, alignment = {x = 1, y = -1},
scale = {x = 100, y = 100}, scale = {x = 100, y = 100},
position = {x = 0.0073, y = 0.989}, position = {x = 0.0073, y = 0.889},
text = text, text = text,
style = 5, style = 5,
["number"] = 0xcccac0, ["number"] = 0xcccac0,
@ -85,8 +73,8 @@ 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, 3 = 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 > 4 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, 4))
return return
end end
if dbg == default_debug then if dbg == default_debug then
@ -98,6 +86,7 @@ minetest.register_chatcommand("debug",{
end end
}) })
--why is this saved on shutdown but not on playerleave / changes ?
minetest.register_on_shutdown(function() minetest.register_on_shutdown(function()
storage:set_string("player_dbg", minetest.serialize(player_dbg)) storage:set_string("player_dbg", minetest.serialize(player_dbg))
end) end)

View File

@ -1,3 +1,3 @@
name = mcl_info name = mcl_info
description = Prints biome name and player position description = Prints biome name and player position
optional_depends = mcl_mapgen depends = mcl_init