From 6257c3940661e34765ba636b47aae620b3394955 Mon Sep 17 00:00:00 2001 From: HybridDog Date: Sun, 24 Oct 2021 19:16:08 +0200 Subject: [PATCH] Remove vector_extras dependency --- functions.lua | 19 +++++++++++++++++++ init.lua | 10 ++++++---- mapgen.lua | 18 +++++++++--------- mod.conf | 2 +- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/functions.lua b/functions.lua index 8b42869..8c56a7b 100644 --- a/functions.lua +++ b/functions.lua @@ -17,3 +17,22 @@ else function riesenpilz.inform() end end + +local circle_tables = {} +function riesenpilz.circle(r) + local circle = circle_tables[r] + if circle then + return circle + end + local circle, n = {}, 1 + for i = -r, r do + for j = -r, r do + if math.floor(math.sqrt(i * i + j * j) + 0.5) == r then + circle[n] = {x=i, y=0, z=j} + n = n+1 + end + end + end + circle_tables[r] = circle + return circle +end diff --git a/init.lua b/init.lua index 8738d14..e841811 100644 --- a/init.lua +++ b/init.lua @@ -67,7 +67,8 @@ local function set_vm_data(manip, pznodes, pos, t1, name) return end manip:write_to_map() - riesenpilz.inform("a giant "..name.." mushroom grew at "..vector.pos_to_string(pos), 3, t1) + riesenpilz.inform("a giant " .. name .. " mushroom grew at " .. + minetest.pos_to_string(pos), 3, t1) local t1 = os.clock() manip:update_map() riesenpilz.inform("map updated", 3, t1) @@ -191,7 +192,8 @@ local function riesenpilz_minecraft_fliegenpilz(pos) manip:set_param2_data(param2s) manip:write_to_map() manip:update_map() - riesenpilz.inform("a fly agaric grew at "..vector.pos_to_string(pos), 3, t1) + riesenpilz.inform("a fly agaric grew at " .. minetest.pos_to_string(pos), + 3, t1) end @@ -501,7 +503,7 @@ local function riesenpilz_apple(pos) return end manip:write_to_map() - riesenpilz.inform("an apple grew at "..vector.pos_to_string(pos), 3, t1) + riesenpilz.inform("an apple grew at " .. minetest.pos_to_string(pos), 3, t1) manip:update_map() end @@ -816,7 +818,7 @@ for name,i in pairs({ -- witch circles local ps = {} - for _,p in pairs(vector.circle(math.random(rmin, rmax))) do + for _,p in pairs(riesenpilz.circle(math.random(rmin, rmax))) do local p = vector.add(pos, p) -- currently 3 is used here, approved by its use in the mapgen diff --git a/mapgen.lua b/mapgen.lua index 184c510..b9e5d2c 100644 --- a/mapgen.lua +++ b/mapgen.lua @@ -79,9 +79,9 @@ end local data = {} local area, pr -function riesenpilz_circle(nam, pos, radius, chance) - local circle = vector.circle(radius) - for i = 1,#circle do +local function make_circle(nam, pos, radius, chance) + local circle = riesenpilz.circle(radius) + for i = 1, #circle do if pr:next(1, chance) == 1 then local vi = area:indexp(vector.add(pos, circle[i])) if data[vi] == c.air @@ -231,13 +231,13 @@ minetest.register_on_generated(function(minp, maxp, seed) if pr:next(1,15) == 1 then data[vi + area.ystride] = c.dry_shrub elseif pr:next(1,80) == 1 then - riesenpilz_circle(c.riesenpilz_brown, boden, pr:next(3,4), 3) + make_circle(c.riesenpilz_brown, boden, pr:next(3,4), 3) elseif pr:next(1,85) == 1 then - riesenpilz_circle(c.riesenpilz_parasol, boden, pr:next(3,5), 3) + make_circle(c.riesenpilz_parasol, boden, pr:next(3,5), 3) elseif pr:next(1,90) == 1 then - riesenpilz_circle(c.riesenpilz_red, boden, pr:next(4,5), 3) + make_circle(c.riesenpilz_red, boden, pr:next(4,5), 3) elseif pr:next(1,100) == 1 then - riesenpilz_circle(c.riesenpilz_fly_agaric, boden, 4, 3) + make_circle(c.riesenpilz_fly_agaric, boden, 4, 3) elseif pr:next(1,340) == 10 then bigtype = 2 elseif pr:next(1,380) == 1 then @@ -247,9 +247,9 @@ minetest.register_on_generated(function(minp, maxp, seed) elseif pr:next(1,800) == 7 then bigtype = 5 elseif pr:next(1,4000) == 1 then - riesenpilz_circle(c.riesenpilz_lavashroom, boden, pr:next(5,6), 3) + make_circle(c.riesenpilz_lavashroom, boden, pr:next(5,6), 3) elseif pr:next(1,5000) == 1 then - riesenpilz_circle(c.riesenpilz_glowshroom, boden, 3, 3) + make_circle(c.riesenpilz_glowshroom, boden, 3, 3) elseif pr:next(1,6000) == 2 then if pr:next(1,200) == 15 then bigtype = 4 diff --git a/mod.conf b/mod.conf index a401428..70223ba 100644 --- a/mod.conf +++ b/mod.conf @@ -1,3 +1,3 @@ name = riesenpilz -depends = default,vector_extras +depends = default optional_depends = digilines,fence_registration,technic