extrablocks/init.lua

846 lines
21 KiB
Lua
Raw Normal View History

2014-01-01 09:04:52 -08:00
local load_time_start = os.clock()
2013-02-08 11:31:22 -08:00
--Node------------------------------------------------------------------------------------
2013-05-28 11:56:36 -07:00
local function orenode(name, desc)
2013-02-08 11:31:22 -08:00
minetest.register_node("extrablocks:"..name.."_ore", {
2013-04-12 09:58:02 -07:00
description = desc,
2013-08-23 07:16:54 -07:00
tiles = {"default_stone.png^extrablocks_"..name.."_ore.png"},
2013-02-08 11:31:22 -08:00
groups = {cracky=3},
2013-05-28 11:56:36 -07:00
drop = "extrablocks:"..name.."_lump",
2013-02-08 11:31:22 -08:00
sounds = default.node_sound_stone_defaults(),
})
end
local function monode(name, desc, ligh)
minetest.register_node("extrablocks:"..name, {
description = desc,
2013-08-23 07:16:54 -07:00
tiles = {"extrablocks_"..name..".png"},
2013-02-08 11:31:22 -08:00
light_source = ligh,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
end
2013-05-18 11:22:04 -07:00
local STONELIKENODES = {
2015-02-27 13:11:32 -08:00
{"marble_ore", "marble ore"},
2013-05-28 11:56:36 -07:00
{"marble_tiling", "Tiling"},
2015-02-27 13:11:32 -08:00
{"marble_clean", "marble"},
{"lapis_lazuli_block", "lapis lazuli Block"},
2013-05-28 11:56:36 -07:00
{"previous_cobble", "Previous Cobblestone"},
{"space", "Space"},
{"special", "Special"},
{"onefootstep", "One Footstep"},
{"coalblock", "Coalblock"},
{"dried_dirt", "Dried Dirt"},
{"wall", "Wall"},
{"mossywall", "Mossy Wall"},
{"stonebrick", "Alternative Stone Brick"},
2013-06-06 09:12:36 -07:00
{"fokni_gneb", "Fokni Gneb"},
{"fokni_gnebbrick", "Fokni Gneb Brick"},
2013-05-28 11:56:36 -07:00
}
2015-02-20 10:37:25 -08:00
local moss_mod = rawget(_G, "moss") and true
if moss_mod then
minetest.register_alias("extrablocks:mossystonebrick", "default:mossystonebrick")
minetest.register_alias("stairs:stair_extrablocks_mossystonebrick", "stairs:stair_mossystonebrick")
minetest.register_alias("stairs:slab_extrablocks_mossystonebrick", "stairs:slab_mossystonebrick")
else
table.insert(STONELIKENODES, {"mossystonebrick", "Mossy Stone Brick"})
end
for _,i in pairs(STONELIKENODES) do
2014-06-14 07:34:44 -07:00
local name, desc = unpack(i)
monode(name, desc, 0)
2014-09-06 07:18:52 -07:00
stairs.register_stair_and_slab("extrablocks_"..name, "extrablocks:"..name,
2014-06-14 07:34:44 -07:00
{cracky=3},
{"extrablocks_"..name..".png"},
desc.." Stair",
desc.." Slab",
default.node_sound_stone_defaults()
)
2013-05-18 11:22:04 -07:00
end
2013-02-08 11:31:22 -08:00
2015-02-27 13:11:32 -08:00
orenode("lapis_lazuli", "lapis lazuli ore")
orenode("iringnite", "Iringnite ore")
orenode("fokni_gneb", "Fokni Gneb ore")
2013-02-08 11:31:22 -08:00
2013-05-11 02:19:41 -07:00
monode("goldbrick", "Goldbrick", 15)
monode("goldblock", "Goldblock", 15)
monode("gold", "Gold", 15)
monode("acid", "Acid", 15)
2013-02-08 11:31:22 -08:00
2013-04-12 09:58:02 -07:00
minetest.register_node("extrablocks:goldstone", {
description = "Gold in Stone",
2013-08-23 07:16:54 -07:00
tiles = {"default_stone.png^extrablocks_goldstone.png"},
2013-05-11 02:19:41 -07:00
light_source = 15,
2015-03-13 11:51:51 -07:00
paramtype = "light",
2013-04-12 09:58:02 -07:00
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
2013-05-28 11:56:36 -07:00
minetest.register_node("extrablocks:iringnite_block", {
description = "Iringnite Block",
tiles = {"extrablocks_iringnite_block.png"},
groups = {cracky=1,level=2},
sounds = default.node_sound_stone_defaults({
dig = {name="extrablocks_iringnite", gain=0.4},
}),
})
2014-08-08 04:40:02 -07:00
minetest.register_node("extrablocks:invisible_path", {
description = "APAT",
tiles = {"extrablocks_inv_path.png"},
groups = {cracky=1,level=2},
use_texture_alpha = true,
})
minetest.register_abm({
nodenames = {"extrablocks:invisible_path"},
neighbors = {},
interval = 50,
chance = 1,
action = function(pos)
for i = -1,1,2 do
for _,p in pairs({
{x=pos.x, y=pos.y, z=pos.z+i},
{x=pos.x, y=pos.y+i, z=pos.z},
{x=pos.x+i, y=pos.y, z=pos.z},
}) do
local n = minetest.get_node(p).name
if n ~= "air"
and n ~= "extrablocks:invisible_path" then
minetest.remove_node(pos)
return
end
end
end
end,
})
2013-02-08 11:31:22 -08:00
----------------------------------------plants----------------------------------------------------------------------------
local function plantnode(name, desc, selbox)
minetest.register_node("extrablocks:"..name, {
description = desc,
2013-06-06 09:12:36 -07:00
inventory_image = "extrablocks_"..name..".png",
tiles = {"extrablocks_"..name..".png"},
groups = {snappy=3,flammable=2,flora=1,attached_node=1},
2013-02-08 11:31:22 -08:00
sounds = default.node_sound_leaves_defaults(),
drawtype = "plantlike",
paramtype = "light",
2014-03-15 06:35:39 -07:00
waving = 1,
2013-02-08 11:31:22 -08:00
walkable = false,
2013-05-18 11:22:04 -07:00
buildable_to = true,
2013-02-08 11:31:22 -08:00
selection_box = {type = "fixed",fixed = selbox},
2013-06-06 09:12:36 -07:00
furnace_burntime = 1,
2013-02-08 11:31:22 -08:00
})
end
plantnode("wheat", "Weizen", {-1/3, -1/2, -1/3, 1/3, 1/4, 1/3})
plantnode("dry_grass", "Dry Grass", {-1/3, -1/2, -1/3, 1/3, 1/4, 1/3})
2013-07-19 09:41:39 -07:00
minetest.register_node("extrablocks:bush", {
description = "Bush",
drawtype = "nodebox",
tiles = {"extrablocks_bush_top.png", "extrablocks_bush_bottom.png", "extrablocks_bush.png"},
inventory_image = "extrablocks_bush.png",
paramtype = "light",
walkable = false,
node_box = {
type = "fixed",
fixed = {
{-1/16, -8/16, -1/16, 1/16, -6/16, 1/16},
{-4/16, -6/16, -4/16, 4/16, 5/16, 4/16},
{-5/16, -5/16, -5/16, 5/16, 3/16, 5/16},
{-6/16, -4/16, -6/16, 6/16, 2/16, 6/16},
{-6.5/16, -3/16, -6.5/16, 6.5/16, -2/16, 6.5/16},
{-3/16, 5/16, -3/16, 3/16, 6/16, 3/16},
{-2/16, 5/16, -2/16, 2/16, 7/16, 2/16},
}
},
groups = {snappy=3,flammable=2,attached_node=1},
sounds = default.node_sound_defaults(),
})
2013-02-08 11:31:22 -08:00
---------------------------------------------------pl-----------------------------------------------------------------
local function fencelikenode(name, desc)
local img, img2 = "extrablocks_"..name..".png", "extrablocks_fence_"..name..".png"
minetest.register_node("extrablocks:fence_"..name, {
description = desc,
drawtype = "fencelike",
tiles = {img},
inventory_image = img2,
wield_image = img2,
paramtype = "light",
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2},
})
end
fencelikenode("special", "Specialfence")
fencelikenode("repellent", "Repellent Fence")
2013-03-24 05:40:42 -07:00
fencelikenode("stonebrick", "Alternative Stone Brick Fence")
2013-06-06 09:12:36 -07:00
fencelikenode("fokni_gneb", "Fokni Gneb Fence")
2013-02-08 11:31:22 -08:00
local function raillikenode(name, desc)
local img = "extrablocks_"..name..".png"
minetest.register_node("extrablocks:"..name, {
description = desc,
drawtype = "raillike",
2013-08-23 07:16:54 -07:00
tiles = {img},
2013-02-08 11:31:22 -08:00
inventory_image = img,
selection_box = {type = "fixed",fixed = {-0.5, -1/2, -0.5, 0.5, -0.45, 0.5},},
paramtype = "light",
walkable = false,
groups = {oddly_breakable_by_hand=3},
})
end
raillikenode("repellent", "Repellent Covering")
raillikenode("radi", "!!!")
minetest.register_node("extrablocks:tort", {
2013-08-23 07:16:54 -07:00
tiles = {"extrablocks_to_t.png", "extrablocks_to_b.png", "extrablocks_to_s2.png"},
2013-02-08 11:31:22 -08:00
groups = {crumbly=2},
drop = "extrablocks:torte 2",
sounds = default.node_sound_dirt_defaults
})
minetest.register_node("extrablocks:torte", {
description = "Torte",
drawtype = "nodebox",
tiles = {"extrablocks_to_t.png", "extrablocks_to_b.png", "extrablocks_to_s.png"},
paramtype = "light",
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
groups = {crumbly=3},
sounds = default.node_sound_dirt_defaults,
on_place = function(itemstack, placer, pointed_thing)
2013-03-24 04:49:00 -07:00
if pointed_thing.type ~= "node" then
return itemstack
end
local slabpos = nil
local slabnode = nil
local p0 = pointed_thing.under
local p1 = pointed_thing.above
2014-04-03 10:50:37 -07:00
local n0 = minetest.get_node(p0)
2013-03-24 04:49:00 -07:00
if n0.name == "extrablocks:torte" and p0.y+1 == p1.y then
slabpos = p0
slabnode = n0
end
if slabpos then
2014-04-03 10:50:37 -07:00
minetest.remove_node(slabpos)
2013-03-24 04:49:00 -07:00
local fakestack = ItemStack("extrablocks:tort")
pointed_thing.above = slabpos
fakestack = minetest.item_place(fakestack, placer, pointed_thing)
if not fakestack or fakestack:is_empty() then
itemstack:take_item(1)
else
2014-04-03 10:50:37 -07:00
minetest.set_node(slabpos, slabnode)
2013-02-08 11:31:22 -08:00
end
2013-03-24 04:49:00 -07:00
return itemstack
end
2013-02-08 11:31:22 -08:00
2013-03-24 04:49:00 -07:00
return minetest.item_place(itemstack, placer, pointed_thing)
end,
2015-05-29 03:09:29 -07:00
2013-02-08 11:31:22 -08:00
})
2015-09-27 07:03:04 -07:00
local chest_formspec =
"size[8,9]" ..
"list[current_name;main;0,0.3;8,4;]" ..
"list[current_player;main;0,4.85;8,1;]" ..
"list[current_player;main;0,6.08;8,3;8]" ..
"listring[current_name;main]" ..
"listring[current_player;main]"
2013-07-19 09:41:39 -07:00
minetest.register_node("extrablocks:eating_chest", {
description = "Eating Chest",
tiles = {{name="extrablocks_eating_chest.png", animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=1.5}},
"default_chest_top.png", "default_chest_side.png"},
groups = {choppy=2,oddly_breakable_by_hand=2},
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
2015-09-27 07:03:04 -07:00
meta:set_string("formspec", chest_formspec)
2013-07-19 09:41:39 -07:00
meta:set_string("infotext", "Hungry Chest")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
2015-09-27 07:03:04 -07:00
on_metadata_inventory_move = function(pos, _,_,_,_,_, player)
2013-07-19 09:41:39 -07:00
minetest.log("action", player:get_player_name()..
" moves stuff in hungry chest at "..minetest.pos_to_string(pos))
end,
2015-09-27 07:03:04 -07:00
on_metadata_inventory_put = function(pos, _,_,_, player)
2013-07-19 09:41:39 -07:00
minetest.log("action", player:get_player_name()..
" moves stuff to hungry chest at "..minetest.pos_to_string(pos))
end,
2015-09-27 07:03:04 -07:00
on_metadata_inventory_take = function(pos, _,_,_, player)
2013-07-19 09:41:39 -07:00
minetest.log("action", player:get_player_name()..
" takes stuff from hungry chest at "..minetest.pos_to_string(pos))
end,
})
minetest.register_abm({
nodenames = {"extrablocks:eating_chest"},
interval = 1,
chance = 1,
2015-09-27 07:03:04 -07:00
action = function(pos, node, _, wider_count)
if wider_count == 0 then
return
end
2014-04-03 10:50:37 -07:00
local inv = minetest.get_meta(pos):get_inventory()
for _, object in pairs(minetest.get_objects_inside_radius({x = pos.x, y = pos.y+0.5, z = pos.z}, .5)) do
2015-09-27 07:03:04 -07:00
if not object:is_player() then
local l = object:get_luaentity()
if l
and l.name == "__builtin:item" then
item = l.itemstring
if item ~= ""
and inv:room_for_item("main", item) then
2013-07-19 09:41:39 -07:00
inv:add_item("main", item)
2015-09-27 07:03:04 -07:00
l.itemstring = ""
2013-07-19 09:41:39 -07:00
object:remove()
minetest.sound_play("survival_hunger_eat", {pos = pos, gain = 0.5, max_hear_distance = 10})--sounds from hungry games
2015-02-27 13:11:32 -08:00
print("[extrablocks] a hungry chest "..minetest.pos_to_string(pos).." ate "..item)
2013-07-19 09:41:39 -07:00
end
end
end
end
end,
})
2015-02-27 13:11:32 -08:00
local default_tabs = {
{x=0, y=0, z=-1},
{x=0, y=0, z=1},
{x=0, y=-1, z=0},
{x=0, y=1, z=0},
{x=-1, y=0, z=0},
{x=1, y=0, z=0},
}
local function get_tab(pos, func, max, tabs)
tabs = tabs or default_tabs
2014-08-14 11:37:05 -07:00
local tab = {pos}
2014-08-14 06:51:27 -07:00
local tab_avoid = {[pos.x.." "..pos.y.." "..pos.z] = true}
local tab_done,num = {pos},2
2014-08-14 11:37:05 -07:00
while tab[1] do
for n,p in pairs(tab) do
2015-02-27 13:11:32 -08:00
for _,p2 in pairs(tabs) do
2015-02-28 03:25:35 -08:00
local p2 = vector.add(p, p2)
2015-02-27 13:11:32 -08:00
local pstr = p2.x.." "..p2.y.." "..p2.z
if not tab_avoid[pstr]
and func(p2) then
tab_avoid[pstr] = true
tab_done[num] = p2
num = num+1
table.insert(tab, p2)
if max
and num > max then
return false
2014-08-14 06:51:27 -07:00
end
end
end
2015-02-28 03:25:35 -08:00
tab[n] = nil
2014-08-14 06:51:27 -07:00
end
end
2015-02-18 08:44:15 -08:00
return tab_done, tab_avoid
2014-08-14 06:51:27 -07:00
end
--[[local lq_rm_count --try to avoid stack overflow
2013-08-16 13:25:27 -07:00
local function rm_lqud(pos, node)
2014-04-03 10:50:37 -07:00
minetest.remove_node(pos)
if lq_rm_count > 100 then
return
end
lq_rm_count = lq_rm_count+1
2013-08-16 13:25:27 -07:00
for i = -1,1,2 do
2014-04-03 10:50:37 -07:00
for _,p in ipairs({
{x=pos.x, y=pos.y, z=pos.z+i},
{x=pos.x+i, y=pos.y, z=pos.z},
{x=pos.x, y=pos.y+i, z=pos.z}
}) do
if minetest.get_node(p).name == node then
rm_lqud(p, node)
end
2013-08-16 13:25:27 -07:00
end
end
2014-08-14 06:51:27 -07:00
end]]
2013-08-16 13:25:27 -07:00
2014-08-14 11:37:05 -07:00
local function is_liquid(pos)
local nd = minetest.get_node(pos).name
for _,i in pairs({"default:water_flowing", "default:water_source", "default:lava_source", "default:lava_flowing"}) do
if nd == i then
return true
end
end
return false
end
2013-08-16 13:25:27 -07:00
minetest.register_node("extrablocks:seakiller", {
description = "Sponge",
tiles = {"default_mese_block.png^default_glass.png"},
2013-08-24 03:32:48 -07:00
drop = "",
2013-08-16 13:25:27 -07:00
groups = {snappy=2, flammable=1},
on_construct = function(pos)
local t1 = os.clock()
2014-08-14 11:37:05 -07:00
for _,p in pairs(get_tab(pos, is_liquid)) do
2014-08-14 06:51:27 -07:00
minetest.remove_node(p)
end
--[[lq_rm_count = 0
2014-08-14 11:37:05 -07:00
for _, nam in ipairs() do
2013-08-16 13:25:27 -07:00
rm_lqud(pos, nam)
2014-08-14 06:51:27 -07:00
end]]
2015-02-27 13:11:32 -08:00
print(string.format("[extrablocks] "..minetest.pos_to_string(pos).." liquids removed after: %.2fs", os.clock() - t1))
2013-08-16 13:25:27 -07:00
end
})
2013-07-19 09:41:39 -07:00
2015-02-27 13:11:32 -08:00
local nds = {
roof = "default:stone",
floor = "default:obsidian",
corner = "default:tree",
wall = "default:wood",
glass = "default:glass",
}
2015-02-18 08:44:15 -08:00
local current_sn
local function is_sn(pos)
return minetest.get_node(pos).name == current_sn
end
2015-02-28 01:14:57 -08:00
local anti
local function is_solid(p)
2015-02-18 08:44:15 -08:00
if anti[p.x.." "..p.y.." "..p.z] then
return true
end
2015-03-21 12:19:36 -07:00
local data = minetest.registered_nodes[minetest.get_node(p).name] or {}
if data.walkable then
2015-02-18 08:44:15 -08:00
return true
end
return false
end
2015-02-27 13:11:32 -08:00
-- patterns for floor etc
local pattern = {}
function pattern.roof()
return nds.roof
end
function pattern.floor()
return nds.floor
2015-02-18 08:44:15 -08:00
end
2015-02-27 13:11:32 -08:00
function pattern.wall()
return nds.wall
end
function pattern.glass()
return nds.glass
end
function pattern.corner()
return nds.corner
end
2015-02-18 08:44:15 -08:00
2015-02-27 13:11:32 -08:00
-- tests if free space is about it
2015-02-28 01:14:57 -08:00
local function is_roof(pos)
2015-02-27 13:11:32 -08:00
for y = 1,10 do
local y = pos.y+y
2015-02-28 01:14:57 -08:00
if is_solid({x=pos.x, y=y, z=pos.z}) then
2015-02-27 13:11:32 -08:00
return false
end
end
return true
2015-02-18 08:44:15 -08:00
end
2015-02-27 13:11:32 -08:00
-- searches for near nodes
2015-02-28 01:14:57 -08:00
local function is_floor(pos)
2015-02-18 08:44:15 -08:00
for i = -1,1,2 do
local y = pos.y+i
if not (
2015-02-28 01:14:57 -08:00
is_solid({x=pos.x+1, y=y, z=pos.z})
and is_solid({x=pos.x-1, y=y, z=pos.z})
2015-02-18 08:44:15 -08:00
)
and not (
2015-02-28 01:14:57 -08:00
is_solid({x=pos.x, y=y, z=pos.z+1})
and is_solid({x=pos.x, y=y, z=pos.z-1})
2015-02-18 08:44:15 -08:00
)
2015-02-28 01:14:57 -08:00
and not is_solid({x=pos.x, y=y, z=pos.z}) then
2015-02-18 08:44:15 -08:00
return true
end
end
return false
end
2015-02-27 13:11:32 -08:00
-- corners for deco
2015-02-28 01:14:57 -08:00
local function is_corner(pos)
2015-02-18 08:44:15 -08:00
local y = pos.y
2015-02-28 03:25:35 -08:00
for i = 1,2 do
if (
is_solid({x=pos.x+i, y=y, z=pos.z})
and is_solid({x=pos.x-i, y=y, z=pos.z})
)
or (
is_solid({x=pos.x, y=y, z=pos.z+i})
and is_solid({x=pos.x, y=y, z=pos.z-i})
) then
return false
end
2015-02-18 08:44:15 -08:00
end
return true
end
2015-02-27 13:11:32 -08:00
-- wall is vertical
2015-02-28 01:14:57 -08:00
local function is_wall(pos)
2015-02-18 08:44:15 -08:00
for i = -1,1,2 do
for _,p in pairs({
{x=pos.x, y=pos.y, z=pos.z+i},
{x=pos.x+i, y=pos.y, z=pos.z},
}) do
2015-02-28 01:14:57 -08:00
if not is_solid(p) then
2015-02-18 08:44:15 -08:00
return true
end
end
end
return false
end
2015-02-27 13:11:32 -08:00
-- glass touching the wall
2015-02-28 03:25:35 -08:00
local function unsolid(p)
return not is_solid(p)
end
local function get_glass(pos, status)
for coord,acoord in pairs({x="z", z="x"}) do
if not is_solid({[coord]=pos[coord]-1, [acoord]=pos[acoord], y=pos.y})
and not is_solid({[coord]=pos[coord]+1, [acoord]=pos[acoord], y=pos.y}) then
for j = -1,1,2 do
local p = {[coord]=pos[coord]-j, [acoord]=pos[acoord], y=pos.y}
local g_tab = {
{x=0, y=-1, z=0},
{x=0, y=1, z=0},
{[coord]=0, [acoord]=-1, y=0},
{[coord]=0, [acoord]=1, y=0},
}
local free_space,ndx = get_tab(p, unsolid, 300, g_tab)
2015-02-28 06:52:01 -08:00
for i = -1,1,2 do
for j = -1,1,2 do
table.insert(g_tab, {[coord]=0, [acoord]=i, y=j})
end
end
2015-02-28 03:25:35 -08:00
if free_space then
local glasss,found = {}
for _,p in pairs(free_space) do
local block
for _,a in pairs(g_tab) do
if not ndx[p.x+a.x .." "..p.y+a.y .." "..p.z+a.z] then
block = true
break
end
p[coord] = p[coord]+j
local pstr = p.x+a.x .." "..p.y+a.y .." "..p.z+a.z
p[coord] = p[coord]-j
if not status[pstr] -- avoids removing doors
or status[pstr].typ ~= "wall" then
block = true
break
end
end
if not block then
p[coord] = p[coord]+j
glasss[p.x.." "..p.y.." "..p.z] = vector.new(p)
found = true
end
end
if found then
return glasss
end
2015-02-27 13:11:32 -08:00
end
end
end
end
end
-- the node
2015-02-18 08:44:15 -08:00
minetest.register_node("extrablocks:house_redesignor", {
description = "Asnh",
tiles = {"default_mese_block.png^default_jungleleaves.png"},
drop = "",
groups = {snappy=2, flammable=1},
on_place = function(_, puncher, pos)
local t1 = os.clock()
if not pos
or not puncher then
return
end
pos = pos.under
current_sn = minetest.get_node(pos).name
local ctrl = puncher:get_player_control()
if not ctrl then
return
end
if ctrl.sneak then
if ctrl.aux1 then
2015-02-27 13:11:32 -08:00
nds.wall = current_sn
2015-02-18 08:44:15 -08:00
else
2015-02-27 13:11:32 -08:00
nds.floor = current_sn
2015-02-18 08:44:15 -08:00
end
return
end
2015-02-28 01:14:57 -08:00
local data
data,anti = get_tab(pos, is_sn, 3000)
2015-02-18 08:44:15 -08:00
if data then
2015-02-27 13:11:32 -08:00
local status = {}
2015-02-18 08:44:15 -08:00
for _,p in pairs(data) do
2015-02-27 13:11:32 -08:00
local no
local pstr = p.x.." "..p.y.." "..p.z
2015-02-28 01:14:57 -08:00
if is_floor(p) then
2015-02-28 03:25:35 -08:00
if is_roof(p) then -- the roof is the place where a lot air is above
2015-02-27 13:11:32 -08:00
p.typ = "roof"
else
p.typ = "floor"
end
2015-02-28 01:14:57 -08:00
elseif is_corner(p) then
2015-02-27 13:11:32 -08:00
p.typ = "corner"
2015-02-28 01:14:57 -08:00
elseif is_wall(p) then
2015-02-27 13:11:32 -08:00
p.typ = "wall"
else
no = true
end
if not no then
status[pstr] = p
2015-02-18 08:44:15 -08:00
end
end
2015-02-27 13:11:32 -08:00
for _,p in pairs(status) do
if p.typ == "wall" then
2015-02-28 03:25:35 -08:00
local glass = get_glass(p, status) -- a table of positions for glass
2015-02-27 13:11:32 -08:00
if glass then
for i,gl in pairs(glass) do
gl.typ = "glass"
status[i] = gl
end
end
end
end
for _,p in pairs(status) do
minetest.set_node(p, {name=pattern[p.typ]()})
end
2015-02-18 08:44:15 -08:00
end
2015-02-27 13:11:32 -08:00
print(string.format("[extrablocks] "..minetest.pos_to_string(pos).." blah blahr: %.2fs", os.clock() - t1))
2015-02-18 08:44:15 -08:00
end
})
2015-12-18 10:02:29 -08:00
-- depends on vector_extras
local set = vector.set_data_to_pos
local get = vector.get_data_from_pos
local remove = vector.remove_data_from_pos
2015-01-26 07:53:44 -08:00
local function get_tab2d(pos, func, max)
2015-12-18 10:02:29 -08:00
local z,y,x = vector.unpack(pos)
local tab = {{z,x}}
local tab_avoid = {}
set(tab_avoid, z,x,0, true)
2015-01-26 07:53:44 -08:00
local tab_done,num = {pos},2
2015-12-18 10:02:29 -08:00
local n = 1
while n do
local z,x = unpack(tab[n])
for i = -1,1,2 do
for _,p2 in pairs({
{z+i,x},
{z,x+i},
}) do
local z,x = unpack(p2)
if not get(tab_avoid, z,x,0)
and func({x=x, y=y, z=z}) then
set(tab_avoid, z,x,0, true)
tab_done[num] = p2
num = num+1
if max
and num > max then
return false
2015-01-26 07:53:44 -08:00
end
2015-12-18 10:02:29 -08:00
table.insert(tab, {z,x})
2015-01-26 07:53:44 -08:00
end
end
end
2015-12-18 10:02:29 -08:00
tab[n] = nil
n = next(tab)
2015-01-26 07:53:44 -08:00
end
return tab_done
end
2015-02-28 03:25:35 -08:00
local function is_air(pos)
2015-01-26 07:53:44 -08:00
return minetest.get_node(pos).name == "air" or false
end
minetest.register_node("extrablocks:house_tidy_up", {
description = "AUFRÄUMEN",
tiles = {"default_wood.png^default_glass.png"},
groups = {snappy=2},
on_construct = function(pos)
local t1 = os.clock()
pos.y = pos.y+1
local data = get_tab2d(pos, is_air, 3000)
if data then
for _,p in pairs(data) do
p.y = p.y-1
if minetest.get_node(p).name ~= "air" then
minetest.remove_node(p)
end
end
end
--[[lq_rm_count = 0
for _, nam in ipairs() do
rm_lqud(pos, nam)
end]]
2015-02-27 13:11:32 -08:00
print(string.format("[extrablocks] "..minetest.pos_to_string(pos).." nodees removed after: %.2fs", os.clock() - t1))
2015-01-26 07:53:44 -08:00
end
})
2015-02-18 08:44:15 -08:00
local lnd = "default:cobble"
minetest.register_node("extrablocks:house_floorfill", {
description = "bodenen",
tiles = {"default_junglewood.png^default_glass.png"},
groups = {snappy=2},
on_place = function(_, puncher, pos)
local t1 = os.clock()
if not pos
or not puncher then
return
end
local ctrl = puncher:get_player_control()
if ctrl.sneak then
lnd = minetest.get_node(pos.under).name
return
end
local pos = pos.above
local data = get_tab2d(pos, is_air, 3000)
if data then
for _,p in pairs(data) do
minetest.set_node(p, {name=lnd})
end
end
2015-02-27 13:11:32 -08:00
print(string.format("[extrablocks] "..minetest.pos_to_string(pos).." hole filled after: %.2fs", os.clock() - t1))
2015-02-18 08:44:15 -08:00
end
})
2013-07-19 09:41:39 -07:00
2013-02-08 11:31:22 -08:00
local function moitem(name, desc)
minetest.register_craftitem("extrablocks:"..name, {
description = desc,
inventory_image = "extrablocks_"..name..".png",
})
end
2015-02-27 13:11:32 -08:00
moitem("lapis_lazuli_lump", "lapis lazuli")
2013-02-08 11:31:22 -08:00
moitem("sugar", "Sugar")
moitem("muffin_uncooked", "Put me into the furnace!")
2015-02-27 13:11:32 -08:00
moitem("iringnite_lump", "Iringnite lump")
2013-05-28 11:56:36 -07:00
moitem("iringnite_ingot", "Iringnite Ingot")
2015-02-27 13:11:32 -08:00
moitem("fokni_gneb_lump", "Fokni Gneb lump")
2013-02-08 11:31:22 -08:00
minetest.register_craftitem("extrablocks:muffin", {
description = "Muffin",
inventory_image = "extrablocks_muffin.png",
on_use = minetest.item_eat(20),
})
2013-04-12 09:58:02 -07:00
2013-05-18 11:22:04 -07:00
2014-09-05 09:08:38 -07:00
2015-02-20 10:37:25 -08:00
if moss_mod then
2014-09-05 09:08:38 -07:00
moss.register_moss({
node = "extrablocks:wall",
result = "extrablocks:mossywall"
})
end
2013-05-18 11:22:04 -07:00
local function ore(name, scarcity, num_ores, size, min, max)
minetest.register_ore({
ore_type = "scatter",
2013-05-28 11:56:36 -07:00
ore = "extrablocks:"..name,
2013-05-18 11:22:04 -07:00
wherein = "default:stone",
clust_scarcity = scarcity,
clust_num_ores = num_ores,
clust_size = size,
2015-11-22 06:36:31 -08:00
y_min = min,
y_max = max,
2013-05-18 11:22:04 -07:00
})
2013-04-12 09:58:02 -07:00
end
2013-05-28 11:56:36 -07:00
ore("lapis_lazuli_ore", 10*10*10, 3, 10, -150, -80)
ore("lapis_lazuli_ore", 7*7*7, 3, 10, -300, -150)
2014-01-14 10:12:26 -08:00
ore("goldstone", 11*11*11, 4, 11, -2000, -1000)
ore("goldstone", 8*8*8, 4, 11, -31000, -2000)
ore("iringnite_ore", 40*40*40, 4, 11, -4000, -3000)
ore("iringnite_ore", 20*20*20, 4, 11, -5000, -4000)
ore("iringnite_ore", 11*11*11, 4, 11, -31000, -5000)
2014-11-24 10:47:25 -08:00
if not minetest.get_modpath("extrablocks") then
minetest.register_ore({
ore_type = "sheet",
ore = "extrablocks:marble_ore",
wherein = "default:stone",
clust_size = 20,
2015-11-22 06:36:31 -08:00
y_min = -100,
y_max = -32,
2014-11-24 10:47:25 -08:00
noise_params = {offset=0, scale=1, spread={x=10, y=10, z=10}, seed=113, octaves=3, persist=0.70}
})
minetest.register_ore({
ore_type = "sheet",
ore = "extrablocks:marble_ore",
wherein = "default:stone",
clust_size = 20,
2015-11-22 06:36:31 -08:00
y_min = -100,
y_max = -90,
2014-11-24 10:47:25 -08:00
noise_params = {offset=0, scale=1, spread={x=10, y=10, z=10}, seed=112, octaves=3, persist=0.70}
})
end
2013-04-12 09:58:02 -07:00
2013-06-06 09:12:36 -07:00
minetest.register_ore({
ore_type = "sheet",
ore = "extrablocks:fokni_gneb_ore",
wherein = "default:stone",
2013-10-18 13:02:49 -07:00
clust_size = 10,
2015-11-22 06:36:31 -08:00
y_min = -10000,
y_max = -6000,
2013-10-18 13:02:49 -07:00
noise_params = {offset=0, scale=1, spread={x=20, y=20, z=20}, seed=114, octaves=3, persist=0.70}
2013-06-06 09:12:36 -07:00
})
2013-07-19 09:41:39 -07:00
2013-08-16 13:25:27 -07:00
local path = minetest.get_modpath("extrablocks")
2013-06-28 06:15:13 -07:00
2013-08-16 13:25:27 -07:00
dofile(path.."/settings.lua")
if extrablocks_allow_crafting then
dofile(path.."/crafting.lua")
2013-06-28 06:15:13 -07:00
end
2013-08-16 13:25:27 -07:00
if extrablocks_movement_stuff then
dofile(path.."/mvmt.lua")
2013-06-28 06:15:13 -07:00
end
2013-08-23 07:16:54 -07:00
if extrablocks_tools then
dofile(path.."/tools.lua")
end
2014-01-27 10:56:49 -08:00
dofile(path.."/weapons.lua")
2013-10-25 13:18:11 -07:00
dofile(path.."/mining_lasers.lua")
2015-02-18 08:44:15 -08:00
minetest.log("info", string.format("[extrablocks] loaded after ca. %.2fs", os.clock() - load_time_start))