1
0
Fork 0

Rename mapgen variables

This commit is contained in:
Wuzzy 2017-03-04 23:00:23 +01:00
parent 19150ddddb
commit 2495676e54
5 changed files with 27 additions and 19 deletions

View File

@ -8,21 +8,29 @@ mcl_vars.gui_bg_img = ""
mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg mcl_vars.inventory_header = mcl_vars.gui_slots .. mcl_vars.gui_bg
-- Mapgen variables
local mg_name = minetest.get_mapgen_setting("mg_name") local mg_name = minetest.get_mapgen_setting("mg_name")
local minecraft_height_limit = 256
if mg_name ~= "flat" then if mg_name ~= "flat" then
mcl_vars.mg_overworld_min = -62
mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
-- 1 flat bedrock layer with 4 rough layers above -- 1 flat bedrock layer with 4 rough layers above
mcl_vars.bedrock_overworld_min = -62 mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
mcl_vars.bedrock_overworld_max = mcl_vars.bedrock_overworld_min + 4 mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min + 4
mcl_vars.bedrock_is_rough = true mcl_vars.mg_bedrock_is_rough = true
else else
-- 1 perfectly flat bedrock layer
local ground = minetest.get_mapgen_setting("mgflat_ground_level") local ground = minetest.get_mapgen_setting("mgflat_ground_level")
if not ground then if not ground then
ground = 8 ground = 8
end end
mcl_vars.bedrock_overworld_min = ground - 3 mcl_vars.mg_overworld_min = ground - 1
mcl_vars.bedrock_overworld_max = mcl_vars.bedrock_overworld_min mcl_vars.mg_overworld_max = mcl_vars.mg_overworld_min + minecraft_height_limit
mcl_vars.bedrock_is_rough = false
-- 1 perfectly flat bedrock layer
mcl_vars.mg_bedrock_overworld_min = mcl_vars.mg_overworld_min
mcl_vars.mg_bedrock_overworld_max = mcl_vars.mg_bedrock_overworld_min
mcl_vars.mg_bedrock_is_rough = false
end end
-- Set default stack sizes -- Set default stack sizes

View File

@ -200,8 +200,8 @@ end
-- 2nd return value: true if it is in the deadly part of the void -- 2nd return value: true if it is in the deadly part of the void
function mcl_util.is_in_void(pos) function mcl_util.is_in_void(pos)
local void, void_deadly local void, void_deadly
void = pos.y < mcl_vars.bedrock_overworld_min void = pos.y < mcl_vars.mg_overworld_min
void_deadly = pos.y < mcl_vars.bedrock_overworld_min - 65 void_deadly = pos.y < mcl_vars.mg_overworld_min - 64
return void, void_deadly return void, void_deadly
end end
@ -213,8 +213,8 @@ end
-- If the Y coordinate is not located in any dimension, it will return: -- If the Y coordinate is not located in any dimension, it will return:
-- nil, "void" -- nil, "void"
function mcl_util.y_to_layer(y) function mcl_util.y_to_layer(y)
if y >= mcl_vars.bedrock_overworld_min then if y >= mcl_vars.mg_overworld_min then
return y - mcl_vars.bedrock_overworld_min, "overworld" return y - mcl_vars.mg_overworld_min, "overworld"
else else
return nil, "void" return nil, "void"
end end
@ -226,5 +226,5 @@ end
-- minecraft_dimension parameter is ignored at the moment -- minecraft_dimension parameter is ignored at the moment
-- TODO: Implement dimensions -- TODO: Implement dimensions
function mcl_util.layer_to_y(layer, minecraft_dimension) function mcl_util.layer_to_y(layer, minecraft_dimension)
return layer + mcl_vars.bedrock_overworld_min return layer + mcl_vars.mg_overworld_min
end end

View File

@ -74,7 +74,7 @@ skycolor = {
players = skycolor.utils.get_players(players) players = skycolor.utils.get_players(players)
for _, player in ipairs(players) do for _, player in ipairs(players) do
local pos = player:getpos() local pos = player:getpos()
if pos.y >= mcl_vars.bedrock_overworld_max then if pos.y >= mcl_vars.mg_bedrock_overworld_max then
player:set_sky(color, "plain", nil) player:set_sky(color, "plain", nil)
end end
end end
@ -112,7 +112,7 @@ skycolor = {
local players = skycolor.utils.get_players(nil) local players = skycolor.utils.get_players(nil)
for _, player in ipairs(players) do for _, player in ipairs(players) do
local pos = player:getpos() local pos = player:getpos()
if pos.y >= mcl_vars.bedrock_overworld_max then if pos.y >= mcl_vars.mg_bedrock_overworld_max then
player:set_sky(color, "plain", nil) player:set_sky(color, "plain", nil)
end end
end end
@ -125,7 +125,7 @@ skycolor = {
local players = skycolor.utils.get_players(players) local players = skycolor.utils.get_players(players)
for _, player in ipairs(players) do for _, player in ipairs(players) do
local pos = player:getpos() local pos = player:getpos()
if pos.y >= mcl_vars.bedrock_overworld_max then if pos.y >= mcl_vars.mg_bedrock_overworld_max then
player:set_sky(nil, "regular", nil) player:set_sky(nil, "regular", nil)
end end
end end

View File

@ -563,8 +563,8 @@ end)
-- Generate bedrock layer or layers -- Generate bedrock layer or layers
local BEDROCK_MIN = mcl_vars.bedrock_overworld_min local BEDROCK_MIN = mcl_vars.mg_bedrock_overworld_min
local BEDROCK_MAX = mcl_vars.bedrock_overworld_max local BEDROCK_MAX = mcl_vars.mg_bedrock_overworld_max
-- Below the bedrock, generate air/void -- Below the bedrock, generate air/void
@ -581,7 +581,7 @@ minetest.register_on_generated(function(minp, maxp)
for z = minp.z, maxp.z do for z = minp.z, maxp.z do
local p_pos = area:index(x, y, z) local p_pos = area:index(x, y, z)
local setdata = nil local setdata = nil
if mcl_vars.bedrock_is_rough then if mcl_vars.mg_bedrock_is_rough then
-- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer -- Bedrock layers with increasing levels of roughness, until a perfecly flat bedrock later at the bottom layer
-- This code assumes a bedrock height of 5 layers. -- This code assumes a bedrock height of 5 layers.
if y == BEDROCK_MAX then if y == BEDROCK_MAX then

View File

@ -122,7 +122,7 @@ minetest.register_globalstep(function(dtime)
end end
-- Apply black sky in the Void and deal Void damage -- Apply black sky in the Void and deal Void damage
if pos.y < mcl_vars.bedrock_overworld_max then if pos.y < mcl_vars.mg_bedrock_overworld_max then
-- Player reached the void, set black sky box -- Player reached the void, set black sky box
player:set_sky("#000000", "plain") player:set_sky("#000000", "plain")
-- FIXME: Sky handling in MCL2 is held together with lots of duct tape. -- FIXME: Sky handling in MCL2 is held together with lots of duct tape.