1
0
mirror of https://github.com/HybridDog/riesenpilz.git synced 2024-11-15 23:10:22 +01:00
riesenpilz/init.lua

1279 lines
31 KiB
Lua
Raw Normal View History

2014-02-16 15:04:49 +01:00
local load_time_start = os.clock()
2013-01-29 18:38:49 +01:00
local MAX_SIZE = 3
2013-04-04 18:44:35 +02:00
2014-08-11 15:17:58 +02:00
riesenpilz = {}
2015-11-06 14:27:25 +01:00
local modpath = minetest.get_modpath("riesenpilz").."/"
dofile(modpath.."settings.lua")
dofile(modpath.."functions.lua")
2014-08-11 15:17:58 +02:00
2015-06-16 19:30:22 +02:00
2015-11-06 14:27:25 +01:00
-- Growing Functions
2015-06-16 19:30:22 +02:00
2014-02-16 15:04:49 +01:00
local function r_area(manip, width, height, pos)
local emerged_pos1, emerged_pos2 = manip:read_from_map(
{x=pos.x-width, y=pos.y, z=pos.z-width},
{x=pos.x+width, y=pos.y+height, z=pos.z+width}
)
return VoxelArea:new({MinEdge=emerged_pos1, MaxEdge=emerged_pos2})
end
-- contents become added later
local c
-- cache buildable_to ids
local re_al_cache = {[minetest.get_content_id("ignore")] = true}
local function replacing_allowed(id)
if re_al_cache[id] ~= nil then
return re_al_cache[id]
end
local def = minetest.registered_nodes[minetest.get_name_from_content_id(id)]
if not def
or def.buildable_to then
re_al_cache[id] = true
return true
end
re_al_cache[id] = false
return false
end
local set_vm_nodes
if riesenpilz.giant_restrict_area then
function set_vm_nodes(manip, pznodes)
local nodes = manip:get_data()
for vi,id in pairs(pznodes) do
if not replacing_allowed(nodes[vi]) then
return false
end
nodes[vi] = id
end
manip:set_data(nodes)
return true
end
else
function set_vm_nodes(manip, pznodes)
local nodes = manip:get_data()
for vi,id in pairs(pznodes) do
if replacing_allowed(nodes[vi]) then
nodes[vi] = id
end
end
manip:set_data(nodes)
return true
end
end
local function set_vm_data(manip, pznodes, pos, t1, name)
if not set_vm_nodes(manip, pznodes) then
return
end
2013-11-05 20:31:44 +01:00
manip:write_to_map()
2021-10-24 19:16:08 +02:00
riesenpilz.inform("a giant " .. name .. " mushroom grew at " ..
minetest.pos_to_string(pos), 3, t1)
local t2 = os.clock()
manip:update_map()
riesenpilz.inform("map updated", 3, t2)
2013-11-05 20:31:44 +01:00
end
2015-03-08 13:28:01 +01:00
2015-05-27 11:44:06 +02:00
function riesenpilz.red(pos, nodes, area, w)
w = w or math.random(MAX_SIZE)
local h = w + 2
2013-08-23 16:32:27 +02:00
2015-05-27 11:44:06 +02:00
for i = 0, h do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem
2013-01-29 18:38:49 +01:00
end
2015-05-27 11:44:06 +02:00
local br = w+1
for k = -1, 1, 2 do
for l = -br+1, br do
nodes[area:index(pos.x+br*k, pos.y+h, pos.z-l*k)] = c.head_red
nodes[area:index(pos.x+l*k, pos.y+h, pos.z+br*k)] = c.head_red
2013-01-29 18:38:49 +01:00
end
end
2015-05-27 11:44:06 +02:00
for k = -w, w do
for l = -w, w do
nodes[area:index(pos.x+l, pos.y+h+1, pos.z+k)] = c.head_red
nodes[area:index(pos.x+l, pos.y+h, pos.z+k)] = c.lamellas
2013-01-29 18:38:49 +01:00
end
end
end
local function riesenpilz_hybridpilz(pos)
2015-05-27 11:44:06 +02:00
local t1 = os.clock()
2013-04-04 18:44:35 +02:00
2015-05-27 11:44:06 +02:00
local w = math.random(MAX_SIZE)
2013-08-23 16:32:27 +02:00
local manip = minetest.get_voxel_manip()
2015-05-27 11:44:06 +02:00
local area = r_area(manip, w+1, w+3, pos)
2013-08-23 16:32:27 +02:00
local pznodes = {}
riesenpilz.red(pos, pznodes, area, w)
2015-05-27 11:44:06 +02:00
set_vm_data(manip, pznodes, pos, t1, "red")
2015-05-27 11:44:06 +02:00
end
function riesenpilz.brown(pos, nodes, area, br)
br = br or math.random(MAX_SIZE-1)+1
local h = br + 2
2013-01-29 18:38:49 +01:00
2015-05-27 11:44:06 +02:00
for i in area:iterp(pos, {x=pos.x, y=pos.y+h, z=pos.z}) do
2014-08-11 15:31:05 +02:00
nodes[i] = c.stem
2013-01-29 18:38:49 +01:00
end
2015-05-27 11:44:06 +02:00
local w = br+1
2015-03-07 16:02:24 +01:00
for l = -br, br do
2015-05-27 11:44:06 +02:00
for k = -w, w, w*2 do
nodes[area:index(pos.x+k, pos.y+h+1, pos.z+l)] = c.head_brown
nodes[area:index(pos.x+l, pos.y+h+1, pos.z+k)] = c.head_brown
2013-04-25 20:34:00 +02:00
end
2015-03-07 16:02:24 +01:00
for k = -br, br do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+l, pos.y+h+1, pos.z+k)] = c.head_brown
2013-01-29 18:38:49 +01:00
end
end
end
local function riesenpilz_brauner_minecraftpilz(pos)
2015-05-27 11:44:06 +02:00
local t1 = os.clock()
2013-04-04 18:44:35 +02:00
2015-05-27 11:44:06 +02:00
local br = math.random(MAX_SIZE-1)+1
2013-08-23 16:32:27 +02:00
local manip = minetest.get_voxel_manip()
2015-05-27 11:44:06 +02:00
local area = r_area(manip, br+1, br+3, pos)
2013-08-23 16:32:27 +02:00
local pznodes = {}
riesenpilz.brown(pos, pznodes, area, br)
2015-05-27 11:44:06 +02:00
set_vm_data(manip, pznodes, pos, t1, "brown")
2015-05-27 11:44:06 +02:00
end
2013-01-29 18:38:49 +01:00
2015-05-27 11:44:06 +02:00
function riesenpilz.fly_agaric(pos, nodes, area, param2s)
local h = 3
for i = 0, h do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem
2013-01-29 18:38:49 +01:00
end
2015-03-07 16:02:24 +01:00
for j = -1, 1 do
for k = -1, 1 do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+j, pos.y+h+1, pos.z+k)] = c.head_red
2013-01-29 18:38:49 +01:00
end
2015-05-27 11:44:06 +02:00
for l = 1, h do
2014-04-03 20:17:18 +02:00
local y = pos.y+l
2015-03-08 13:28:01 +01:00
for _,p in pairs({
2014-04-03 20:17:18 +02:00
{area:index(pos.x+j, y, pos.z+2), 0},
{area:index(pos.x+j, y, pos.z-2), 2},
{area:index(pos.x+2, y, pos.z+j), 1},
{area:index(pos.x-2, y, pos.z+j), 3},
}) do
local tmp = p[1]
2014-08-11 15:31:05 +02:00
nodes[tmp] = c.head_red_side
2014-04-03 20:17:18 +02:00
param2s[tmp] = p[2]
end
2013-01-29 18:38:49 +01:00
end
end
2015-05-27 11:44:06 +02:00
end
local function riesenpilz_minecraft_fliegenpilz(pos)
2015-05-27 11:44:06 +02:00
local t1 = os.clock()
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 2, 4, pos)
2015-05-29 12:09:22 +02:00
local param2s = manip:get_param2_data()
2015-05-27 11:44:06 +02:00
local pznodes = {}
riesenpilz.fly_agaric(pos, pznodes, area, param2s)
2013-08-23 16:32:27 +02:00
if not set_vm_nodes(manip, pznodes) then
return
end
2014-04-03 20:17:18 +02:00
manip:set_param2_data(param2s)
2013-08-23 16:32:27 +02:00
manip:write_to_map()
manip:update_map()
2021-10-24 19:16:08 +02:00
riesenpilz.inform("a fly agaric grew at " .. minetest.pos_to_string(pos),
3, t1)
2013-01-29 18:38:49 +01:00
end
2013-08-23 16:32:27 +02:00
local function ran_node(a, b, ran)
2013-04-21 13:45:30 +02:00
if math.random(ran) == 1 then
2013-08-23 16:32:27 +02:00
return a
2013-04-21 13:45:30 +02:00
end
2013-08-23 16:32:27 +02:00
return b
2013-04-21 13:45:30 +02:00
end
2015-05-27 11:44:06 +02:00
function riesenpilz.lavashroom(pos, nodes, area, h)
h = h or 3 + math.random(MAX_SIZE - 2)
2013-08-23 16:32:27 +02:00
2015-05-27 11:44:06 +02:00
-- remove the mushroom
nodes[area:indexp(pos)] = c.air
2013-04-21 13:45:30 +02:00
2013-06-15 00:11:35 +02:00
for i = -1, 1, 2 do
2015-05-27 11:44:06 +02:00
-- set the stem
for n = 0, h do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x+i, pos.y+n, pos.z)] = c.stem_brown
nodes[area:index(pos.x, pos.y+n, pos.z+i)] = c.stem_brown
2013-04-21 13:45:30 +02:00
end
2015-05-27 11:44:06 +02:00
local o = 2*i
2015-03-07 16:02:24 +01:00
for l = -1, 1 do
for k = 2, 3 do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+k*i, pos.y+h+2, pos.z+l)] = c.head_brown_full
nodes[area:index(pos.x+l, pos.y+h+2, pos.z+k*i)] = c.head_brown_full
2013-04-21 13:45:30 +02:00
end
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+l, pos.y+h+1, pos.z+o)] = c.head_brown_full
nodes[area:index(pos.x+o, pos.y+h+1, pos.z+l)] = c.head_brown_full
2013-04-21 13:45:30 +02:00
end
2013-06-15 00:11:35 +02:00
for m = -1, 1, 2 do
2015-03-07 16:02:24 +01:00
for k = 2, 3 do
for j = 2, 3 do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+j*i, pos.y+h+2, pos.z+k*m)] = ran_node(c.head_yellow, c.head_orange, 7)
2013-06-15 00:11:35 +02:00
end
end
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+i, pos.y+h+1, pos.z+m)] = c.head_brown_full
nodes[area:index(pos.x+m*2, pos.y+h+1, pos.z+o)] = c.head_brown_full
2013-04-21 13:45:30 +02:00
end
2015-03-07 16:02:24 +01:00
for l = -3+1, 3 do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+3*i, pos.y+h+5, pos.z-l*i)] = ran_node(c.head_yellow, c.head_orange, 5)
nodes[area:index(pos.x+l*i, pos.y+h+5, pos.z+3*i)] = ran_node(c.head_yellow, c.head_orange, 5)
2013-05-01 16:46:31 +02:00
end
2013-04-25 20:34:00 +02:00
2015-03-07 16:02:24 +01:00
for j = 0, 1 do
for l = -3, 3 do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+i*4, pos.y+h+3+j, pos.z+l)] = ran_node(c.head_yellow, c.head_orange, 6)
nodes[area:index(pos.x+l, pos.y+h+3+j, pos.z+i*4)] = ran_node(c.head_yellow, c.head_orange, 6)
2013-04-21 13:45:30 +02:00
end
end
2013-06-15 00:11:35 +02:00
2013-04-21 13:45:30 +02:00
end
2015-03-07 16:02:24 +01:00
for k = -2, 2 do
for l = -2, 2 do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+k, pos.y+h+6, pos.z+l)] = ran_node(c.head_yellow, c.head_orange, 4)
2013-04-21 13:45:30 +02:00
end
end
end
local function riesenpilz_lavashroom(pos)
2015-05-27 11:44:06 +02:00
local t1 = os.clock()
2013-04-21 13:45:30 +02:00
2015-05-27 11:44:06 +02:00
local h = 3+math.random(MAX_SIZE-2)
2013-08-23 16:32:27 +02:00
local manip = minetest.get_voxel_manip()
2015-05-27 11:44:06 +02:00
local area = r_area(manip, 4, h+6, pos)
2013-08-23 16:32:27 +02:00
local pznodes = {}
riesenpilz.lavashroom(pos, pznodes, area, h)
2015-05-27 11:44:06 +02:00
set_vm_data(manip, pznodes, pos, t1, "lavashroom")
2015-05-27 11:44:06 +02:00
end
2013-05-01 18:00:02 +02:00
2015-05-27 11:44:06 +02:00
function riesenpilz.glowshroom(pos, nodes, area, h)
h = h or 2 + math.random(MAX_SIZE)
2015-05-27 11:44:06 +02:00
for i = 0, h do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.stem_blue
2013-05-01 18:00:02 +02:00
end
2015-05-27 11:44:06 +02:00
local br = 2
2013-06-15 00:11:35 +02:00
for i = -1, 1, 2 do
2013-05-01 18:00:02 +02:00
2013-06-15 00:11:35 +02:00
for k = -br, br, 2*br do
2015-05-27 11:44:06 +02:00
for l = 2, h do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x+i*br, pos.y+l, pos.z+k)] = c.head_blue
2013-06-15 00:11:35 +02:00
end
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x+i*br, pos.y+1, pos.z+k)] = c.head_blue_bright
2013-05-01 18:00:02 +02:00
end
2015-03-07 16:02:24 +01:00
for l = -br+1, br do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+i*br, pos.y+h, pos.z-l*i)] = c.head_blue
nodes[area:index(pos.x+l*i, pos.y+h, pos.z+br*i)] = c.head_blue
2013-05-01 18:00:02 +02:00
end
2013-06-15 00:11:35 +02:00
end
2013-05-01 18:00:02 +02:00
2015-03-07 16:02:24 +01:00
for l = 0, br do
for i = -br+l, br-l do
for k = -br+l, br-l do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+i, pos.y+h+1+l, pos.z+k)] = c.head_blue
2013-05-01 18:00:02 +02:00
end
end
end
2013-11-05 20:31:44 +01:00
end
local function riesenpilz_glowshroom(pos)
2013-11-05 20:31:44 +01:00
local t1 = os.clock()
2013-11-10 11:06:24 +01:00
2015-05-27 11:44:06 +02:00
local h = 2+math.random(MAX_SIZE)
2013-11-10 11:06:24 +01:00
2013-11-05 20:31:44 +01:00
local manip = minetest.get_voxel_manip()
2015-05-27 11:44:06 +02:00
local area = r_area(manip, 2, h+3, pos)
2013-11-05 20:31:44 +01:00
local pznodes = {}
riesenpilz.glowshroom(pos, pznodes, area, h)
2015-05-27 11:44:06 +02:00
set_vm_data(manip, pznodes, pos, t1, "glowshroom")
2015-05-27 11:44:06 +02:00
end
function riesenpilz.parasol(pos, nodes, area, w, h)
h = h or 6 + math.random(MAX_SIZE)
2013-11-05 20:31:44 +01:00
--stem
2015-05-27 11:44:06 +02:00
for i in area:iterp(pos, {x=pos.x, y=pos.y+h-2, z=pos.z}) do
2014-08-11 15:31:05 +02:00
nodes[i] = c.stem
2013-11-05 20:31:44 +01:00
end
w = w or MAX_SIZE + math.random(2)
2015-05-27 11:44:06 +02:00
local bhead1 = w-1
local bhead2 = math.random(1,w-2)
2015-03-08 13:28:01 +01:00
for _,j in pairs({
2014-08-11 15:31:05 +02:00
{bhead2, 0, c.head_brown_bright},
2019-11-04 12:26:58 +01:00
{bhead1, -1, c.head_beige}
2014-02-16 15:04:49 +01:00
}) do
2015-05-27 11:44:06 +02:00
for i in area:iter(pos.x-j[1], pos.y+h+j[2], pos.z-j[1], pos.x+j[1], pos.y+h+j[2], pos.z+j[1]) do
2014-02-16 15:04:49 +01:00
nodes[i] = j[3]
2013-11-05 20:31:44 +01:00
end
end
2015-05-27 11:44:06 +02:00
local rh = math.random(2,3)
2013-11-10 11:06:24 +01:00
for k = -1, 1, 2 do
for l = 0, 1 do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x+k, pos.y+rh, pos.z-l*k)] = c.head_white
nodes[area:index(pos.x+l*k, pos.y+rh, pos.z+k)] = c.head_white
2013-11-10 11:06:24 +01:00
end
2015-05-27 11:44:06 +02:00
for l = -w+1, w do
2019-11-04 12:26:58 +01:00
nodes[area:index(pos.x+w*k, pos.y+h-2, pos.z-l*k)] = c.head_beige
nodes[area:index(pos.x+l*k, pos.y+h-2, pos.z+w*k)] = c.head_beige
2013-11-10 11:06:24 +01:00
end
for l = -bhead1+1, bhead1 do
2015-05-27 11:44:06 +02:00
nodes[area:index(pos.x+bhead1*k, pos.y+h-2, pos.z-l*k)] = c.head_white
nodes[area:index(pos.x+l*k, pos.y+h-2, pos.z+bhead1*k)] = c.head_white
2013-11-05 20:31:44 +01:00
end
end
2013-05-01 18:00:02 +02:00
end
local function riesenpilz_parasol(pos)
2015-05-27 11:44:06 +02:00
local t1 = os.clock()
2013-05-01 18:00:02 +02:00
local w = MAX_SIZE+math.random(2)
2015-05-27 11:44:06 +02:00
local h = 6+math.random(MAX_SIZE)
2013-08-23 16:32:27 +02:00
local manip = minetest.get_voxel_manip()
2015-05-27 11:44:06 +02:00
local area = r_area(manip, w, h, pos)
2013-08-23 16:32:27 +02:00
local pznodes = {}
riesenpilz.parasol(pos, pznodes, area, w, h)
2015-05-27 11:44:06 +02:00
set_vm_data(manip, pznodes, pos, t1, "parasol")
2015-05-27 11:44:06 +02:00
end
function riesenpilz.red45(pos, nodes, area, h1, h2)
local walkspace = h1 or math.random(2,MAX_SIZE)
2015-07-25 17:32:00 +02:00
local toph = h2 or math.random(MAX_SIZE)
local h = walkspace+toph+4
-- stem
for i in area:iterp(pos, {x=pos.x, y=pos.y+h, z=pos.z}) do
nodes[i] = c.stem_red
end
for i = -1,1,2 do
for l = 0, 1 do
if math.random(2) == 1 then
nodes[area:index(pos.x+i, pos.y, pos.z-l*i)] = c.stem_red
if math.random(2) == 1 then
nodes[area:index(pos.x+i, pos.y+1, pos.z-l*i)] = c.stem_red
end
end
if math.random(2) == 1 then
nodes[area:index(pos.x+l*i, pos.y, pos.z+i)] = c.stem_red
if math.random(2) == 1 then
nodes[area:index(pos.x+l*i, pos.y+1, pos.z+i)] = c.stem_red
end
end
nodes[area:index(pos.x+i, pos.y+walkspace+2, pos.z-l*i)] = c.head_red
nodes[area:index(pos.x+l*i, pos.y+walkspace+2, pos.z+i)] = c.head_red
end
nodes[area:index(pos.x, pos.y+walkspace+3, pos.z+i)] = c.head_red
nodes[area:index(pos.x+i, pos.y+walkspace+3, pos.z)] = c.head_red
for j = -1,1,2 do
nodes[area:index(pos.x+j, pos.y+walkspace+1, pos.z+i)] = c.head_red
nodes[area:index(pos.x+j*3, pos.y+walkspace+1, pos.z+i*3)] = c.head_red
for z = 1,2 do
for x = 1,2 do
for y = h-toph, h-1 do
nodes[area:index(pos.x+x*j, pos.y+y, pos.z+z*i)] = c.head_red
end
if z ~= 2
or x ~= 2
or math.random(4) ~= 2 then
nodes[area:index(pos.x+x*j, pos.y+h, pos.z+z*i)] = c.head_red
end
local zo = z+1
local xo = x+1
nodes[area:index(pos.x + xo * j, pos.y + walkspace + 2,
pos.z + zo * i)] = c.head_red
if zo ~= 3
or xo ~= 3
or math.random(2) == 1 then
nodes[area:index(pos.x + xo * j, pos.y + walkspace + 3,
pos.z + zo * i)] = c.head_red
end
end
end
end
end
-- top
for z = -1,1 do
for x = -1,1 do
nodes[area:index(pos.x+x, pos.y+h+1, pos.z+z)] = c.head_red
end
end
end
local function riesenpilz_red45(pos)
local t1 = os.clock()
local h1 = math.random(2,MAX_SIZE)
2015-07-25 17:32:00 +02:00
local h2 = math.random(MAX_SIZE)
local h = h1+h2+5
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 3, h, pos)
local pznodes = {}
riesenpilz.red45(pos, pznodes, area, h1, h2)
set_vm_data(manip, pznodes, pos, t1, "red45")
end
2015-05-27 11:44:06 +02:00
function riesenpilz.apple(pos, nodes, area)
2013-05-10 20:08:50 +02:00
local size = 5
local a = size*2
local b = size-1
2013-08-23 16:32:27 +02:00
2015-03-07 16:02:24 +01:00
for l = -b, b do
for j = 1, a-1 do
2013-05-10 20:08:50 +02:00
for k = -size, size, a do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x+k, pos.y+j, pos.z+l)] = c.red
nodes[area:index(pos.x+l, pos.y+j, pos.z+k)] = c.red
2013-05-10 20:08:50 +02:00
end
end
2015-03-07 16:02:24 +01:00
for i = -b, b do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x+i, pos.y, pos.z+l)] = c.red
nodes[area:index(pos.x+i, pos.y+a, pos.z+l)] = c.red
2013-05-10 20:08:50 +02:00
end
end
2015-03-07 16:02:24 +01:00
for i = a+1, a+b do
2014-08-11 15:31:05 +02:00
nodes[area:index(pos.x, pos.y+i, pos.z)] = c.tree
2013-05-10 20:08:50 +02:00
end
2016-01-25 19:29:23 +01:00
local d = pos.y+1
2013-05-10 20:08:50 +02:00
for i = -3,1,1 do
2016-01-25 19:29:23 +01:00
nodes[area:index(pos.x+i, d, pos.z+1)] = c.brown
2013-05-10 20:08:50 +02:00
end
for i = 0,1,1 do
2016-01-25 19:29:23 +01:00
nodes[area:index(pos.x+i+1, d, pos.z-1-i)] = c.brown
nodes[area:index(pos.x+i+2, d, pos.z-1-i)] = c.brown
2013-05-10 20:08:50 +02:00
end
2016-01-25 19:29:23 +01:00
nodes[area:index(pos.x+1, d, pos.z)] = c.brown
nodes[area:index(pos.x-3, d+1, pos.z+1)] = c.brown
2015-05-27 11:44:06 +02:00
end
local function riesenpilz_apple(pos)
2015-05-27 11:44:06 +02:00
local t1 = os.clock()
local manip = minetest.get_voxel_manip()
local area = r_area(manip, 5, 14, pos)
local pznodes = {}
riesenpilz.apple(pos, pznodes, area)
2013-08-23 16:32:27 +02:00
if not set_vm_nodes(manip, pznodes) then
return
end
2013-08-23 16:32:27 +02:00
manip:write_to_map()
2021-10-24 19:16:08 +02:00
riesenpilz.inform("an apple grew at " .. minetest.pos_to_string(pos), 3, t1)
2013-08-23 16:32:27 +02:00
manip:update_map()
2013-05-10 20:08:50 +02:00
end
2015-11-06 14:27:25 +01:00
-- 3D apple [3apple]
2013-05-10 20:08:50 +02:00
2015-11-06 14:27:25 +01:00
if riesenpilz.change_apple then
minetest.override_item("default:apple", {
drawtype = "nodebox",
tiles = {"3apple_apple_top.png", "3apple_apple_bottom.png", "3apple_apple.png"},
node_box = {
type = "fixed",
fixed = {
{-3/16, -7/16, -3/16, 3/16, 1/16, 3/16},
{-4/16, -6/16, -3/16, 4/16, 0, 3/16},
{-3/16, -6/16, -4/16, 3/16, 0, 4/16},
{-1/32, 1/16, -1/32, 1/32, 4/16, 1/32},
{-1/16, 1.6/16, 0, 1/16, 1.8/16, 1/16},
{-2/16, 1.4/16, 1/16, 1/16, 1.6/16, 2/16},
{-2/16, 1.2/16, 2/16, 0, 1.4/16, 3/16},
{-1.5/16, 1/16, .5/16, 0.5/16, 1.2/16, 2.5/16},
}
},
})
end
2013-05-10 20:08:50 +02:00
2015-11-06 14:27:25 +01:00
-- Mushroom Nodes
2013-01-29 18:38:49 +01:00
2013-04-04 18:44:35 +02:00
2015-11-06 14:27:25 +01:00
local abm_allowed = true
local disallowed_ps = {}
2013-04-04 18:44:35 +02:00
for name, ndata in pairs({
2015-07-05 21:01:34 +02:00
brown = {
2014-12-05 22:50:57 +01:00
description = "brown mushroom",
2014-12-07 17:45:58 +01:00
box = {
{-0.15, -0.2, -0.15, 0.15, -0.1, 0.15},
{-0.2, -0.3, -0.2, 0.2, -0.2, 0.2},
{-0.05, -0.5, -0.05, 0.05, -0.3, 0.05}
},
2014-12-05 22:50:57 +01:00
growing = {
2014-12-05 23:52:55 +01:00
r = {min=3, max=4},
grounds = {soil=1, crumbly=3},
neighbours = {"default:tree"},
2014-12-07 16:53:31 +01:00
light = {min=1, max=7},
interval = 100,
chance = 18,
2014-12-05 23:52:55 +01:00
},
hp = 2,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
red = {
2014-12-05 22:50:57 +01:00
description = "red mushroom",
2014-12-07 17:45:58 +01:00
box = {
{-1/16, -8/16, -1/16, 1/16, -6/16, 1/16},
{-3/16, -6/16, -3/16, 3/16, -5/16, 3/16},
{-4/16, -5/16, -4/16, 4/16, -4/16, 4/16},
{-3/16, -4/16, -3/16, 3/16, -3/16, 3/16},
{-2/16, -3/16, -2/16, 2/16, -2/16, 2/16}
},
2014-12-05 23:52:55 +01:00
growing = {
r = {min=4, max=5},
grounds = {soil=2},
neighbours = {"default:water_flowing"},
2014-12-07 16:53:31 +01:00
light = {min=4, max=13},
2014-12-05 23:52:55 +01:00
interval = 50,
chance = 30,
},
hp = -2,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
fly_agaric = {
2014-12-05 22:50:57 +01:00
description = "fly agaric",
2014-12-07 17:45:58 +01:00
box = {
{-0.05, -0.5, -0.05, 0.05, 1/20, 0.05},
{-3/20, -6/20, -3/20, 3/20, 0, 3/20},
{-4/20, -2/20, -4/20, 4/20, -4/20, 4/20}
},
2014-12-05 23:52:55 +01:00
growing = {
r = 4,
grounds = {soil=1, crumbly=3},
neighbours = {"default:pinetree"},
2014-12-07 16:53:31 +01:00
light = {min=2, max=10},
2014-12-05 23:52:55 +01:00
interval = 101,
chance = 30,
},
hp = -6,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
lavashroom = {
2014-12-05 22:50:57 +01:00
description = "Lavashroom",
2014-12-07 17:45:58 +01:00
box = {
{-1/16, -8/16, -1/16, 1/16, -6/16, 1/16},
{-2/16, -6/16, -2/16, 2/16, 0, 2/16},
{-3/16, -5/16, -3/16, 3/16, -1/16, 3/16},
{-4/16, -4/16, -4/16, 4/16, -2/16, 4/16}
},
2014-12-05 23:52:55 +01:00
growing = {
r = {min=5, max=6},
grounds = {cracky=3},
neighbours = {"default:lava_source"},
2015-05-27 10:47:37 +02:00
light = {min=10, max=12},
2014-12-05 23:52:55 +01:00
interval = 1010,
chance = 60,
},
hp = -1,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
glowshroom = {
2014-12-05 22:50:57 +01:00
description = "Glowshroom",
2014-12-07 17:45:58 +01:00
box = {
2015-07-05 21:01:34 +02:00
{-1/16, -8/16, -1/16, 1/16, -1/16, 1/16},
{-2/16, -3/16, -2/16, 2/16, -2/16, 2/16},
{-3/16, -5/16, -3/16, 3/16, -3/16, 3/16},
2014-12-07 17:45:58 +01:00
{-3/16, -7/16, -3/16, -2/16, -5/16, -2/16},
2015-07-05 21:01:34 +02:00
{3/16, -7/16, -3/16, 2/16, -5/16, -2/16},
{-3/16, -7/16, 3/16, -2/16, -5/16, 2/16},
{3/16, -7/16, 3/16, 2/16, -5/16, 2/16}
2014-12-07 17:45:58 +01:00
},
2014-12-05 23:52:55 +01:00
growing = {
r = 3,
grounds = {soil=1, crumbly=3},
neighbours = {"default:stone"},
light = 0,
2014-12-06 15:16:22 +01:00
interval = 710,
2014-12-07 16:53:31 +01:00
chance = 320,
2014-12-05 23:52:55 +01:00
},
hp = -2,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
nether_shroom = {
2014-12-05 22:50:57 +01:00
description = "Nether mushroom",
2014-12-07 17:45:58 +01:00
box = {
{-1/16, -8/16, -1/16, 1/16, -2/16, 1/16},
{-2/16, -6/16, -2/16, 2/16, -5/16, 2/16},
{-3/16, -2/16, -3/16, 3/16, 0, 3/16},
{-4/16, -1/16, -4/16, 4/16, 1/16,-2/16},
{-4/16, -1/16, 2/16, 4/16, 1/16, 4/16},
{-4/16, -1/16, -2/16,-2/16, 1/16, 2/16},
{ 2/16, -1/16, -2/16, 4/16, 1/16, 2/16}
},
2014-12-05 23:52:55 +01:00
burntime = 6,
hp = -3,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
parasol = {
2014-12-05 22:50:57 +01:00
description = "white parasol mushroom",
2014-12-07 17:45:58 +01:00
box = {
{-1/16, -8/16, -1/16, 1/16, 0, 1/16},
{-2/16, -6/16, -2/16, 2/16, -5/16, 2/16},
{-5/16, -4/16, -5/16, 5/16, -3/16, 5/16},
{-4/16, -3/16, -4/16, 4/16, -2/16, 4/16},
{-3/16, -2/16, -3/16, 3/16, -1/16, 3/16}
},
2014-12-05 23:52:55 +01:00
growing = {
r = {min=3, max=5},
grounds = {soil=1, crumbly=3},
neighbours = {"default:pinetree"},
2014-12-07 16:53:31 +01:00
light = {min=1, max=11},
2014-12-06 15:16:22 +01:00
interval = 51,
chance = 36,
2014-12-05 23:52:55 +01:00
},
hp = 3,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
red45 = {
2014-12-05 22:50:57 +01:00
description = "45 red mushroom",
2014-12-07 17:45:58 +01:00
box = {
2015-07-05 21:01:34 +02:00
{-1/16, -0.5, -1/16, 1/16, 1/8, 1/16},
{-3/16, 1/8, -3/16, 3/16, 1/4, 3/16},
2014-12-07 17:45:58 +01:00
{-5/16, -1/4, -5/16, -1/16, 1/8, -1/16},
2015-07-05 21:01:34 +02:00
{1/16, -1/4, -5/16, 5/16, 1/8, -1/16},
{-5/16, -1/4, 1/16, -1/16, 1/8, 5/16},
{1/16, -1/4, 1/16, 5/16, 1/8, 5/16}
2014-12-07 17:45:58 +01:00
},
2014-12-05 23:52:55 +01:00
growing = {
r = {min=3, max=4},
grounds = {soil=2},
neighbours = {"default:water_source"},
2014-12-07 16:53:31 +01:00
light = {min=2, max=7},
2014-12-06 15:16:22 +01:00
interval = 1000,
chance = 180,
2014-12-05 23:52:55 +01:00
},
hp = 1,
2014-12-05 22:50:57 +01:00
},
2015-07-05 21:01:34 +02:00
brown45 = {
2014-12-05 22:50:57 +01:00
description = "45 brown mushroom",
2014-12-07 17:45:58 +01:00
box = {
{-1/16, -0.5, -1/16, 1/16, 1/16, 1/16},
2015-07-05 21:01:34 +02:00
{-3/8, 1/8, -7/16, 3/8, 1/4, 7/16},
{-7/16, 1/8, -3/8, 7/16, 1/4, 3/8},
{-3/8, 1/4, -3/8, 3/8, 5/16, 3/8},
{-3/8, 1/16, -3/8, 3/8, 1/8, 3/8}
2014-12-07 17:45:58 +01:00
},
2014-12-05 23:52:55 +01:00
growing = {
r = {min=2, max=3},
grounds = {tree=1},
neighbours = {"default:water_flowing"},
light = {min=7, max=11},
2014-12-06 15:16:22 +01:00
interval = 100,
chance = 20,
2014-12-05 23:52:55 +01:00
},
hp = 1,
2014-12-05 22:50:57 +01:00
},
2015-11-06 14:27:25 +01:00
}) do
local burntime = ndata.burntime or 1
2014-12-05 22:50:57 +01:00
local box = {
type = "fixed",
fixed = ndata.box
2014-12-05 22:50:57 +01:00
}
local nd = "riesenpilz:" .. name
2014-12-06 15:16:22 +01:00
minetest.register_node(nd, {
description = ndata.description,
tiles = {
--~ {name = "riesenpilz_"..name.."_top.png", tileable_vertical = false},
--~ {name = "riesenpilz_"..name.."_bottom.png", tileable_vertical = false},
--~ {name = "riesenpilz_"..name.."_side.png", tileable_vertical = false},
"riesenpilz_" .. name .. "_top.png",
"riesenpilz_" .. name .. "_bottom.png",
"riesenpilz_" .. name .. "_side.png",
},
use_texture_alpha = "opaque",
2014-12-05 22:50:57 +01:00
inventory_image = "riesenpilz_"..name.."_side.png",
walkable = false,
buildable_to = true,
drawtype = "nodebox",
paramtype = "light",
groups = {snappy=3,flammable=2,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
node_box = box,
selection_box = box,
furnace_burntime = burntime,
on_secondary_use = minetest.item_eat(ndata.hp),
2014-12-05 22:50:57 +01:00
})
2013-01-29 18:38:49 +01:00
local g = ndata.growing
2014-12-06 15:16:22 +01:00
if g then
local grounds = g.grounds
local nds = {}
for n in pairs(grounds) do
table.insert(nds, "group:"..n)
end
local nbs = table.copy(g.neighbours)
table.insert(nbs, "air")
2014-12-07 16:53:31 +01:00
local rmin, rmax, lmin, lmax
2014-12-06 15:16:22 +01:00
local r = g.r
if type(r) == "table" then
rmin = r.min
rmax = r.max
else
rmin = r or 3
rmax = rmin
end
local l = g.light
if type(l) == "table" then
lmin = l.min
lmax = l.max
else
lmin = l or 3
lmax = lmin
end
minetest.register_abm({
nodenames = nds,
neighbors = g.neighbours,
interval = g.interval,
chance = g.chance,
catch_up = false,
2014-12-06 15:16:22 +01:00
action = function(pos, node)
2014-12-07 16:53:31 +01:00
if not abm_allowed then
return
end
-- don't try to spawn them on the same positions again
for _,p in pairs(disallowed_ps) do
if vector.equals(p, pos) then
return
end
end
2014-12-06 15:16:22 +01:00
-- don't spawn mushroom circles next to other ones
if minetest.find_node_near(pos, rmax, nd) then
return
end
-- spawn them around the right nodes
local data = minetest.registered_nodes[node.name]
if not data
or not data.groups then
return
end
local groups = data.groups
for groupname, groupvalue in pairs(grounds) do
if groups[groupname] ~= groupvalue then
2014-12-06 15:16:22 +01:00
return
end
end
-- find their neighbours
for _,n in pairs(nbs) do
if not minetest.find_node_near(pos, rmin, n) then
return
end
end
-- should disallow lag
abm_allowed = false
minetest.after(2, function() abm_allowed = true end)
disallowed_ps[#disallowed_ps+1] = pos
2014-12-06 15:16:22 +01:00
-- witch circles
2014-12-07 17:41:04 +01:00
local ps = {}
2021-10-24 19:16:08 +02:00
for _,p in pairs(riesenpilz.circle(math.random(rmin, rmax))) do
p = vector.add(pos, p)
2014-12-06 15:16:22 +01:00
-- currently 3 is used here, approved by its use in the mapgen
if math.random(3) == 1 then
-- don't only use the current y for them
2014-12-07 15:33:43 +01:00
for y = 1,-1,-1 do
local pos_above = {x=p.x, y=p.y+y, z=p.z}
if minetest.get_node(pos_above).name ~= "air" then
2014-12-06 15:16:22 +01:00
break
end
local f = minetest.get_node({x=p.x, y=p.y+y-1, z=p.z}).name
if f ~= "air" then
2015-06-16 19:30:22 +02:00
-- they grown on specific nodes
local data_ground = minetest.registered_nodes[f]
if data_ground
and data_ground.walkable
and data_ground.groups
and (not data_ground.drawtype
or data_ground.drawtype == "normal"
2014-12-06 15:16:22 +01:00
) then
2015-06-16 19:30:22 +02:00
local ground_disallowed
for n,i in pairs(grounds) do
if data_ground.groups[n] ~= i then
2015-06-16 19:30:22 +02:00
ground_disallowed = true
break
end
end
if not ground_disallowed then
-- they also need specific light strengths
local light = minetest.get_node_light(
pos_above, 0.5)
2015-06-16 19:30:22 +02:00
if light >= lmin
and light <= lmax then
ps[#ps+1] = pos_above
2015-06-16 19:30:22 +02:00
end
2014-12-06 15:16:22 +01:00
end
end
break
end
end
end
end
2014-12-07 17:41:04 +01:00
if not ps[1] then
return
2014-12-07 16:53:31 +01:00
end
2014-12-07 17:41:04 +01:00
-- place them
for _,p in pairs(ps) do
minetest.set_node(p, {name=nd})
end
2014-12-28 22:01:33 +01:00
minetest.log("info", "[riesenpilz] "..nd.." mushrooms grew at "..minetest.pos_to_string(pos))
2014-12-06 15:16:22 +01:00
end
})
end
end
2013-04-04 18:44:35 +02:00
2014-12-07 16:53:31 +01:00
-- disallow abms when the server is lagging
minetest.register_globalstep(function(dtime)
if dtime > 0.5
and abm_allowed then
abm_allowed = false
minetest.after(2, function() abm_allowed = true end)
--minetest.chat_send_all(dtime)
end
end)
2013-04-04 18:44:35 +02:00
2015-11-06 14:27:25 +01:00
-- Big Mushroom Nodes
2013-04-04 18:44:35 +02:00
2015-11-06 14:27:25 +01:00
local head_sounds = default.node_sound_wood_defaults({
footstep = {name="riesenpilz_head", gain=0.1},
place = {name="default_place_node", gain=0.5},
dig = {name="riesenpilz_head", gain=0.2},
dug = {name="riesenpilz_stem", gain=0.1}
})
2015-12-28 16:54:35 +01:00
local add_fence = minetest.register_fence
local node_groups = {oddly_breakable_by_hand=3, fall_damage_add_percent=-80, bouncy=10}
2013-04-04 18:44:35 +02:00
for _, ndata in ipairs({
2015-03-08 13:28:01 +01:00
{
typ = "stem",
description = "white",
textures = {"stem_top.png", "stem_top.png", "stem_white.png"},
},
{
typ = "stem",
name = "brown",
textures = {"stem_top.png", "stem_top.png", "stem_brown.png"},
2015-12-28 16:54:35 +01:00
fence = false,
2015-03-08 13:28:01 +01:00
},
{
typ = "stem",
name = "blue",
textures = {"stem_top.png","stem_top.png","stem_blue.png"},
2015-12-28 16:54:35 +01:00
fence = false,
2015-03-08 13:28:01 +01:00
},
{
typ = "stem",
name = "red",
textures = {"stem_red45_top.png","stem_red45_top.png","stem_red45.png"},
},
2015-03-08 13:28:01 +01:00
{
name = "lamellas",
description = "giant mushroom lamella",
textures = "lamellas.png",
sapling = "lamellas"
},
{
typ = "head",
name = "red",
textures = {"head.png", "lamellas.png", "head.png"},
sapling = "red"
},
{
typ = "head",
name = "orange",
textures = "head_orange.png",
sapling = "lavashroom"
},
{
typ = "head",
name = "yellow",
textures = "head_yellow.png",
sapling = "lavashroom"
},
{
typ = "head",
name = "brown",
textures = {"brown_top.png", "lamellas.png", "brown_top.png"},
2015-12-28 16:54:35 +01:00
sapling = "brown",
2015-03-08 13:28:01 +01:00
},
{
typ = "head",
name = "brown_full",
description = "full brown",
textures = "brown_top.png",
2015-12-28 16:54:35 +01:00
sapling = "brown",
fence = false,
2015-03-08 13:28:01 +01:00
},
{
typ = "head",
name = "blue_bright",
description = "blue bright",
textures = "head_blue_bright.png",
sapling = "glowshroom"
},
{
typ = "head",
name = "blue",
textures = "head_blue.png",
sapling = "glowshroom"
},
{
typ = "head",
name = "white",
textures = "head_white.png",
sapling = "parasol"
},
{
typ = "head",
2019-11-04 12:26:58 +01:00
name = "beige",
textures = {"head_beige.png", "head_white.png", "head_beige.png"},
2015-03-08 13:28:01 +01:00
sapling = "parasol"
},
{
typ = "head",
name = "brown_bright",
description = "brown bright",
textures = {"head_brown_bright.png", "head_white.png", "head_brown_bright.png"},
sapling = "parasol"
},
2015-11-06 14:27:25 +01:00
}) do
2015-03-08 13:28:01 +01:00
-- fill missing stuff
local textures = ndata.textures
ndata.description = ndata.description or ndata.name
2015-03-08 13:28:01 +01:00
if type(textures) == "string" then
textures = {textures}
end
for i = 1,#textures do
textures[i] = "riesenpilz_"..textures[i]
end
local nodename = "riesenpilz:"
local desctiption,sounds = "giant mushroom "
if ndata.typ == "stem" then
desctiption = desctiption .. "stem " .. ndata.description
nodename = nodename .. "stem" ..
((ndata.name and "_" .. ndata.name) or "")
2015-03-08 13:28:01 +01:00
sounds = default.node_sound_wood_defaults({
footstep = {name="riesenpilz_stem", gain=0.2},
2015-03-14 15:39:20 +01:00
place = {name="default_place_node", gain=0.5},
2015-03-08 13:28:01 +01:00
dig = {name="riesenpilz_stem", gain=0.4},
dug = {name="default_wood_footstep", gain=0.3}
})
elseif ndata.typ == "head" then
desctiption = desctiption .. "head " .. ndata.description
nodename = nodename .. "head_" .. ndata.name
2015-03-14 15:39:20 +01:00
sounds = head_sounds
2015-03-08 13:28:01 +01:00
else
nodename = nodename .. ndata.name
desctiption = desctiption .. ndata.description
2015-03-08 13:28:01 +01:00
end
local drop = ndata.sapling and {max_items = 1, items = {
{items = {"riesenpilz:" .. ndata.sapling}, rarity = 20},
2015-03-08 13:28:01 +01:00
{items = {nodename}, rarity = 1}
}}
minetest.register_node(nodename, {
description = desctiption,
2014-12-07 17:41:04 +01:00
tiles = textures,
groups = node_groups,
2015-03-08 13:28:01 +01:00
drop = drop,
sounds = sounds,
2014-12-07 17:41:04 +01:00
})
2015-12-28 16:54:35 +01:00
if add_fence
and ndata.fence ~= false then
2015-12-28 16:54:35 +01:00
add_fence({fence_of = nodename})
end
2013-10-18 22:05:21 +02:00
end
2013-04-04 18:44:35 +02:00
minetest.register_node("riesenpilz:head_red_side", {
2014-12-05 22:18:44 +01:00
description = "giant mushroom head red side",
2013-08-23 16:32:27 +02:00
tiles = {"riesenpilz_head.png", "riesenpilz_lamellas.png", "riesenpilz_head.png",
2013-04-04 18:44:35 +02:00
"riesenpilz_head.png", "riesenpilz_head.png", "riesenpilz_lamellas.png"},
2013-01-29 18:38:49 +01:00
paramtype2 = "facedir",
groups = node_groups,
2013-01-29 18:38:49 +01:00
drop = {max_items = 1,
2013-04-04 18:44:35 +02:00
items = {{items = {"riesenpilz:fly_agaric"},rarity = 20,},
2015-03-14 15:39:20 +01:00
{items = {"riesenpilz:head_red"},rarity = 1,}}},
sounds = head_sounds
2013-01-29 18:38:49 +01:00
})
2015-03-08 13:28:01 +01:00
2013-04-24 20:53:20 +02:00
minetest.register_node("riesenpilz:ground", {
2014-12-05 22:18:44 +01:00
description = "dirt with rotten grass",
2015-07-17 20:47:04 +02:00
tiles = {"riesenpilz_ground_top.png","default_dirt.png",
{name="default_dirt.png^riesenpilz_ground_side.png", tileable_vertical = false}
},
2013-04-24 20:53:20 +02:00
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults(),
drop = 'default:dirt'
})
2013-01-29 18:38:49 +01:00
2014-08-11 15:31:05 +02:00
c = {
air = minetest.get_content_id("air"),
2013-08-23 16:32:27 +02:00
2014-08-11 15:31:05 +02:00
stem = minetest.get_content_id("riesenpilz:stem"),
head_red = minetest.get_content_id("riesenpilz:head_red"),
lamellas = minetest.get_content_id("riesenpilz:lamellas"),
2013-08-23 16:32:27 +02:00
2014-08-11 15:31:05 +02:00
head_brown = minetest.get_content_id("riesenpilz:head_brown"),
2013-08-23 16:32:27 +02:00
2014-08-11 15:31:05 +02:00
head_red_side = minetest.get_content_id("riesenpilz:head_red_side"),
2014-04-03 20:17:18 +02:00
2014-08-11 15:31:05 +02:00
stem_brown = minetest.get_content_id("riesenpilz:stem_brown"),
head_brown_full = minetest.get_content_id("riesenpilz:head_brown_full"),
head_orange = minetest.get_content_id("riesenpilz:head_orange"),
head_yellow = minetest.get_content_id("riesenpilz:head_yellow"),
2013-08-23 16:32:27 +02:00
2014-08-11 15:31:05 +02:00
stem_blue = minetest.get_content_id("riesenpilz:stem_blue"),
head_blue = minetest.get_content_id("riesenpilz:head_blue"),
head_blue_bright = minetest.get_content_id("riesenpilz:head_blue_bright"),
2013-08-23 16:32:27 +02:00
2014-08-11 15:31:05 +02:00
head_white = minetest.get_content_id("riesenpilz:head_white"),
2019-11-04 12:26:58 +01:00
head_beige = minetest.get_content_id("riesenpilz:head_beige"),
2014-08-11 15:31:05 +02:00
head_brown_bright = minetest.get_content_id("riesenpilz:head_brown_bright"),
2013-08-23 16:32:27 +02:00
stem_red = minetest.get_content_id("riesenpilz:stem_red"),
2014-08-11 15:31:05 +02:00
red = minetest.get_content_id("default:copperblock"),
brown = minetest.get_content_id("default:desert_stone"),
tree = minetest.get_content_id("default:tree"),
}
2013-08-23 16:32:27 +02:00
2013-04-04 18:44:35 +02:00
2015-11-06 14:27:25 +01:00
-- Growing
2013-01-29 18:38:49 +01:00
2013-04-04 18:44:35 +02:00
minetest.register_tool("riesenpilz:growingtool", {
2014-12-05 22:18:44 +01:00
description = "growingtool",
2013-04-04 18:44:35 +02:00
inventory_image = "riesenpilz_growingtool.png",
2013-01-29 18:38:49 +01:00
})
local grow_functions = {
["riesenpilz:red"] = riesenpilz_hybridpilz,
["riesenpilz:fly_agaric"] = riesenpilz_minecraft_fliegenpilz,
["riesenpilz:brown"] = riesenpilz_brauner_minecraftpilz,
["riesenpilz:lavashroom"] = riesenpilz_lavashroom,
["riesenpilz:glowshroom"] = riesenpilz_glowshroom,
["riesenpilz:parasol"] = riesenpilz_parasol,
["riesenpilz:red45"] = riesenpilz_red45,
["default:apple"] = riesenpilz_apple
}
local function get_grow(name)
if grow_functions[name] then
return grow_functions[name]
end
local is = {}
for i = 1,#minetest.registered_abms do
local ad = minetest.registered_abms[i]
if type(ad.nodenames) ~= "table" then
minetest.log("warning", "ABM nodenames is not a table: " ..
dump(ad))
return
end
if ad.chance > 1
and table.indexof(ad.nodenames, name) ~= -1 then
is[#is+1] = ad.action
end
end
local func
if is[1] then
2016-07-22 21:51:44 +02:00
function func(pos, node)
for i = 1,#is do
2016-07-22 21:51:44 +02:00
is[i](pos, node)
end
end
else
local def = minetest.registered_nodes[name]
if def then
if def.on_timer then
func = def.on_timer
else
func = function(pos, _, player)
if def.on_place then
def.on_place(ItemStack(name), player, {
type = "node",
under = vector.new(pos),--{x=pos.x, y=pos.y-1, z=pos.z},
above = vector.new(pos)
})
end
if def.after_place_node then
def.after_place_node(pos)
end
end
end
else
func = function() end
end
end
grow_functions[name] = func
return func
end
2015-11-06 14:27:25 +01:00
minetest.register_on_punchnode(function(pos, node, player)
if player:get_wielded_item():get_name() ~= "riesenpilz:growingtool"
or minetest.is_protected(pos, player:get_player_name()) then
return
end
local func = get_grow(node.name)
if func then
func(pos, node, player)
2013-01-29 18:38:49 +01:00
end
2013-04-04 18:44:35 +02:00
end)
2013-04-24 20:53:20 +02:00
2016-01-23 11:33:55 +01:00
-- Uses
2015-11-06 14:27:25 +01:00
2016-01-23 11:33:55 +01:00
-- mush45's meal
2015-11-06 14:27:25 +01:00
minetest.register_craftitem("riesenpilz:mush45_meal", {
description = "Mushroom Meal",
inventory_image = "riesenpilz_mush45_meal.png",
on_use = minetest.item_eat(6),
})
minetest.register_craft({
output = "riesenpilz:mush45_meal 4",
recipe = {
{"riesenpilz:brown45", "riesenpilz:red45"},
{"riesenpilz:red45", "riesenpilz:brown45"},
}
})
2016-01-23 11:33:55 +01:00
--[[ unfinished
if minetest.global_exists(technic) then
if minetest.global_exists(digilines) then
-- digiline light value detector
minetest.register_node("riesenpilz:light_detector" {
tiles = {"riesenpilz_light_detector.png"},
paramtype = "light",
digiline = {
receive = function(pos)
local light = minetest.get_node_light(pos)
send("light_detector", light)
end,
},
--sounds = ,
})
--technic.comp({"riesenpilz:glowshroom 10", "coal"}, "riesenpilz:light_detector")
end
--[ [
if minetest.global_exists(3darmor) then add to depends
--lavashroom skin armor, swimming in lava possible
minetest.register_craftitem("riesenpilz:lavashroom_flesh", {
description = "lavashroom's flesh",
inventory_image = "riesenpilz_lavashroom_flesh.png",
on_use = minetest.item_eat(3),
})
minetest.register_craftitem("riesenpilz:lavashroom_skin", {
description = "lavashroom's skin",
inventory_image = "riesenpilz_lavashroom_skin.png",
})
minetest.register_craftitem("riesenpilz:antilava_plate", {
description = "lava protecting plate",
inventory_image = "riesenpilz_antilava_plate.png",
})
technic.centri("riesenpilz:lavashroom", {"riesenpilz:lavashroom_flesh", "riesenpilz:lavashroom_skin"})
technic.comp("riesenpilz:lavashroom_skin 5", "riesenpilz:antilava_plate")
armor_register(plate blah)
end--] ]
})
end--]]
2015-11-06 14:27:25 +01:00
2013-04-24 20:53:20 +02:00
if riesenpilz.enable_mapgen then
2015-11-06 14:27:25 +01:00
dofile(modpath.."mapgen.lua")
2013-04-24 20:53:20 +02:00
end
2019-11-04 12:26:58 +01:00
-- Legacy
minetest.register_alias("riesenpilz:head_binge", "riesenpilz:head_beige")
2015-08-05 10:35:47 +02:00
local time = math.floor(tonumber(os.clock()-load_time_start)*100+0.5)/100
local msg = "[riesenpilz] loaded after ca. "..time
if time > 0.05 then
print(msg)
else
minetest.log("info", msg)
end