forked from mtcontrib/riesenpilz
Remove vector_extras dependency
This commit is contained in:
parent
dc64c2fb6e
commit
6257c39406
@ -17,3 +17,22 @@ else
|
|||||||
function riesenpilz.inform()
|
function riesenpilz.inform()
|
||||||
end
|
end
|
||||||
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
|
||||||
|
10
init.lua
10
init.lua
@ -67,7 +67,8 @@ local function set_vm_data(manip, pznodes, pos, t1, name)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
manip:write_to_map()
|
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()
|
local t1 = os.clock()
|
||||||
manip:update_map()
|
manip:update_map()
|
||||||
riesenpilz.inform("map updated", 3, t1)
|
riesenpilz.inform("map updated", 3, t1)
|
||||||
@ -191,7 +192,8 @@ local function riesenpilz_minecraft_fliegenpilz(pos)
|
|||||||
manip:set_param2_data(param2s)
|
manip:set_param2_data(param2s)
|
||||||
manip:write_to_map()
|
manip:write_to_map()
|
||||||
manip:update_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
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -501,7 +503,7 @@ local function riesenpilz_apple(pos)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
manip:write_to_map()
|
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()
|
manip:update_map()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -816,7 +818,7 @@ for name,i in pairs({
|
|||||||
|
|
||||||
-- witch circles
|
-- witch circles
|
||||||
local ps = {}
|
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)
|
local p = vector.add(pos, p)
|
||||||
|
|
||||||
-- currently 3 is used here, approved by its use in the mapgen
|
-- currently 3 is used here, approved by its use in the mapgen
|
||||||
|
18
mapgen.lua
18
mapgen.lua
@ -79,9 +79,9 @@ end
|
|||||||
|
|
||||||
local data = {}
|
local data = {}
|
||||||
local area, pr
|
local area, pr
|
||||||
function riesenpilz_circle(nam, pos, radius, chance)
|
local function make_circle(nam, pos, radius, chance)
|
||||||
local circle = vector.circle(radius)
|
local circle = riesenpilz.circle(radius)
|
||||||
for i = 1,#circle do
|
for i = 1, #circle do
|
||||||
if pr:next(1, chance) == 1 then
|
if pr:next(1, chance) == 1 then
|
||||||
local vi = area:indexp(vector.add(pos, circle[i]))
|
local vi = area:indexp(vector.add(pos, circle[i]))
|
||||||
if data[vi] == c.air
|
if data[vi] == c.air
|
||||||
@ -231,13 +231,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
if pr:next(1,15) == 1 then
|
if pr:next(1,15) == 1 then
|
||||||
data[vi + area.ystride] = c.dry_shrub
|
data[vi + area.ystride] = c.dry_shrub
|
||||||
elseif pr:next(1,80) == 1 then
|
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
|
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
|
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
|
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
|
elseif pr:next(1,340) == 10 then
|
||||||
bigtype = 2
|
bigtype = 2
|
||||||
elseif pr:next(1,380) == 1 then
|
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
|
elseif pr:next(1,800) == 7 then
|
||||||
bigtype = 5
|
bigtype = 5
|
||||||
elseif pr:next(1,4000) == 1 then
|
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
|
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
|
elseif pr:next(1,6000) == 2 then
|
||||||
if pr:next(1,200) == 15 then
|
if pr:next(1,200) == 15 then
|
||||||
bigtype = 4
|
bigtype = 4
|
||||||
|
Loading…
Reference in New Issue
Block a user