439 lines
13 KiB
Lua
439 lines
13 KiB
Lua
PyuTestCore.make_node_sounds = function(tbl)
|
|
local t = tbl or {}
|
|
t.footstep = t.footstep or {name = "block_walk", gain = 1}
|
|
t.dig = t.dig or {name = "block_dig", gain = 0.50}
|
|
t.dug = t.dug or {name = "block_break", gain = 0.50}
|
|
t.place = t.place or {name = "block_place", gain = 0.50}
|
|
return t
|
|
end
|
|
|
|
PyuTestCore.make_node = function(name, desc, groups, tiles, extra_conf)
|
|
local conf = {
|
|
description = Translate(desc),
|
|
tiles = tiles,
|
|
groups = groups,
|
|
sounds = PyuTestCore.make_node_sounds()
|
|
}
|
|
|
|
if extra_conf ~= nil then
|
|
for k, v in pairs(extra_conf) do
|
|
conf[k] = v
|
|
end
|
|
end
|
|
|
|
minetest.register_node(name, conf)
|
|
end
|
|
|
|
PyuTestCore.node_boxes = {
|
|
CARPET = {
|
|
type = "fixed",
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}
|
|
},
|
|
SLAB = {
|
|
type = "fixed",
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
|
|
},
|
|
PILLAR = {
|
|
type = "fixed",
|
|
fixed = {-0.15, -0.5, -0.15, 0.15, 0.5, 0.15}
|
|
}
|
|
}
|
|
PyuTestCore.building_blocks = {}
|
|
|
|
PyuTestCore.make_building_blocks = function (name, desc, tex, colortint, cgroups, extra_conf)
|
|
local groups = cgroups or {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_NORMAL
|
|
}
|
|
groups["block"] = groups["block"] or PyuTestCore.BLOCK_BREAKABLE_NORMAL
|
|
|
|
local econf = extra_conf or {}
|
|
local id_block = name.."_block"
|
|
local id_carpet = name.."_carpet"
|
|
local id_slab = name.."_slab"
|
|
local id_pillar = name.."_pillar"
|
|
|
|
minetest.register_node(id_block, PyuTestCore.util.tableconcat({
|
|
description = Translate(desc.." Block"),
|
|
tiles = tex,
|
|
color = colortint,
|
|
groups = groups,
|
|
sounds = PyuTestCore.make_node_sounds(),
|
|
}, econf))
|
|
table.insert(PyuTestCore.building_blocks, id_block)
|
|
|
|
minetest.register_node(id_carpet, PyuTestCore.util.tableconcat({
|
|
description = Translate(desc .. " Carpet"),
|
|
tiles = tex,
|
|
groups = groups,
|
|
color = colortint,
|
|
drawtype = "nodebox",
|
|
paramtype = "light",
|
|
paramtype2 = "facedir",
|
|
node_box = PyuTestCore.node_boxes.CARPET,
|
|
sounds = PyuTestCore.make_node_sounds(),
|
|
}, econf))
|
|
table.insert(PyuTestCore.building_blocks, id_carpet)
|
|
|
|
minetest.register_node(id_slab, PyuTestCore.util.tableconcat({
|
|
description = Translate(desc.." Slab"),
|
|
tiles = tex,
|
|
groups = groups,
|
|
color = colortint,
|
|
drawtype = "nodebox",
|
|
paramtype = "light",
|
|
paramtype2 = "facedir",
|
|
node_box = PyuTestCore.node_boxes.SLAB,
|
|
sounds = PyuTestCore.make_node_sounds(),
|
|
}, econf))
|
|
table.insert(PyuTestCore.building_blocks, id_slab)
|
|
|
|
minetest.register_node(id_pillar, PyuTestCore.util.tableconcat({
|
|
description = Translate(desc.." Pillar"),
|
|
tiles = tex,
|
|
groups = groups,
|
|
color = colortint,
|
|
drawtype = "nodebox",
|
|
paramtype = "light",
|
|
paramtype2 = "facedir",
|
|
node_box = PyuTestCore.node_boxes.PILLAR,
|
|
sounds = PyuTestCore.make_node_sounds(),
|
|
}, econf))
|
|
table.insert(PyuTestCore.building_blocks, id_pillar)
|
|
|
|
minetest.register_craft({
|
|
output = id_carpet .. " 2",
|
|
recipe = {
|
|
{id_block, id_block}
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = id_slab .. " 3",
|
|
recipe = {
|
|
{id_block, id_block, id_block}
|
|
}
|
|
})
|
|
|
|
minetest.register_craft({
|
|
output = id_pillar .. " 3",
|
|
recipe = {
|
|
{id_block},
|
|
{id_block},
|
|
{id_block}
|
|
}
|
|
})
|
|
end
|
|
|
|
PyuTestCore.make_building_blocks("pyutest_core:grass", "Grass", {"grass.png"}, nil, {ground = 1}, {drop = "pyutest_core:dirt_block"})
|
|
PyuTestCore.make_building_blocks("pyutest_core:dirt", "Dirt", {"dirt.png"}, nil, {ground = 1})
|
|
PyuTestCore.make_building_blocks("pyutest_core:stone", "Stone", {"stone.png"}, nil, {ground = 1, block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE})
|
|
PyuTestCore.make_building_blocks("pyutest_core:wooden", "Wooden", {"wood.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY})
|
|
PyuTestCore.make_building_blocks("pyutest_core:snow", "Snow", {"snow.png"}, nil, {ground = 1})
|
|
PyuTestCore.make_building_blocks("pyutest_core:sand", "Sand", {"sand.png"}, nil, {ground = 1})
|
|
PyuTestCore.make_building_blocks("pyutest_core:sandstone", "Sandstone", {"sandstone.png"}, nil, {ground = 1})
|
|
PyuTestCore.make_building_blocks("pyutest_core:ice", "Ice", {"ice.png"}, nil, {ground = 1})
|
|
PyuTestCore.make_building_blocks("pyutest_core:leaves", "Leaves", {"leaves.png"}, nil)
|
|
PyuTestCore.make_building_blocks("pyutest_core:mushroom", "Mushroom", {"mushroom.png"}, nil)
|
|
PyuTestCore.make_building_blocks("pyutest_core:mushroom_stem", "Mushroom Stem", {"mushroom-stem.png"}, nil)
|
|
PyuTestCore.make_building_blocks("pyutest_core:mycelium", "Mycelium", {"mycelium.png"}, nil, {ground = 1})
|
|
PyuTestCore.make_building_blocks("pyutest_core:hellstone", "Hellstone", {"hellstone.png"}, nil, {ground = 1, block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE})
|
|
PyuTestCore.make_building_blocks("pyutest_core:basalt", "Basalt", {"basalt.png"}, nil, {ground = 1, block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE})
|
|
PyuTestCore.make_building_blocks("pyutest_core:obsidian", "Obsidian", {"obsidian.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_VERYLONG})
|
|
PyuTestCore.make_building_blocks("pyutest_core:haybale", "Haybale", {"haybale-top-bottom.png", "haybale-top-bottom.png", "haybale.png"}, nil)
|
|
-- keeping old ID for backwards compatibility
|
|
PyuTestCore.make_building_blocks("pyutest_core:crying_obsidian", "Enchanted Obsidian", {"crying-obsidian.png"}, nil, {block = PyuTestCore.BLOCK_BREAKABLE_VERYLONG})
|
|
|
|
PyuTestCore.make_node("pyutest_core:light", "Light", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT,
|
|
light = 1
|
|
}, {
|
|
"light.png"
|
|
}, {
|
|
drawtype = "torchlike",
|
|
walkable = false,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
light_source = minetest.LIGHT_MAX,
|
|
on_rightclick = function ()
|
|
if minetest.get_timeofday() >= 0.5 then
|
|
minetest.set_timeofday(0)
|
|
else
|
|
minetest.set_timeofday(0.5)
|
|
end
|
|
end
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:torch", "Torch", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT,
|
|
light = 1
|
|
}, {
|
|
"torch.png"
|
|
}, {
|
|
light_source = 12,
|
|
walkable = false,
|
|
drawtype = "torchlike",
|
|
paramtype = "light",
|
|
inventory_image = "torch.png",
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:sponge", "Sponge", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {"sponge.png"})
|
|
|
|
PyuTestCore.make_node("pyutest_core:glass", "Glass", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {"glass.png"}, {
|
|
drawtype = "glasslike_framed",
|
|
paramtype = "light",
|
|
sunlight_propagates = true
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:flower", "Rose", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT,
|
|
}, {"flower.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "flower.png"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:flower2", "Dandelion", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT,
|
|
}, {"flower2.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "flower2.png"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:flower3", "Blue Daisy", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT,
|
|
}, {"flower3.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "flower3.png"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:flower4", "Lavender", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT,
|
|
}, {"flower4.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "flower4.png"
|
|
})
|
|
|
|
|
|
PyuTestCore.make_node("pyutest_core:deadbush", "Deadbush", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {"deadbush.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "deadbush.png"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:grass_plant", "Grass", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {"grass-plant.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "grass-plant.png"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:tree_sapling", "Tree Sapling", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {"sapling.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "sapling.png",
|
|
|
|
on_timer = function (pos)
|
|
local trees = {
|
|
"tree",
|
|
"tree2"
|
|
}
|
|
|
|
math.randomseed(os.time())
|
|
local selected_tree = trees[math.random(#trees)]
|
|
|
|
minetest.remove_node(pos)
|
|
pos.y = pos.y - 1
|
|
minetest.place_schematic(pos, PyuTestCore.get_schem_path(selected_tree), "random", nil, false, "place_center_x, place_center_z")
|
|
end,
|
|
|
|
on_rightclick = function (pos)
|
|
local timer = minetest.get_node_timer(pos)
|
|
timer:start(6)
|
|
end
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:sugarcane", "Sugarcane", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {"sugarcane.png"}, {
|
|
drawtype = "plantlike",
|
|
walkable = false,
|
|
waving = 1,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "sugarcane.png"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:trapdoor", "Trapdoor", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY
|
|
}, {"trapdoor.png"}, {
|
|
drawtype = "nodebox",
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
node_box = {
|
|
type = "fixed",
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.15, 0.5}
|
|
}
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:contagious_acid", "Contagious Acid", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_MIDDLE,
|
|
}, {"acid.png"}, {})
|
|
|
|
PyuTestCore.make_node("pyutest_core:barrier", "Barrier", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_FOREVER
|
|
}, {}, {
|
|
drawtype = "airlike",
|
|
walkable = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
inventory_image = "barrier.png",
|
|
wield_image = "barrier.png"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:fire", "Fire", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {"fire.png"}, {
|
|
drawtype = "firelike",
|
|
walkable = false,
|
|
buildable_to = true,
|
|
paramtype = "light",
|
|
sunlight_propagates = true,
|
|
damage_per_second = 2,
|
|
light_source = 8,
|
|
drop = "pyutest_core:ash 4"
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:tnt", "TNT", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_INSTANT
|
|
}, {
|
|
"tnt-top-bottom.png",
|
|
"tnt-top-bottom.png",
|
|
"tnt-side.png" -- Affects all other sides
|
|
}, {
|
|
on_rightclick = function (pos)
|
|
local timer = minetest.get_node_timer(pos)
|
|
timer:start(4)
|
|
end,
|
|
|
|
on_timer = function (pos)
|
|
PyuTestCore.create_explosion(pos, 3, true, 3)
|
|
end
|
|
})
|
|
|
|
PyuTestCore.make_node("pyutest_core:crate", "Crate", {
|
|
block = PyuTestCore.BLOCK_BREAKABLE_CHOPPY
|
|
}, {"crate.png"}, {
|
|
on_construct = function (pos)
|
|
local meta = minetest.get_meta(pos)
|
|
local inventory = meta:get_inventory()
|
|
inventory:set_size("main", 8 * 4)
|
|
end,
|
|
|
|
can_dig = function (pos, player)
|
|
local meta = minetest.get_meta(pos)
|
|
local inventory = meta:get_inventory()
|
|
local empty = inventory:is_empty("main")
|
|
|
|
if not empty then
|
|
minetest.chat_send_player(player:get_player_name(), "Cannot destroy crate, it's not empty!")
|
|
end
|
|
|
|
return empty
|
|
end,
|
|
|
|
on_rightclick = function (pos, node, clicker)
|
|
local spos = string.format("%d,%d,%d", pos.x, pos.y, pos.z)
|
|
local formspec =
|
|
"size[8,9]" ..
|
|
"list[nodemeta:"..spos..";main;0,0;8,4;]" ..
|
|
"list[current_player;main;0,5;8,4;]" ..
|
|
"listring[nodemeta:"..spos..";main]" ..
|
|
"listring[current_player;main]"
|
|
minetest.show_formspec(clicker:get_player_name(), string.format("pyutest_core:crate_%d_%d_%d", pos.x, pos.y, pos.z), formspec)
|
|
end
|
|
})
|
|
|
|
PyuTestCore.make_liquid = function (name, desc, groups, tiles, extra_conf)
|
|
local function make_liquid_flags(liquidtype)
|
|
local drawtype = ""
|
|
|
|
if liquidtype == "source" then
|
|
drawtype = "liquid"
|
|
elseif liquidtype == "flowing" then
|
|
drawtype = "liquid"
|
|
end
|
|
|
|
local t = PyuTestCore.util.tableconcat({
|
|
drawtype = drawtype,
|
|
waving = 3,
|
|
walkable = false,
|
|
pointable = false,
|
|
buildable_to = true,
|
|
is_ground_content = false,
|
|
use_texture_alpha = "blend",
|
|
paramtype = "light",
|
|
drop = "",
|
|
drowning = 1,
|
|
liquidtype = liquidtype,
|
|
liquid_viscosity = 1,
|
|
liquid_alternative_flowing = name.."_flowing",
|
|
liquid_alternative_source = name.."_source"
|
|
}, extra_conf or {})
|
|
return t
|
|
end
|
|
groups["liquid"] = 1
|
|
|
|
PyuTestCore.make_node(name.."_source", desc .. " Source", groups, tiles, make_liquid_flags("source"))
|
|
PyuTestCore.make_node(name.."_flowing", "Flowing " .. desc, groups, tiles, make_liquid_flags("flowing"))
|
|
end
|
|
|
|
PyuTestCore.make_liquid("pyutest_core:water", "Water", {}, {"water.png"})
|
|
PyuTestCore.make_liquid("pyutest_core:lava", "Lava", {}, {"lava.png"}, {
|
|
damage_per_second = 2,
|
|
light_source = 8
|
|
})
|
|
PyuTestCore.make_liquid("pyutest_core:oil", "Oil", {}, {"oil.png"})
|
|
PyuTestCore.make_liquid("pyutest_core:liquid_acid", "Acid", {}, {"acid.png"}, {
|
|
damage_per_second = 2
|
|
})
|