From a093b785a55f40bafe6da04147564db5e2ae9d16 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 15 May 2020 16:25:18 +0200 Subject: [PATCH] Replace deprecated functions so it stops crashing --- init.lua | 18 +++++------------- villages.lua | 4 ++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/init.lua b/init.lua index a0b82bc..45c5171 100644 --- a/init.lua +++ b/init.lua @@ -120,7 +120,7 @@ local function smooth(x, z, ...) end function inside_village(x, z, village, vnoise) - return get_vn(x, z, vnoise:get2d({x = x, y = z}), village) <= 40 + return get_vn(x, z, vnoise:get_2d({x = x, y = z}), village) <= 40 end local wseed @@ -355,7 +355,7 @@ function get_biome_table(minp, humidity, temperature, range) local mnp, mxp = {x=minp.x+xi*80,z=minp.z+zi*80}, {x=minp.x+xi*80+80,z=minp.z+zi*80+80} local pr = PseudoRandom(get_bseed(mnp)) local bxp, bzp = pr:next(mnp.x, mxp.x), pr:next(mnp.z, mxp.z) - local h, t = humidity:get2d({x=bxp, y=bzp}), temperature:get2d({x=bxp, y=bzp}) + local h, t = humidity:get_2d({x=bxp, y=bzp}), temperature:get_2d({x=bxp, y=bzp}) l[#l+1] = {x=bxp, z=bzp, h=h, t=t} end end @@ -385,15 +385,7 @@ local function get_perlin_map(seed, octaves, persistance, scale, minp, maxp) {offset=0, scale=1, spread={x=scale, y=scale, z=scale}, seed=seed, octaves=octaves, persist=persistance}, {x=sidelen, y=sidelen, z=sidelen} ) - return pm:get2dMap_flat({x = minp.x, y = minp.z, z = 0}) -end - -local function copytable(t) - local t2 = {} - for key, val in pairs(t) do - t2[key] = val - end - return t2 + return pm:get_2d_map_flat({x = minp.x, y = minp.z, z = 0}) end local function mg_generate(minp, maxp, emin, emax, vm) @@ -580,10 +572,10 @@ local function mg_generate(minp, maxp, emin, emax, vm) for _, ore_sheet in ipairs(mg.registered_ore_sheets) do local sidelen = maxp.x - minp.x + 1 - local np = copytable(ore_sheet.noise_params) + local np = table.copy(ore_sheet.noise_params) np.seed = np.seed + minp.y local pm = minetest.get_perlin_map(np, {x = sidelen, y = sidelen, z = 1}) - local map = pm:get2dMap_flat({x = minp.x, y = minp.z}) + local map = pm:get_2d_map_flat({x = minp.x, y = minp.z}) local ni = 0 local trh = ore_sheet.threshhold local wherein = minetest.get_content_id(ore_sheet.wherein) diff --git a/villages.lua b/villages.lua index 17269bc..b9999a5 100644 --- a/villages.lua +++ b/villages.lua @@ -33,7 +33,7 @@ function villages_at_point(minp, noise1) local s = pi:next(1, 400) local x = pi:next(mp.x, mp.x + 79) local z = pi:next(mp.z, mp.z + 79) - if s <= VILLAGE_CHANCE and noise1:get2d({x = x, y = z}) >= -0.3 then return {} end + if s <= VILLAGE_CHANCE and noise1:get_2d({x = x, y = z}) >= -0.3 then return {} end end end end @@ -41,7 +41,7 @@ function villages_at_point(minp, noise1) if pr:next(1, 400) > VILLAGE_CHANCE then return {} end -- No village here local x = pr:next(minp.x, minp.x + 79) local z = pr:next(minp.z, minp.z + 79) - if noise1:get2d({x = x, y = z}) < -0.3 then return {} end -- Deep in the ocean + if noise1:get_2d({x = x, y = z}) < -0.3 then return {} end -- Deep in the ocean local type = pr:next(1, 1) -- TODO: actually make them local size = pr:next(VILLAGE_MIN_SIZE, VILLAGE_MAX_SIZE) -- TODO: change to type-dependant sizes local height = pr:next(5, 20)