Merge ShadowNinja's rewrite.

This commit is contained in:
Calinou 2014-03-09 10:38:18 +01:00
parent 396945ed3e
commit 8337a6c192
19 changed files with 1348 additions and 1663 deletions

View File

@ -1,6 +1,6 @@
+---- zlib/libpng license ----+
Copyright (c) 2013 Calinou
Copyright (c) 2013-2014 Calinou and contributors
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

View File

@ -1,22 +1,12 @@
Calinou's Minetest Mods
=====================
MoreBlocks
==========
Calinou's Mods for Minetest [http://minetest.net], a free and opensource Minecraft-like game.
MoreBlocks for Minetest (http://minetest.net), a free and open source infinite
world block sandbox game.
This Git repository is mostly made for servers; it allows easy updating.
To install, just clone this repository into your "mods" folder.
To install, just clone this repository somewhere, then copy the "calinou_mods" folder in the "mods/minetest" folder of Minetest's installation folder.
MoreBlocks code is under the zlib/libpng license, textures are under CC BY-SA 3.0 unported.
Forum thread: http://forum.minetest.net/viewtopic.php?id=509
Misc stuff
=====================
All these mods' source codes, except More Ores are under the zlib/libpng license. More Ores is under the GNU GPLv3; the mods' textures are under the CC BY-SA 3.0 Unported.
Mods' forum threads:
More Blocks: http://minetest.net/forum/viewtopic.php?id=509
More Ores: http://minetest.net/forum/viewtopic.php?id=549
Map Tools: http://minetest.net/forum/viewtopic.php?id=1882
Doors+: http://minetest.net/forum/viewtopic.php?id=2059
Stairs+: http://minetest.net/forum/viewtopic.php?id=2092

View File

@ -1,149 +1,9 @@
-- Aliases (some of them are about the default mod, some about moreblocks)
-- Additional default aliases
minetest.register_alias("woodpick", "default:pick_wood")
minetest.register_alias("woodenpick", "default:pick_wood")
minetest.register_alias("stonepick", "default:pick_stone")
minetest.register_alias("steelpick", "default:pick_steel")
minetest.register_alias("ironpick", "default:pick_steel")
minetest.register_alias("mesepick", "default:pick_mese")
minetest.register_alias("woodaxe", "default:axe_wood")
minetest.register_alias("woodenaxe", "default:axe_wood")
minetest.register_alias("stoneaxe", "default:axe_stone")
minetest.register_alias("steelaxe", "default:axe_steel")
minetest.register_alias("ironaxe", "default:axe_steel")
minetest.register_alias("woodshovel", "default:shovel_wood")
minetest.register_alias("woodenshovel", "default:shovel_wood")
minetest.register_alias("stoneshovel", "default:shovel_stone")
minetest.register_alias("steelshovel", "default:shovel_steel")
minetest.register_alias("ironshovel", "default:shovel_steel")
minetest.register_alias("woodsword", "default:sword_wood")
minetest.register_alias("woodensword", "default:sword_wood")
minetest.register_alias("stonesword", "default:sword_stone")
minetest.register_alias("steelsword", "default:sword_steel")
minetest.register_alias("ironsword", "default:sword_steel")
minetest.register_alias("grass", "default:dirt_with_grass")
minetest.register_alias("grassblock", "default:dirt_with_grass")
minetest.register_alias("grass_block", "default:dirt_with_grass")
minetest.register_alias("grassfootsteps", "default:dirt_with_grass_footsteps")
minetest.register_alias("grass_footsteps", "default:dirt_with_grass_footsteps")
minetest.register_alias("jungle_tree", "default:jungletree")
minetest.register_alias("stick", "default:stick")
minetest.register_alias("sign", "default:sign_wall")
minetest.register_alias("fence", "default:fence_wood")
minetest.register_alias("coal", "default:coal_lump")
minetest.register_alias("iron", "default:iron_lump")
minetest.register_alias("clay", "default:clay_lump")
minetest.register_alias("steel", "default:steel_ingot")
minetest.register_alias("steel_block", "default:steelblock")
minetest.register_alias("stonebrick", "default:stonebrick")
minetest.register_alias("stonebricks", "default:stonebrick")
minetest.register_alias("stone_brick", "default:stonebrick")
minetest.register_alias("stone_bricks", "default:stonebrick")
minetest.register_alias("screwdriver", "screwdriver:screwdriver")
minetest.register_alias("screw_driver", "screwdriver:screw_driver")
minetest.register_alias("screwdrive", "screwdriver:screw_driver")
minetest.register_alias("screw_drive", "screwdriver:screw_driver")
minetest.register_alias("sd", "screwdriver:screw_driver")
minetest.register_alias("obsidian", "default:obsidian")
minetest.register_alias("obsidianglass", "default:obsidian_glass")
minetest.register_alias("obsidian_glass", "default:obsidian_glass")
-- More Blocks aliases
minetest.register_alias("circlestonebrick", "moreblocks:circle_stone_bricks")
minetest.register_alias("circlestonebricks", "moreblocks:circle_stone_bricks")
minetest.register_alias("circlestone_brick", "moreblocks:circle_stone_bricks")
minetest.register_alias("circlestone_bricks", "moreblocks:circle_stone_bricks")
minetest.register_alias("circle_stonebrick", "moreblocks:circle_stone_bricks")
minetest.register_alias("circle_stonebricks", "moreblocks:circle_stone_bricks")
minetest.register_alias("circle_stone_brick", "moreblocks:circle_stone_bricks")
minetest.register_alias("circle_stone_bricks", "moreblocks:circle_stone_bricks")
minetest.register_alias("sweeper", "moreblocks:sweeper")
minetest.register_alias("circularsaw", "moreblocks:circular_saw")
minetest.register_alias("circular_saw", "moreblocks:circular_saw")
minetest.register_alias("cs", "moreblocks:circular_saw")
minetest.register_alias("sweep", "moreblocks:sweeper")
minetest.register_alias("junglestick", "moreblocks:jungle_stick")
minetest.register_alias("jungle_stick", "moreblocks:jungle_stick")
minetest.register_alias("stonesquare", "moreblocks:stone_tile")
minetest.register_alias("stonesquares", "moreblocks:stone_tile")
minetest.register_alias("stone_square", "moreblocks:stone_tile")
minetest.register_alias("stone_squares", "moreblocks:stone_tile")
minetest.register_alias("stonetile", "moreblocks:stone_tile")
minetest.register_alias("stonetiles", "moreblocks:stone_tile")
minetest.register_alias("stone_tile", "moreblocks:stone_tile")
minetest.register_alias("stone_tiles", "moreblocks:stone_tile")
minetest.register_alias("splitstonesquare", "moreblocks:split_stone_tile")
minetest.register_alias("splitstonesquares", "moreblocks:split_stone_tile")
minetest.register_alias("split_stone_square", "moreblocks:split_stone_tile")
minetest.register_alias("split_stone_squares", "moreblocks:split_stone_tile")
minetest.register_alias("split_stonesquare", "moreblocks:split_stone_tile")
minetest.register_alias("split_stonesquares", "moreblocks:split_stone_tile")
minetest.register_alias("coalstone", "moreblocks:coal_stone")
minetest.register_alias("coal_stone", "moreblocks:coal_stone")
minetest.register_alias("ironstone", "moreblocks:iron_stone")
minetest.register_alias("iron_stone", "moreblocks:iron_stone")
minetest.register_alias("coalglass", "moreblocks:coal_glass")
minetest.register_alias("coal_glass", "moreblocks:coal_glass")
minetest.register_alias("ironglass", "moreblocks:iron_glass")
minetest.register_alias("iron_glass", "moreblocks:iron_glass")
minetest.register_alias("glowglass", "moreblocks:glow_glass")
minetest.register_alias("glow_glass", "moreblocks:glow_glass")
minetest.register_alias("superglowglass", "moreblocks:super_glow_glass")
minetest.register_alias("super_glowglass", "moreblocks:super_glow_glass")
minetest.register_alias("super_glow_glass", "moreblocks:super_glow_glass")
minetest.register_alias("plankstone", "moreblocks:plankstone")
minetest.register_alias("cactusbrick", "moreblocks:cactus_brick")
minetest.register_alias("cactus_brick", "moreblocks:cactus_brick")
minetest.register_alias("cactuschecker", "moreblocks:cactus_checker")
minetest.register_alias("cactus_checker", "moreblocks:cactus_checker")
minetest.register_alias("coalchecker", "moreblocks:coal_checker")
minetest.register_alias("coal_checker", "moreblocks:coal_checker")
minetest.register_alias("ironchecker", "moreblocks:iron_checker")
minetest.register_alias("iron_checker", "moreblocks:iron_checker")
minetest.register_alias("woodtile", "moreblocks:wood_tile")
minetest.register_alias("woodentile", "moreblocks:wood_tile")
minetest.register_alias("wood_tile", "moreblocks:wood_tile")
minetest.register_alias("wooden_tile", "moreblocks:wood_tile")
minetest.register_alias("woodtile_full", "moreblocks:wood_tile_full")
minetest.register_alias("woodentile_full", "moreblocks:wood_tile_full")
minetest.register_alias("wood_tile_full", "moreblocks:wood_tile_full")
minetest.register_alias("wooden_tile_full", "moreblocks:wood_tile_full")
minetest.register_alias("full_woodtile", "moreblocks:wood_tile_full")
minetest.register_alias("full_woodentile", "moreblocks:wood_tile_full")
minetest.register_alias("full_wood_tile", "moreblocks:wood_tile_full")
minetest.register_alias("full_wooden_tile", "moreblocks:wood_tile_full")
-- Old block/item replacement
minetest.register_alias("moreblocks:oerkkiblock", "default:mossycobble")
@ -156,6 +16,10 @@ minetest.register_alias("moreblocks:stonebrick", "default:stonebrick")
minetest.register_alias("moreblocks:junglewood", "default:junglewood")
minetest.register_alias("moreblocks:jungle_wood", "default:junglewood")
for _, t in pairs(circular_saw.names) do
minetest.register_alias("moreblocks:"..t[1].."_jungle_wood"..t[2],
"moreblocks:"..t[1].."_junglewood"..t[2])
end
minetest.register_alias("moreblocks:horizontaltree", "moreblocks:horizontal_tree")
minetest.register_alias("moreblocks:horizontaljungletree", "moreblocks:horizontal_jungle_tree")
minetest.register_alias("moreblocks:stonesquare", "moreblocks:stone_tile")
@ -187,20 +51,25 @@ minetest.register_alias("moreblocks:junglestick", "moreblocks:jungle_stick")
minetest.register_alias("moreblocks:splitstonesquare","moreblocks:split_stone_tile")
minetest.register_alias("moreblocks:allfacestree","moreblocks:all_faces_tree")
-- ABM for Horizontal_tree (fix facedir).
-- ABM for horizontal trees (fix facedir).
local horizontal_tree_convert_facedir = {7, 12, 9, 18}
minetest.register_abm({
nodenames = {"moreblocks:horizontal_tree","moreblocks:horizontal_jungle_tree"},
interval = 1,
chance = 1,
action = function(pos, node)
local convert_facedir={7,12,9,18}
if node.name=="moreblocks:horizontal_tree" then
node.name="default:tree"
if node.name == "moreblocks:horizontal_tree" then
node.name = "default:tree"
else
node.name="default:jungletree"
node.name = "default:jungletree"
end
minetest.set_node(pos, {name=node.name,param2=convert_facedir[node.param2+1]})
node.param2 = node.param2 < 3 and node.param2 or 0
minetest.set_node(pos, {
name = node.name,
param2 = horizontal_tree_convert_facedir[node.param2 + 1]
})
end,
})

View File

@ -1,311 +1,315 @@
-- Load translation library if intllib is installed
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
end
local S = moreblocks.gettext
circular_saw = {}
circular_saw = {};
circular_saw.known_stairs = {}
-- Register known moreblocks stairs.
for i,v in ipairs({"default:wood", "default:stone", "default:cobble", "default:mossycobble", "default:brick", "default:sandstone",
"default:steelblock", "default:desert_stone", "default:glass", "default:tree", "default:jungletree", "default:stonebrick",
"default:obsidian", "default:obsidian_glass", "default:stone_bricks", "default:junglewood", "default:goldblock",
"default:copperblock", "default:bronzeblock", "default:diamondblock", "default:desert_stonebrick", "default:sandstonebrick",
"moreblocks:coal_stone", "moreblocks:iron_stone", "moreblocks:coal_checker", "moreblocks:iron_checker",
"moreblocks:cactus_checker", "moreblocks:coal_glass", "moreblocks:iron_glass", "moreblocks:glow_glass",
"moreblocks:super_glow_glass", "moreblocks:wooden_tile", "moreblocks:stone_tile", "moreblocks:split_stone_tile",
"moreblocks:coal_stone_bricks","moreblocks:iron_stone_bricks", "moreblocks:circle_stone_bricks",
"moreblocks:wood_tile_centered", "moreblocks:wood_tile_full", "moreblocks:plank_stone"}) do
table.insert(circular_saw.known_stairs, v);
end
circular_saw.known_stairs = setmetatable({}, {
__newindex = function(k, v)
local modname = minetest.get_current_modname()
print(("Mod %s tried to add node %s to the circular saw"
.." manually!"):format(modname, v))
end,
})
-- This is populated by stairsplus:register_all
circular_saw.known_nodes = {}
-- How many microblocks does this shape at the output inventory cost?
circular_saw.cost_in_microblocks = { 1, 1, 1, 1, 1, 1, 1, 2,
circular_saw.cost_in_microblocks = {
1, 1, 1, 1, 1, 1, 1, 2,
2, 3, 2, 4, 2, 4, 5, 6,
7, 1, 1, 2, 4, 6, 7, 8,
3, 1, 1, 2, 4, 0, 0, 0, };
3, 1, 1, 2, 4, 0, 0, 0,
}
-- anz: amount of input material in microblocks.
circular_saw.get_stair_output_inv = function(modname, material, anz, max)
circular_saw.names = {
{"micro", "_1"},
{"panel", "_1"},
{"micro", "_2"},
{"panel", "_2"},
{"micro", "_4"},
{"panel", "_4"},
{"micro", ""},
{"panel", ""},
{"micro", "_12"},
{"panel", "_12"},
{"micro", "_14"},
{"panel", "_14"},
{"micro", "_15"},
{"panel", "_15"},
{"stair", "_outer"},
{"stair", ""},
{"stair", "_inner"},
{"slab", "_1"},
{"slab", "_2"},
{"slab", "_quarter"},
{"slab", ""},
{"slab", "_three_quarter"},
{"slab", "_14"},
{"slab", "_15"},
{"stair", "_half"},
{"stair", "_alt_1"},
{"stair", "_alt_2"},
{"stair", "_alt_4"},
{"stair", "_alt"},
}
local max_offered = 99;
function circular_saw:get_cost(inv, stackname)
for i, item in pairs(inv:get_list("output")) do
if item:get_name() == stackname then
return circular_saw.cost_in_microblocks[i]
end
end
end
if(not(max) or (max == nil) or tonumber(max) > 99 or tonumber(max) < 1) then
max_offered = 99;
else
max_offered = tonumber(max);
function circular_saw:get_output_inv(modname, material, amount, max)
if (not max or max < 1) then
max = 99
end
-- If there is nothing inside display empty inventory.
if(anz < 1) then
return { "", "", "", "", "", "", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", "",
"", "", "", "", "", "", ""};
local list = {}
-- If there is nothing inside display empty inventory
if amount < 1 then
return list
end
return {
modname .. ":micro_" .. material .. "_1 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":panel_" .. material .. "_1 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":micro_" .. material .. "_2 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":panel_" .. material .. "_2 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":micro_" .. material .. "_4 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":panel_" .. material .. "_4 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":micro_" .. material .. " " .. math.min(math.floor(anz/1), max_offered),
modname .. ":panel_" .. material .. " " .. math.min(math.floor(anz/2), max_offered),
modname .. ":micro_" .. material .. "_12 " .. math.min(math.floor(anz/2), max_offered),
modname .. ":panel_" .. material .. "_12 " .. math.min(math.floor(anz/3), max_offered),
modname .. ":micro_" .. material .. "_14 " .. math.min(math.floor(anz/2), max_offered),
modname .. ":panel_" .. material .. "_14 " .. math.min(math.floor(anz/4), max_offered),
modname .. ":micro_" .. material .. "_15 " .. math.min(math.floor(anz/2), max_offered),
modname .. ":panel_" .. material .. "_15 " .. math.min(math.floor(anz/4), max_offered),
modname .. ":stair_" .. material .. "_outer " .. math.min(math.floor(anz/5), max_offered),
modname .. ":stair_" .. material .. " " .. math.min(math.floor(anz/6), max_offered),
modname .. ":stair_" .. material .. "_inner " .. math.min(math.floor(anz/7), max_offered),
modname .. ":slab_" .. material .. "_1 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":slab_" .. material .. "_2 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":slab_" .. material .. "_quarter " .. math.min(math.floor(anz/2), max_offered),
modname .. ":slab_" .. material .. " " .. math.min(math.floor(anz/4), max_offered),
modname .. ":slab_" .. material .. "_three_quarter " .. math.min(math.floor(anz/6), max_offered),
modname .. ":slab_" .. material .. "_14 " .. math.min(math.floor(anz/7), max_offered),
modname .. ":slab_" .. material .. "_15 " .. math.min(math.floor(anz/8), max_offered),
modname .. ":stair_" .. material .. "_half " .. math.min(math.floor(anz/3), max_offered),
modname .. ":stair_" .. material .. "_alt_1 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":stair_" .. material .. "_alt_2 " .. math.min(math.floor(anz/1), max_offered),
modname .. ":stair_" .. material .. "_alt_4 " .. math.min(math.floor(anz/2), max_offered),
modname .. ":stair_" .. material .. "_alt " .. math.min(math.floor(anz/4), max_offered),
"",
}
for i, t in ipairs(circular_saw.names) do
local cost = circular_saw.cost_in_microblocks[i]
table.insert(list, modname..":"..t[1].."_"..material..t[2]
.." "..math.min(math.floor(amount/cost), max))
end
return list
end
-- Reset empty circular_saw after last full block has been taken out (or the circular_saw has been placed the first tiem); note: max_offered is not reset.
circular_saw.reset_circular_saw = function(pos)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory();
-- Reset empty circular_saw after last full block has been taken out
-- (or the circular_saw has been placed the first time)
-- note: max_offered is not reset
function circular_saw:reset(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
inv:set_list("input", { "" });
inv:set_list("micro", { "" });
inv:set_list("output", circular_saw.get_stair_output_inv("", "", 0, meta:get_string("max_offered")));
meta:set_int("anz", 0);
inv:set_list("input", {})
inv:set_list("micro", {})
inv:set_list("output", {})
meta:set_int("anz", 0)
meta:set_string("infotext", S("Circular saw, empty (owned by %s)"):format((meta:get_string("owner") or "")));
meta:set_string("infotext",
S("Circular saw, empty (owned by %s)")
:format(meta:get_string("owner") or ""))
end
-- Player has taken something out of the box or placed something inside; that amounts to count microblocks.
circular_saw.update_inventory = function(pos, amount)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory();
local akt = meta:get_int("anz");
-- Player has taken something out of the box or placed something inside
-- that amounts to count microblocks
function circular_saw:update_inventory(pos, amount)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
-- The material is receicled automaticly
inv:set_list("recycle", { "" });
amount = meta:get_int("anz") + amount
if(akt + amount < 1) then -- If the last block is taken out
circular_saw.reset_circular_saw(pos);
return;
-- The material is recycled automaticly.
inv:set_list("recycle", {})
if amount < 1 then -- If the last block is taken out.
self:reset(pos)
return
end
local stack = inv:get_stack("input", 1);
local stack = inv:get_stack("input", 1)
-- At least one "normal" block is necessary to see what kind of stairs are requested.
if(stack:is_empty()) then
-- Any microblocks not taken out yet are now lost (covers material loss in the machine).
circular_saw.reset_circular_saw(pos);
return;
if stack:is_empty() then
-- Any microblocks not taken out yet are now lost.
-- (covers material loss in the machine)
self:reset(pos)
return
end
local node_name = stack:get_name();
local liste = node_name:split(":");
local modname = liste[1];
local material = liste[2];
local node_name = stack:get_name()
local name_parts = circular_saw.known_nodes[node_name]
local modname = name_parts[1]
local material = name_parts[2]
-- Display as many full blocks as possible.
inv:set_list("input", { modname.. ":" .. material .. " " .. math.floor( (akt + amount) / 8) });
-- Display as many full blocks as possible
inv:set_list("input", {
node_name.." ".. math.floor(amount / 8)
})
-- The stairnodes made of default nodes use moreblocks namespace, other mods keep own.
if(modname == "default") then modname = "moreblocks"; end
--print("circular_saw set to " ..modname.. " : " ..material.. " with " .. (akt+amount) .. " microblocks.");
if modname == "default" then
modname = "moreblocks"
end
--print("circular_saw set to " ..modname.. " : "
-- ..material.. " with "..(amount).." microblocks.")
-- 0-7 microblocks may remain as a rest.
inv:set_list("micro", { modname.. ":micro_" .. material .. "_bottom " .. ((akt + amount) % 8) });
-- Display.
inv:set_list("output", circular_saw.get_stair_output_inv(modname, material, (akt + amount), meta:get_string("max_offered")));
-- Store how many microblocks are available.
meta:set_int("anz", (akt+amount));
-- 0-7 microblocks may remain left-over.
inv:set_list("micro", {
modname..":micro_"..material.."_bottom "..(amount % 8)
})
-- Display
inv:set_list("output",
self:get_output_inv(modname, material, amount,
meta:get_int("max_offered")))
-- Store how many microblocks are available
meta:set_int("anz", amount)
meta:set_string("infotext", S("Circular saw, working with %s (owned by %s)"):format(material,(meta:get_string("owner") or "")));
meta:set_string("infotext",
S("Circular saw, working with %s (owned by %s)")
:format(material, meta:get_string("owner") or ""))
end
-- The amount of items offered per shape can be configured.
circular_saw.on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos);
if tonumber(fields.max_offered) and tonumber(fields.max_offered) > 0 and tonumber(fields.max_offered) < 99 then
meta:set_string("max_offered", fields.max_offered);
circular_saw.update_inventory(pos, 0); -- Update to show the correct number of items.
-- The amount of items offered per shape can be configured
function circular_saw.on_receive_fields(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local max = tonumber(fields.max_offered)
if max and max > 0 then
meta:set_string("max_offered", max)
-- update to show the correct number of items
circular_saw:update_inventory(pos, 0)
end
end
-- Moving the inventory of the circular_saw around is not allowed because it is a fictional inventory.
circular_saw.allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
-- Moving inventory around would be rather immpractical and make things more difficult to calculate.
return 0;
-- Moving the inventory of the circular_saw around is not allowed because it
-- is a fictional inventory. Moving inventory around would be rather
-- impractical and make things more difficult to calculate.
function circular_saw.allow_metadata_inventory_move(
pos, from_list, from_index, to_list, to_index, count, player)
return 0
end
-- Only input- and recycle-slot are intended as input slots.
circular_saw.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
-- The player is not allowed to put something in there.
if(listname == "output" or listname == "micro") then
return 0;
-- Only input- and recycle-slot are intended as input slots
function circular_saw.allow_metadata_inventory_put(
pos, listname, index, stack, player)
-- The player is not allowed to put something in there
if listname == "output" or listname == "micro" then
return 0
end
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory();
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stackname = stack:get_name()
local count = stack:get_count()
-- Only alow those items that are offered in the output inventory to be recycled.
if(listname == "recycle" and not(inv:contains_item("output", stack:get_name()))) then
return 0;
-- Only alow those items that are offered in the output inventory to be recycled
if listname == "recycle" then
if not inv:contains_item("output", stackname) then
return 0
end
local stackmax = stack:get_stack_max()
local instack = inv:get_stack("input", 1)
local microstack = inv:get_stack("micro", 1)
local incount = instack:get_count()
local incost = (incount * 8) + microstack:get_count()
local maxcost = (stackmax * 8) + 7
local cost = circular_saw:get_cost(inv, stackname)
if (incost + cost) > maxcost then
return math.max((maxcost - incost) / cost, 0)
end
return count
end
-- Only accept certain blocks as input which are known to be craftable into stairs.
if(listname == "input") then
for i,v in ipairs(circular_saw.known_stairs) do
if(circular_saw.known_stairs[ i ] == stack:get_name()) and inv:room_for_item("input", stack) then
return stack:get_count();
-- Only accept certain blocks as input which are known to be craftable into stairs
if listname == "input" then
if not inv:is_empty("input") and
inv:get_stack("input", index):get_name() ~= stackname then
return 0
end
end
return 0;
end
return stack:get_count()
end
-- Taking is allowed from all slots (even the internal microblock slot).
-- Putting something in is slightly more complicated than taking anything because we have to make sure it is of a suitable material.
circular_saw.on_metadata_inventory_put = function(pos, listname, index, stack, player)
-- We need to find out if the circular_saw is already set to a specific material or not.
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory();
-- Putting something into the input slot is only possible if that had been empty before or did contain something of the same material.
if( listname=="input") then
if( not( inv:is_empty("input"))) then
local old_stack = inv:get_stack("input", 1 );
if( old_stack:get_name() ~= stack:get_name() ) then
return 0;
end
end
-- Each new block is worth 8 microblocks.
circular_saw.update_inventory(pos, 8 * stack:get_count());
elseif(listname=="recycle") then
-- Lets look which shape this represents.
for i,v in ipairs(inv:get_list("output")) do
if(v:get_name() == stack:get_name()) then
local value = circular_saw.cost_in_microblocks[ i ] * stack:get_count();
--print("\nRecycling " .. (v:get_name()) .. " into " ..value.. " microblocks.");
-- We get value microblocks back.
circular_saw.update_inventory(pos, value);
for name, t in pairs(circular_saw.known_nodes) do
if name == stackname and inv:room_for_item("input", stack) then
return count
end
end
return 0
end
end
-- The player takes something.
circular_saw.on_metadata_inventory_take = function(pos, listname, index, stack, player)
-- Taking is allowed from all slots (even the internal microblock slot)
-- Putting something in is slightly more complicated than taking anything
-- because we have to make sure it is of a suitable material
function circular_saw.on_metadata_inventory_put(
pos, listname, index, stack, player)
-- We need to find out if the circular_saw is already set to a
-- specific material or not
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stackname = stack:get_name()
local count = stack:get_count()
-- If it is one of the offered stairs: find out how many microblocks have to be substracted.
if (listname=="output") then
-- Putting something into the input slot is only possible if that had
-- been empty before or did contain something of the same material
if listname == "input" then
-- Each new block is worth 8 microblocks
circular_saw:update_inventory(pos, 8 * count)
elseif listname == "recycle" then
-- Lets look which shape this represents
local cost = circular_saw:get_cost(inv, stackname)
circular_saw:update_inventory(pos, cost * count)
end
end
-- We do know how much each block at each position costs.
local cost = circular_saw.cost_in_microblocks[ index ] * stack:get_count();
circular_saw.update_inventory(pos, -1 * cost);
elseif (listname=="micro") then
-- Each microblock costs 1 microblock.
circular_saw.update_inventory(pos, -1 * 1 * stack:get_count());
elseif (listname=="input") then
-- Each normal (= full) block taken costs 8 microblocks.
circular_saw.update_inventory(pos, -1 * 8 * stack:get_count());
function circular_saw.on_metadata_inventory_take(
pos, listname, index, stack, player)
-- If it is one of the offered stairs: find out how many
-- microblocks have to be substracted
if listname == "output" then
-- We do know how much each block at each position costs
local cost = circular_saw.cost_in_microblocks[index]
* stack:get_count()
circular_saw:update_inventory(pos, -cost)
elseif listname == "micro" then
-- Each microblock costs 1 microblock
circular_saw:update_inventory(pos, -stack:get_count())
elseif listname == "input" then
-- Each normal (= full) block taken costs 8 microblocks
circular_saw:update_inventory(pos, 8 * -stack:get_count())
end
-- The recycle field plays no role here since it is processed immediately.
end
circular_saw.on_construct_init = function(pos, formspec)
function circular_saw.on_construct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[11,9]"..
"label[0,0;"..S("Input\nmaterial").."]"..
"list[current_name;input;1.5,0;1,1;]"..
"label[0,1;"..S("Left-over").."]"..
"list[current_name;micro;1.5,1;1,1;]"..
"label[0,2;"..S("Recycle\noutput").."]"..
"list[current_name;recycle;1.5,2;1,1;]"..
"field[0.3,3.5;1,1;max_offered;"..S("Max")..":;${max_offered}]"..
"button[1,3.2;1,1;Set;"..S("Set").."]"..
"list[current_name;output;2.8,0;8,4;]"..
"list[current_player;main;1.5,5;8,4;]")
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec", formspec);
meta:set_int( "anz", 0); -- No microblocks inside yet.
meta:set_string("max_offered", 99); -- How many items of this kind are offered by default?
meta:set_int("anz", 0) -- No microblocks inside yet
meta:set_string("max_offered", 99) -- How many items of this kind are offered by default?
meta:set_string("infotext", S("Circular saw, empty"))
local inv = meta:get_inventory()
inv:set_size("input", 1) -- Input slot for full blocks of material x
inv:set_size("micro", 1) -- Storage for 1-7 surplus microblocks
inv:set_size("recycle", 1) -- Surplus partial blocks can be placed here
inv:set_size("output", 32) -- 4*7 versions of stair-parts of material x
inv:set_size("output", 4*8) -- 4x8 versions of stair-parts of material x
circular_saw.reset_circular_saw(pos);
circular_saw:reset(pos)
end
circular_saw.can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
function circular_saw.can_dig(pos,player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
if not inv:is_empty("input") then
return false
elseif not inv:is_empty("micro") then
return false
elseif not inv:is_empty("recycle") then
if not inv:is_empty("input") or
not inv:is_empty("micro") or
not inv:is_empty("recycle") then
return false
end
-- Can be digged by anyone when empty (not only by the owner)
-- Can be dug by anyone when empty (not only by the owner)
return true
end,
end
minetest.register_node("moreblocks:circular_saw", {
description = S("Circular Saw"),
@ -313,71 +317,43 @@ minetest.register_node("moreblocks:circular_saw", {
node_box = {
type = "fixed",
fixed = {
{-0.4, -0.5, -0.4, -0.25, 0.25, -0.25}, -- leg
{0.25, -0.5, 0.25, 0.4, 0.25, 0.4}, -- leg
{-0.4, -0.5, 0.25, -0.25, 0.25, 0.4}, -- leg
{0.25, -0.5, -0.4, 0.4, 0.25, -0.25}, -- leg
{-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- tabletop
{-0.01, 0.4375, -0.125, 0.01, 0.5, 0.125}, -- saw blade (top)
{-0.01, 0.375, -0.1875, 0.01, 0.4375, 0.1875}, -- saw blade (bottom)
{-0.25, -0.0625, -0.25, 0.25, 0.25, 0.25}, -- motor case
{-0.4, -0.5, -0.4, -0.25, 0.25, -0.25}, -- Leg
{0.25, -0.5, 0.25, 0.4, 0.25, 0.4}, -- Leg
{-0.4, -0.5, 0.25, -0.25, 0.25, 0.4}, -- Leg
{0.25, -0.5, -0.4, 0.4, 0.25, -0.25}, -- Leg
{-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- Tabletop
{-0.01, 0.4375, -0.125, 0.01, 0.5, 0.125}, -- Saw blade (top)
{-0.01, 0.375, -0.1875, 0.01, 0.4375, 0.1875}, -- Saw blade (bottom)
{-0.25, -0.0625, -0.25, 0.25, 0.25, 0.25}, -- Motor case
},
},
tiles = {"moreblocks_circular_saw_top.png", "moreblocks_circular_saw_bottom.png", "moreblocks_circular_saw_side.png"},
tiles = {"moreblocks_circular_saw_top.png",
"moreblocks_circular_saw_bottom.png",
"moreblocks_circular_saw_side.png"},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {cracky=2},
on_construct = function(pos)
return circular_saw.on_construct_init(pos,
"size[10,9]" ..
"list[current_name;input;0,0;1,1;]" ..
"label[0,0;"..S("Input material").."]" ..
"list[current_name;micro;0,1;1,1;]" ..
"label[0,1;"..S("Rest/microblocks").."]" ..
"field[0.3,2.5;1,1;max_offered;"..S("Max:")..";${max_offered}]" ..
"button[1,2;1,1;Set;"..S("Set").."]" ..
"list[current_name;recycle;0,3;1,1;]" ..
"label[0,3;"..S("Recycle output").."]" ..
"list[current_name;output;2,0;8,4;]" ..
"list[current_player;main;1,5;8,4;]");
end,
can_dig = function(pos,player)
return circular_saw.can_dig(pos, player);
end,
-- Set owner of this circular saw.
on_construct = circular_saw.on_construct,
can_dig = circular_saw.can_dig,
-- Set owner of this circular saw
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos);
meta:set_string("owner", (placer:get_player_name() or ""));
meta:set_string("infotext", S("Circular saw is empty (owned by %s)"):format((placer:get_player_name() or "")));
local meta = minetest.get_meta(pos)
local owner = placer and placer:get_player_name() or ""
meta:set_string("owner", owner)
meta:set_string("infotext",
S("Circular saw is empty (owned by %s)")
:format(owner))
end,
-- The amount of items offered per shape can be configured.
on_receive_fields = function(pos, formname, fields, sender)
return circular_saw.on_receive_fields(pos, formname, fields, sender);
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
return circular_saw.allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player);
end,
-- Only input- and recycle-slot are intended as input slots.
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
return circular_saw.allow_metadata_inventory_put(pos, listname, index, stack, player);
end,
-- Taking is allowed from all slots (even the internal microblock slot); moving is forbidden.
-- Putting something in is slightly more complicated than taking anything because we have to make sure it is of a suitable material.
on_metadata_inventory_put = function(pos, listname, index, stack, player)
return circular_saw.on_metadata_inventory_put(pos, listname, index, stack, player);
end,
on_metadata_inventory_take = function(pos, listname, index, stack, player)
return circular_saw.on_metadata_inventory_take(pos, listname, index, stack, player);
end
-- The amount of items offered per shape can be configured
on_receive_fields = circular_saw.on_receive_fields,
allow_metadata_inventory_move = circular_saw.allow_metadata_inventory_move,
-- Only input- and recycle-slot are intended as input slots
allow_metadata_inventory_put = circular_saw.allow_metadata_inventory_put,
-- Taking is allowed from all slots (even the internal microblock slot). Moving is forbidden.
-- Putting something in is slightly more complicated than taking anything because we have to make sure it is of a suitable material
on_metadata_inventory_put = circular_saw.on_metadata_inventory_put,
on_metadata_inventory_take = circular_saw.on_metadata_inventory_take,
})

30
config.lua Normal file
View File

@ -0,0 +1,30 @@
moreblocks.config = {}
local function getbool_default(setting, default)
local value = minetest.setting_getbool(setting)
if value == nil then
value = default
end
return value
end
local function setting(settingtype, name, default)
if settingtype == "bool" then
moreblocks.config[name] =
getbool_default("moreblocks."..name, default)
else
moreblocks.config[name] =
minetest.setting_get("moreblocks."..name) or default
end
end
-- Whether to direct wood based on player yaw when placing the block (true or false)
setting("bool", "wood_facedir", true)
-- Allow stair/slab crafting without a circular saw or not (true or false)
setting("bool", "allow_stair_slab_crafting", false)
-- Show stairs/slabs/panels/microblocks in creative inventory (true or false)
setting("bool", "show_stairsplus_creative_inv", false)

View File

@ -352,3 +352,4 @@ minetest.register_craft({
{ "default:tree", "", "default:tree"},
}
})

View File

@ -1 +1,2 @@
default
intllib?

380
init.lua
View File

@ -1,375 +1,31 @@
--[[
****
More Blocks
by Calinou
Licensed under the zlib/libpng license for code and CC BY-SA for textures, see LICENSE.txt for info.
****
-- More Blocks (moreblocks) by Calinou
-- Licensed under the zlib/libpng license for code and CC BY-SA for textures, see LICENSE.txt for info.
--]]
moreblocks = {}
-- Load translation library if intllib is installed
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
local S = nil
if intllib then
S = intllib.Getter()
else
S = function(s) return s end
end
moreblocks.gettext = S
dofile(minetest.get_modpath("moreblocks").."/_config.txt")
local modpath = minetest.get_modpath("moreblocks")
dofile(minetest.get_modpath("moreblocks").."/ownership.lua")
dofile(minetest.get_modpath("moreblocks").."/redefinitions.lua")
dofile(minetest.get_modpath("moreblocks").."/crafting.lua")
dofile(minetest.get_modpath("moreblocks").."/aliases.lua")
dofile(minetest.get_modpath("moreblocks").."/stairsplus_convert.lua")
dofile(minetest.get_modpath("moreblocks").."/stairsplus/stairs.lua")
dofile(minetest.get_modpath("moreblocks").."/stairsplus/slabs.lua")
dofile(minetest.get_modpath("moreblocks").."/stairsplus/panels.lua")
dofile(minetest.get_modpath("moreblocks").."/stairsplus/microblocks.lua")
dofile(minetest.get_modpath("moreblocks").."/stairsplus/aliases.lua")
dofile(minetest.get_modpath("moreblocks").."/stairsplus.lua")
dofile(minetest.get_modpath("moreblocks").."/circular_saw.lua")
dofile(modpath.."/config.lua")
dofile(modpath.."/circular_saw.lua")
dofile(modpath.."/stairsplus/init.lua")
dofile(modpath.."/nodes.lua")
dofile(modpath.."/redefinitions.lua")
dofile(modpath.."/crafting.lua")
dofile(modpath.."/aliases.lua")
-- Blocks
if minetest.setting_getbool("log_mod") then
print(S("[moreblocks] loaded."))
end
minetest.register_node("moreblocks:wood_tile", {
description = S("Wooden Tile"),
tiles = {"moreblocks_wood_tile.png", "moreblocks_wood_tile.png", "moreblocks_wood_tile.png", "moreblocks_wood_tile.png", "moreblocks_wood_tile.png^[transformR90", "moreblocks_wood_tile.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:wood_tile_flipped", {
description = S("Wooden Tile"),
tiles = {"moreblocks_wood_tile_flipped.png", "moreblocks_wood_tile_flipped.png", "moreblocks_wood_tile_flipped.png", "moreblocks_wood_tile_flipped.png", "moreblocks_wood_tile_flipped.png^[transformR90", "moreblocks_wood_tile_flipped.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:wood_tile_center", {
description = S("Centered Wooden Tile"),
tiles = {"moreblocks_wood_tile_center.png", "moreblocks_wood_tile_center.png", "moreblocks_wood_tile_center.png", "moreblocks_wood_tile_center.png", "moreblocks_wood_tile_center.png^[transformR90", "moreblocks_wood_tile_center.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:wood_tile_full", {
description = S("Full Wooden Tile"),
tiles = {"moreblocks_wood_tile_full.png", "moreblocks_wood_tile_full.png", "moreblocks_wood_tile_full.png",
"moreblocks_wood_tile_full.png", "moreblocks_wood_tile_full.png^[transformR90", "moreblocks_wood_tile_full.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:wood_tile_up", {
description = S("Up Wooden Tile"),
tiles = {"moreblocks_wood_tile_up.png", "moreblocks_wood_tile_up.png", "moreblocks_wood_tile_up.png",
"moreblocks_wood_tile_up.png", "moreblocks_wood_tile_up.png^[transformR90", "moreblocks_wood_tile_up.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:wood_tile_down", {
description = S("Down Wooden Tile"),
tiles = {"moreblocks_wood_tile_down.png", "moreblocks_wood_tile_down.png", "moreblocks_wood_tile_down.png",
"moreblocks_wood_tile_down.png", "moreblocks_wood_tile_down.png^[transformR90", "moreblocks_wood_tile_down.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:wood_tile_left", {
description = S("Left Wooden Tile"),
tiles = {"moreblocks_wood_tile_left.png", "moreblocks_wood_tile_left.png", "moreblocks_wood_tile_left.png",
"moreblocks_wood_tile_left.png", "moreblocks_wood_tile_left.png^[transformR90", "moreblocks_wood_tile_left.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:wood_tile_right", {
description = S("Right Wooden Tile"),
tiles = {"moreblocks_wood_tile_right.png", "moreblocks_wood_tile_right.png", "moreblocks_wood_tile_right.png",
"moreblocks_wood_tile_right.png", "moreblocks_wood_tile_right.png^[transformR90", "moreblocks_wood_tile_right.png^[transformR90"},
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:circle_stone_bricks", {
description = S("Circle Stone Bricks"),
tiles = {"moreblocks_circle_stone_bricks.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:coal_stone_bricks", {
description = S("Coal Stone Bricks"),
tiles = {"moreblocks_coal_stone_bricks.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:iron_stone_bricks", {
description = S("Iron Stone Bricks"),
tiles = {"moreblocks_iron_stone_bricks.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:stone_tile", {
description = S("Stone Tile"),
tiles = {"moreblocks_stone_tile.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:split_stone_tile", {
description = S("Split Stone Tile"),
tiles = {"moreblocks_split_stone_tile_top.png", "moreblocks_split_stone_tile.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:plankstone", {
description = S("Plankstone"),
tiles = {"moreblocks_plankstone.png", "moreblocks_plankstone.png", "moreblocks_plankstone.png",
"moreblocks_plankstone.png", "moreblocks_plankstone.png^[transformR90", "moreblocks_plankstone.png^[transformR90"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:iron_glass", {
description = S("Iron Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_iron_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_iron_glass.png"),
paramtype = "light",
sunlight_propagates = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:coal_glass", {
description = S("Coal Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_coal_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_coal_glass.png"),
paramtype = "light",
sunlight_propagates = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:clean_glass", {
description = S("Clean Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_clean_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_clean_glass.png"),
paramtype = "light",
sunlight_propagates = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:cactus_brick", {
description = S("Cactus Brick"),
tiles = {"moreblocks_cactus_brick.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:cactus_checker", {
description = S("Cactus Checker"),
tiles = {"moreblocks_cactus_checker.png", "moreblocks_cactus_checker.png", "moreblocks_cactus_checker.png",
"moreblocks_cactus_checker.png", "moreblocks_cactus_checker.png^[transformR90", "moreblocks_cactus_checker.png^[transformR90"},
paramtype2 = "facedir",
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:empty_bookshelf", {
description = S("Empty Bookshelf"),
tiles = {"default_wood.png", "default_wood.png", "moreblocks_empty_bookshelf.png"},
groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2,flammable=3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:coal_stone", {
description = S("Coal Stone"),
tiles = {"moreblocks_coal_stone.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:iron_stone", {
description = S("Iron Stone"),
tiles = {"moreblocks_iron_stone.png"},
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:coal_checker", {
description = S("Coal Checker"),
tiles = {"moreblocks_coal_checker.png", "moreblocks_coal_checker.png", "moreblocks_coal_checker.png",
"moreblocks_coal_checker.png", "moreblocks_coal_checker.png^[transformR90", "moreblocks_coal_checker.png^[transformR90"},
paramtype2 = "facedir",
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:iron_checker", {
description = S("Iron Checker"),
tiles = {"moreblocks_iron_checker.png", "moreblocks_iron_checker.png", "moreblocks_iron_checker.png",
"moreblocks_iron_checker.png", "moreblocks_iron_checker.png^[transformR90", "moreblocks_iron_checker.png^[transformR90"},
paramtype2 = "facedir",
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:trap_stone", {
description = S("Trap Stone"),
tiles = {"moreblocks_trap_stone.png"},
walkable = false,
groups = {cracky=3},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("moreblocks:trap_glass", {
description = S("Trap Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_trap_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_trap_glass.png"),
paramtype = "light",
sunlight_propagates = true,
walkable = false,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:fence_jungle_wood", {
description = S("Jungle Wood Fence"),
drawtype = "fencelike",
tiles = {"moreblocks_jungle_wood.png"},
inventory_image = "moreblocks_fence_jungle_wood.png",
wield_image = "moreblocks_fence_jungle_wood.png",
paramtype = "light",
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node("moreblocks:all_faces_tree", {
description = S("All-faces Tree"),
tiles = {"default_tree_top.png"},
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
furnace_burntime = 30,
})
minetest.register_node("moreblocks:all_faces_jungle_tree", {
description = S("All-faces Tree"),
tiles = {"default_jungletree_top.png"},
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = default.node_sound_wood_defaults(),
furnace_burntime = 30,
})
minetest.register_node("moreblocks:glow_glass", {
description = S("Glow Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_glow_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_glow_glass.png"),
paramtype = "light",
sunlight_propagates = true,
light_source = 11,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:trap_glow_glass", {
description = S("Trap Glow Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_glow_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_glow_glass.png"),
paramtype = "light",
sunlight_propagates = true,
light_source = 11,
walkable = false,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:super_glow_glass", {
description = S("Super Glow Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_super_glow_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_super_glow_glass.png"),
paramtype = "light",
sunlight_propagates = true,
light_source = 15,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:trap_super_glow_glass", {
description = S("Trap Super Glow Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_glow_glass.png"},
inventory_image = minetest.inventorycube("moreblocks_glow_glass.png"),
paramtype = "light",
sunlight_propagates = true,
light_source = 11,
walkable = false,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = default.node_sound_glass_defaults(),
})
minetest.register_node("moreblocks:rope", {
description = S("Rope"),
drawtype = "signlike",
tiles = {"moreblocks_rope.png"},
inventory_image = "moreblocks_rope.png",
wield_image = "moreblocks_rope.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
},
groups = {snappy=3,flammable=2},
sounds = default.node_sound_leaves_defaults(),
})
-- Items
minetest.register_craftitem("moreblocks:sweeper", {
description = S("Sweeper"),
inventory_image = "moreblocks_sweeper.png",
})
minetest.register_craftitem("moreblocks:jungle_stick", {
description = S("Jungle Stick"),
inventory_image = "moreblocks_junglestick.png",
groups = {stick=1},
})
minetest.register_craftitem("moreblocks:nothing", {
on_use = minetest.item_eat(0),
})
print(S("[moreblocks] loaded."))

319
nodes.lua Normal file
View File

@ -0,0 +1,319 @@
local S = moreblocks.gettext
local sound_wood = default.node_sound_wood_defaults()
local sound_stone = default.node_sound_stone_defaults()
local sound_glass = default.node_sound_glass_defaults()
local sound_leaves = default.node_sound_leaves_defaults()
local function tile_tiles(name)
local tex = "moreblocks_"..name..".png"
return {tex, tex, tex, tex, tex.."^[transformR90", tex.."^[transformR90"}
end
local nodes = {
["wood_tile"] = {
description = S("Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile"),
sounds = sound_wood,
},
["wood_tile_flipped"] = {
description = S("Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile_flipped"),
sounds = sound_wood,
no_stairs = true,
},
["wood_tile_center"] = {
description = S("Centered Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile_center"),
sounds = sound_wood,
},
["wood_tile_full"] = {
description = S("Full Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile_full"),
sounds = sound_wood,
},
["wood_tile_up"] = {
description = S("Up Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile_up"),
sounds = sound_wood,
no_stairs = true,
},
["wood_tile_down"] = {
description = S("Down Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile_down"),
sounds = sound_wood,
no_stairs = true,
},
["wood_tile_left"] = {
description = S("Left Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile_left"),
sounds = sound_wood,
no_stairs = true,
},
["wood_tile_right"] = {
description = S("Right Wooden Tile"),
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3},
paramtype2 = "facedir",
tiles = tile_tiles("wood_tile_right"),
sounds = sound_wood,
no_stairs = true,
},
["circle_stone_bricks"] = {
description = S("Circle Stone Bricks"),
groups = {cracky=3},
sounds = sound_stone,
},
["coal_stone_bricks"] = {
description = S("Coal Stone Bricks"),
groups = {cracky=3},
sounds = sound_stone,
},
["iron_stone_bricks"] = {
description = S("Iron Stone Bricks"),
groups = {cracky=3},
sounds = sound_stone,
},
["stone_tile"] = {
description = S("Stone Tile"),
groups = {cracky=3},
sounds = sound_stone,
},
["split_stone_tile"] = {
description = S("Split Stone Tile"),
tiles = {"moreblocks_split_stone_tile_top.png",
"moreblocks_split_stone_tile.png"},
groups = {cracky=3},
sounds = sound_stone,
},
["plankstone"] = {
description = S("Plankstone"),
groups = {cracky=3},
tiles = tile_tiles("plankstone"),
sounds = sound_stone,
},
["iron_glass"] = {
description = S("Iron Glass"),
drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
},
["coal_glass"] = {
description = S("Coal Glass"),
drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
},
["clean_glass"] = {
description = S("Clean Glass"),
drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
},
["cactus_brick"] = {
description = S("Cactus Brick"),
groups = {cracky=3},
sounds = sound_stone,
},
["cactus_checker"] = {
description = S("Cactus Checker"),
groups = {cracky=3},
paramtype2 = "facedir",
tiles = tile_tiles("cactus_checker"),
sounds = sound_stone,
},
["empty_bookshelf"] = {
description = S("Empty Bookshelf"),
tiles = {"default_wood.png", "default_wood.png",
"moreblocks_empty_bookshelf.png"},
groups = {snappy=2,choppy=3,oddly_breakable_by_hand=2,flammable=3},
sounds = sound_wood,
no_stairs = true,
},
["coal_stone"] = {
description = S("Coal Stone"),
groups = {cracky=3},
sounds = sound_stone,
},
["iron_stone"] = {
description = S("Iron Stone"),
groups = {cracky=3},
sounds = sound_stone,
},
["coal_checker"] = {
description = S("Coal Checker"),
tiles = tile_tiles("coal_checker"),
paramtype2 = "facedir",
groups = {cracky=3},
sounds = sound_stone,
},
["iron_checker"] = {
description = S("Iron Checker"),
tiles = tile_tiles("iron_checker"),
paramtype2 = "facedir",
groups = {cracky=3},
sounds = sound_stone,
},
["trap_stone"] = {
description = S("Trap Stone"),
walkable = false,
groups = {cracky=3},
sounds = sound_stone,
no_stairs = true,
},
["trap_glass"] = {
description = S("Trap Glass"),
drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
no_stairs = true,
},
["fence_jungle_wood"] = {
description = S("Jungle Wood Fence"),
drawtype = "fencelike",
tiles = {"moreblocks_jungle_wood.png"},
inventory_image = "moreblocks_fence_jungle_wood.png",
wield_image = "moreblocks_fence_jungle_wood.png",
paramtype = "light",
selection_box = {
type = "fixed",
fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,flammable=2},
sounds = sound_wood,
no_stairs = true,
},
["all_faces_tree"] = {
description = S("All-faces Tree"),
tiles = {"default_tree_top.png"},
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = sound_wood,
furnace_burntime = 30,
},
["all_faces_jungle_tree"] = {
description = S("All-faces Tree"),
tiles = {"default_jungletree_top.png"},
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
sounds = sound_wood,
furnace_burntime = 30,
},
["glow_glass"] = {
description = S("Glow Glass"),
drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
light_source = 11,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
},
["trap_glow_glass"] = {
description = S("Trap Glow Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_glow_glass.png"},
paramtype = "light",
sunlight_propagates = true,
light_source = 11,
walkable = false,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
no_stairs = true,
},
["super_glow_glass"] = {
description = S("Super Glow Glass"),
drawtype = "glasslike",
paramtype = "light",
sunlight_propagates = true,
light_source = 15,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
},
["trap_super_glow_glass"] = {
description = S("Trap Super Glow Glass"),
drawtype = "glasslike",
tiles = {"moreblocks_super_glow_glass.png"},
paramtype = "light",
sunlight_propagates = true,
light_source = 11,
walkable = false,
groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3},
sounds = sound_glass,
no_stairs = true,
},
["rope"] = {
description = S("Rope"),
drawtype = "signlike",
inventory_image = "moreblocks_rope.png",
wield_image = "moreblocks_rope.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
},
groups = {snappy=3,flammable=2},
sounds = sound_leaves,
no_stairs = true,
},
}
for name, def in pairs(nodes) do
def.tiles = def.tiles or {"moreblocks_"..name..".png"}
minetest.register_node("moreblocks:"..name, def)
minetest.register_alias(name, "moreblocks:"..name)
if not def.no_stairs then
local groups = {}
for k, v in pairs(def.groups) do groups[k] = v end
stairsplus:register_all("moreblocks", name, "moreblocks:"..name, {
description = def.description,
groups = groups,
tiles = def.tiles,
sunlight_propagates = def.sunlight_propagates,
light_source = def.light_source,
sounds = def.sounds,
})
end
end
-- Items
minetest.register_craftitem("moreblocks:sweeper", {
description = S("Sweeper"),
inventory_image = "moreblocks_sweeper.png",
})
minetest.register_craftitem("moreblocks:jungle_stick", {
description = S("Jungle Stick"),
inventory_image = "moreblocks_junglestick.png",
groups = {stick=1},
})
minetest.register_craftitem("moreblocks:nothing", {
inventory_image = "invisible.png",
on_use = function() end,
})

View File

@ -70,203 +70,66 @@ minetest.register_craft({
-- Redefinitions of some default nodes
minetest.register_node(":default:ladder", {
description = "Ladder",
drawtype = "signlike",
tiles = {"default_ladder.png"},
inventory_image = "default_ladder.png",
wield_image = "default_ladder.png",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "wallmounted",
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
},
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=3,flammable=2},
legacy_wallmounted = true,
sounds = default.node_sound_wood_defaults(),
})
-- Don't bother overriding nodes if minetest.override_item isn't available
if minetest.override_item then
if wood_facedir == true
then
minetest.register_node(":default:wood", {
description = "Wooden Planks",
tiles = {"default_wood.png"},
if moreblocks.config.wood_facedir then
minetest.override_item("default:wood", {
paramtype2 = "facedir",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
sounds = default.node_sound_wood_defaults(),
})
})
end
minetest.register_node(":default:sapling", {
description = "Sapling",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_sapling.png"},
inventory_image = "default_sapling.png",
wield_image = "default_sapling.png",
-- Let there be light!
minetest.override_item("default:ladder", {
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
sounds = default.node_sound_defaults(),
})
minetest.register_node(":default:dry_shrub", {
description = "Dry Shrub",
drawtype = "plantlike",
visual_scale = 1.0,
tiles = {"default_dry_shrub.png"},
inventory_image = "default_dry_shrub.png",
wield_image = "default_dry_shrub.png",
minetest.override_item("default:sapling", {
paramtype = "light",
sunlight_propagates = true,
walkable = false,
groups = {snappy=3,flammable=3,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-1/3, -1/2, -1/3, 1/3, 1/6, 1/3},
},
})
minetest.register_node(":default:papyrus", {
description = "Papyrus",
drawtype = "plantlike",
tiles = {"default_papyrus.png"},
inventory_image = "default_papyrus.png",
wield_image = "default_papyrus.png",
minetest.override_item("default:dry_shrub", {
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
},
groups = {snappy=3,flammable=2},
sounds = default.node_sound_leaves_defaults(),
})
minetest.register_node(":default:fence_wood", {
description = "Wooden Fence",
drawtype = "fencelike",
tiles = {"default_wood.png"},
inventory_image = "default_fence.png",
wield_image = "default_fence.png",
minetest.override_item("default:papyrus", {
paramtype = "light",
sunlight_propagates = true,
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,flammable=2},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_node(":default:junglegrass", {
description = "Jungle Grass",
drawtype = "plantlike",
visual_scale = 1.3,
tiles = {"default_junglegrass.png"},
inventory_image = "default_junglegrass.png",
wield_image = "default_junglegrass.png",
minetest.override_item("default:fence_wood", {
paramtype = "light",
walkable = false,
buildable_to = true,
is_ground_content = true,
sunlight_propagates = true,
drop = {
max_items = 1,
items = {
{items = {'farming:seed_cotton'},rarity = 8},
{items = {'default:junglegrass'}},
}
},
groups = {snappy=3,flammable=2,flora=1,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
})
minetest.register_node(":default:junglesapling", {
description = "Jungle Sapling",
drawtype = "plantlike",
sunlight_propagates = true,
tiles = {"default_junglesapling.png"},
minetest.override_item("default:junglegrass", {
paramtype = "light",
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3}
},
groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1},
sounds = default.node_sound_defaults(),
sunlight_propagates = true,
})
minetest.register_node(":default:grass_1", {
description = "Grass",
drawtype = "plantlike",
tiles = {"default_grass_1.png"},
-- use a bigger inventory image
minetest.override_item("default:junglesapling", {
paramtype = "light",
sunlight_propagates = true,
})
minetest.override_item("default:grass_1", {
-- Use a bigger inventory image
inventory_image = "default_grass_3.png",
wield_image = "default_grass_3.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
drop = {
max_items = 1,
items = {
{items = {'farming:seed_wheat'},rarity = 5},
{items = {'default:grass_1'}},
}
},
groups = {snappy=3,flammable=3,flora=1,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
on_place = function(itemstack, placer, pointed_thing)
-- place a random grass node
local stack = ItemStack("default:grass_"..math.random(1,5))
local ret = minetest.item_place(stack, placer, pointed_thing)
return ItemStack("default:grass_1 "..itemstack:get_count()-(1-ret:get_count()))
end,
})
for i=2,5 do
minetest.register_node(":default:grass_"..i, {
description = "Grass",
drawtype = "plantlike",
tiles = {"default_grass_"..i..".png"},
inventory_image = "default_grass_"..i..".png",
wield_image = "default_grass_"..i..".png",
for i = 2, 5 do
minetest.override_item("default:grass_"..i, {
paramtype = "light",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
is_ground_content = true,
drop = {
max_items = 1,
items = {
{items = {'farming:seed_wheat'},rarity = 5},
{items = {'default:grass_1'}},
}
},
groups = {snappy=3,flammable=3,flora=1,attached_node=1,not_in_creative_inventory=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
})
end
end -- End if minetest.override_item

25
stairsplus/API.md Normal file
View File

@ -0,0 +1,25 @@
API documentation for StairsPlus
================================
- - - - - - - - - - - - - - - -
* `stairsplus:register_all(modname, subname, recipeitem, fields)`
Registers a stair, slab, panel, microblock, and any other types of
microblocks to be added in the future.
Also registers the node with the circular saw.
Example:
```lua
stairsplus:register_all("moreblocks", "wood", "defaut:wood", {
description = "Wooden",
tiles = {"default_wood.png"},
groups = {oddly_breakabe_by_hand=1},
sounds = default.node_sound_wood_defaults(),
})
```
The following register only a particular type of microblock.
You will probably never want to use them directly.
* `stairsplus:register_stair(modname, subname, recipeitem, fields)`
* `stairsplus:register_slab(modname, subname, recipeitem, fields)`
* `stairsplus:register_panel(modname, subname, recipeitem, fields)`
* `stairsplus:register_micro(modname, subname, recipeitem, fields)`

View File

@ -1,33 +1,34 @@
function register_stairsplus_alias(modname, origname, newname)
minetest.register_alias(modname .. ":slab_" .. origname, "moreblocks:slab_" .. newname)
minetest.register_alias(modname .. ":slab_" .. origname .. "_inverted", "moreblocks:slab_" .. newname .. "_inverted")
minetest.register_alias(modname .. ":slab_" .. origname .. "_wall", "moreblocks:slab_" .. newname .. "_wall")
minetest.register_alias(modname .. ":slab_" .. origname .. "_quarter", "moreblocks:slab_" .. newname .. "_quarter")
minetest.register_alias(modname .. ":slab_" .. origname .. "_quarter_inverted", "moreblocks:slab_" .. newname .. "_quarter_inverted")
minetest.register_alias(modname .. ":slab_" .. origname .. "_quarter_wall", "moreblocks:slab_" .. newname .. "_quarter_wall")
minetest.register_alias(modname .. ":slab_" .. origname .. "_three_quarter", "moreblocks:slab_" .. newname .. "_three_quarter")
minetest.register_alias(modname .. ":slab_" .. origname .. "_three_quarter_inverted", "moreblocks:slab_" .. newname .. "_three_quarter_inverted")
minetest.register_alias(modname .. ":slab_" .. origname .. "_three_quarter_wall", "moreblocks:slab_" .. newname .. "_three_quarter_wall")
minetest.register_alias(modname .. ":stair_" .. origname, "moreblocks:stair_" .. newname)
minetest.register_alias(modname .. ":stair_" .. origname .. "_inverted", "moreblocks:stair_" .. newname .. "_inverted")
minetest.register_alias(modname .. ":stair_" .. origname .. "_wall", "moreblocks:stair_" .. newname .. "_wall")
minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half", "moreblocks:stair_" .. newname .. "_wall_half")
minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half_inverted", "moreblocks:stair_" .. newname .. "_wall_half_inverted")
minetest.register_alias(modname .. ":stair_" .. origname .. "_half", "moreblocks:stair_" .. newname .. "_half")
minetest.register_alias(modname .. ":stair_" .. origname .. "_half_inverted", "moreblocks:stair_" .. newname .. "_half_inverted")
minetest.register_alias(modname .. ":stair_" .. origname .. "_right_half", "moreblocks:stair_" .. newname .. "_right_half")
minetest.register_alias(modname .. ":stair_" .. origname .. "_right_half_inverted", "moreblocks:stair_" .. newname .. "_right_half_inverted")
minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half", "moreblocks:stair_" .. newname .. "_wall_half")
minetest.register_alias(modname .. ":stair_" .. origname .. "_wall_half_inverted", "moreblocks:stair_" .. newname .. "_wall_half_inverted")
minetest.register_alias(modname .. ":stair_" .. origname .. "_inner", "moreblocks:stair_" .. newname .. "_inner")
minetest.register_alias(modname .. ":stair_" .. origname .. "_inner_inverted", "moreblocks:stair_" .. newname .. "_inner_inverted")
minetest.register_alias(modname .. ":stair_" .. origname .. "_outer", "moreblocks:stair_" .. newname .. "_outer")
minetest.register_alias(modname .. ":stair_" .. origname .. "_outer_inverted", "moreblocks:stair_" .. newname .. "_outer_inverted")
minetest.register_alias(modname .. ":panel_" .. origname .. "_bottom", "moreblocks:panel_" .. newname .. "_bottom")
minetest.register_alias(modname .. ":panel_" .. origname .. "_top", "moreblocks:panel_" .. newname .. "_top")
minetest.register_alias(modname .. ":panel_" .. origname .. "_vertical", "moreblocks:panel_" .. newname .. "_vertical")
minetest.register_alias(modname .. ":micro_" .. origname .. "_bottom", "moreblocks:micro_" .. newname .. "_bottom")
minetest.register_alias(modname .. ":micro_" .. origname .. "_top", "moreblocks:micro_" .. newname .. "_top")
local function register_stairsplus_alias(modname, origname, newname)
minetest.register_alias(modname..":slab_"..origname, "moreblocks:slab_"..newname)
minetest.register_alias(modname..":slab_"..origname.."_inverted", "moreblocks:slab_"..newname.."_inverted")
minetest.register_alias(modname..":slab_"..origname.."_wall", "moreblocks:slab_"..newname.."_wall")
minetest.register_alias(modname..":slab_"..origname.."_quarter", "moreblocks:slab_"..newname.."_quarter")
minetest.register_alias(modname..":slab_"..origname.."_quarter_inverted", "moreblocks:slab_"..newname.."_quarter_inverted")
minetest.register_alias(modname..":slab_"..origname.."_quarter_wall", "moreblocks:slab_"..newname.."_quarter_wall")
minetest.register_alias(modname..":slab_"..origname.."_three_quarter", "moreblocks:slab_"..newname.."_three_quarter")
minetest.register_alias(modname..":slab_"..origname.."_three_quarter_inverted", "moreblocks:slab_"..newname.."_three_quarter_inverted")
minetest.register_alias(modname..":slab_"..origname.."_three_quarter_wall", "moreblocks:slab_"..newname.."_three_quarter_wall")
minetest.register_alias(modname..":stair_"..origname, "moreblocks:stair_"..newname)
minetest.register_alias(modname..":stair_"..origname.."_inverted", "moreblocks:stair_"..newname.."_inverted")
minetest.register_alias(modname..":stair_"..origname.."_wall", "moreblocks:stair_"..newname.."_wall")
minetest.register_alias(modname..":stair_"..origname.."_wall_half", "moreblocks:stair_"..newname.."_wall_half")
minetest.register_alias(modname..":stair_"..origname.."_wall_half_inverted", "moreblocks:stair_"..newname.."_wall_half_inverted")
minetest.register_alias(modname..":stair_"..origname.."_half", "moreblocks:stair_"..newname.."_half")
minetest.register_alias(modname..":stair_"..origname.."_half_inverted", "moreblocks:stair_"..newname.."_half_inverted")
minetest.register_alias(modname..":stair_"..origname.."_right_half", "moreblocks:stair_"..newname.."_right_half")
minetest.register_alias(modname..":stair_"..origname.."_right_half_inverted", "moreblocks:stair_"..newname.."_right_half_inverted")
minetest.register_alias(modname..":stair_"..origname.."_wall_half", "moreblocks:stair_"..newname.."_wall_half")
minetest.register_alias(modname..":stair_"..origname.."_wall_half_inverted", "moreblocks:stair_"..newname.."_wall_half_inverted")
minetest.register_alias(modname..":stair_"..origname.."_inner", "moreblocks:stair_"..newname.."_inner")
minetest.register_alias(modname..":stair_"..origname.."_inner_inverted", "moreblocks:stair_"..newname.."_inner_inverted")
minetest.register_alias(modname..":stair_"..origname.."_outer", "moreblocks:stair_"..newname.."_outer")
minetest.register_alias(modname..":stair_"..origname.."_outer_inverted", "moreblocks:stair_"..newname.."_outer_inverted")
minetest.register_alias(modname..":panel_"..origname.."_bottom", "moreblocks:panel_"..newname.."_bottom")
minetest.register_alias(modname..":panel_"..origname.."_top", "moreblocks:panel_"..newname.."_top")
minetest.register_alias(modname..":panel_"..origname.."_vertical", "moreblocks:panel_"..newname.."_vertical")
minetest.register_alias(modname..":micro_"..origname.."_bottom", "moreblocks:micro_"..newname.."_bottom")
minetest.register_alias(modname..":micro_"..origname.."_top", "moreblocks:micro_"..newname.."_top")
end
register_stairsplus_alias("stairsplus", "stone", "stone")
@ -59,3 +60,4 @@ register_stairsplus_alias("moreblocks", "splitstonesquare", "split_stone_tile")
register_stairsplus_alias("moreblocks", "woodtile", "wood_tile")
register_stairsplus_alias("moreblocks", "woodtile_centered", "wood_tile_centered")
register_stairsplus_alias("moreblocks", "woodtile_full", "wood_tile_full")

132
stairsplus/conversion.lua Normal file
View File

@ -0,0 +1,132 @@
-- Function to convert all stairs/slabs/etc nodes from
-- inverted, wall, etc to regular + 6d facedir
local dirs1 = {21, 20, 23, 22, 21}
local dirs2 = {15, 8, 17, 6, 15}
local dirs3 = {14, 11, 16, 5, 14}
function stairsplus:register_6dfacedir_conversion(modname, material)
--print("Register stairsplus 6d facedir conversion")
--print('ABM for '..modname..' "'..material..'"')
local objects_list1 = {
modname..":slab_"..material.."_inverted",
modname..":slab_"..material.."_quarter_inverted",
modname..":slab_"..material.."_three_quarter_inverted",
modname..":stair_"..material.."_inverted",
modname..":stair_"..material.."_wall",
modname..":stair_"..material.."_wall_half",
modname..":stair_"..material.."_wall_half_inverted",
modname..":stair_"..material.."_half_inverted",
modname..":stair_"..material.."_right_half_inverted",
modname..":panel_"..material.."_vertical",
modname..":panel_"..material.."_top",
}
local objects_list2 = {
modname..":slab_"..material.."_wall",
modname..":slab_"..material.."_quarter_wall",
modname..":slab_"..material.."_three_quarter_wall",
modname..":stair_"..material.."_inner_inverted",
modname..":stair_"..material.."_outer_inverted",
modname..":micro_"..material.."_top"
}
for _, object in pairs(objects_list1) do
local flip_upside_down = false
local flip_to_wall = false
local dest_object = object
if string.find(dest_object, "_inverted") then
flip_upside_down = true
dest_object = string.gsub(dest_object, "_inverted", "")
end
if string.find(object, "_top") then
flip_upside_down = true
dest_object = string.gsub(dest_object, "_top", "")
end
if string.find(dest_object, "_wall") then
flip_to_wall = true
dest_object = string.gsub(dest_object, "_wall", "")
end
if string.find(dest_object, "_vertical") then
flip_to_wall = true
dest_object = string.gsub(dest_object, "_vertical", "")
end
if string.find(dest_object, "_half") and not string.find(dest_object, "_right_half") then
dest_object = string.gsub(dest_object, "_half", "_right_half")
elseif string.find(dest_object, "_right_half") then
dest_object = string.gsub(dest_object, "_right_half", "_half")
end
--print(" +---> convert "..object)
--print(" | to "..dest_object)
minetest.register_abm({
nodenames = {object},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local fdir = node.param2 or 0
if flip_upside_down and not flip_to_wall then
nfdir = dirs1[fdir + 2]
elseif flip_to_wall and not flip_upside_down then
nfdir = dirs2[fdir + 1]
elseif flip_to_wall and flip_upside_down then
nfdir = dirs3[fdir + 2]
end
minetest.set_node(pos, {name = dest_object, param2 = nfdir})
end
})
end
for _, object in pairs(objects_list2) do
local flip_upside_down = false
local flip_to_wall = false
local dest_object = object
if string.find(dest_object, "_inverted") then
flip_upside_down = true
dest_object = string.gsub(dest_object, "_inverted", "")
end
if string.find(dest_object, "_top") then
flip_upside_down = true
dest_object = string.gsub(dest_object, "_top", "")
end
if string.find(dest_object, "_wall") then
flip_to_wall = true
dest_object = string.gsub(dest_object, "_wall", "")
end
--print(" +---> convert "..object)
--print(" | to "..dest_object)
minetest.register_abm({
nodenames = {object},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local fdir = node.param2
local nfdir = 20
if flip_upside_down and not flip_to_wall then
nfdir = dirs1[fdir + 1]
elseif flip_to_wall and not flip_upside_down then
nfdir = dirs2[fdir + 2]
end
minetest.set_node(pos, {name = dest_object, param2 = nfdir})
end
})
end
end

45
stairsplus/init.lua Normal file
View File

@ -0,0 +1,45 @@
-- Nodes will be called <modname>:{stair,slab,panel,micro}_<subname>
local modpath = minetest.get_modpath("moreblocks").."/stairsplus"
stairsplus = {}
stairsplus.expect_infinite_stacks = false
if not minetest.get_modpath("unified_inventory") and
minetest.setting_getbool("creative_mode") then
stairsplus.expect_infinite_stacks = true
end
function stairsplus:register_all(modname, subname, recipeitem, fields)
fields = fields or {}
fields.groups = fields.groups or {}
if not moreblocks.config.show_stairsplus_creative_inv then
fields.groups.not_in_creative_inventory = 1
end
self:register_stair(modname, subname, recipeitem, fields)
self:register_slab (modname, subname, recipeitem, fields)
self:register_panel(modname, subname, recipeitem, fields)
self:register_micro(modname, subname, recipeitem, fields)
self:register_6dfacedir_conversion(modname, subname)
circular_saw.known_nodes[recipeitem] = {modname, subname}
end
function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, images, description, drop, light)
stairsplus:register_all(modname, subname, recipeitem, {
groups = groups,
tiles = images,
description = description,
drop = drop,
light_source = light
})
end
dofile(modpath.."/conversion.lua")
dofile(modpath.."/stairs.lua")
dofile(modpath.."/slabs.lua")
dofile(modpath.."/panels.lua")
dofile(modpath.."/microblocks.lua")
dofile(modpath.."/aliases.lua")
dofile(modpath.."/registrations.lua")

View File

@ -1,142 +1,86 @@
-- Load translation library if intllib is installed
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
if intllib then
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
else
S = function(s) return s end
end
-- Node will be called <modname>micro_<subname>
-- Node will be called <modname>:micro_<subname>
function register_micro(modname, subname, recipeitem, groups, images, description, drop, light)
minetest.register_node(":"..modname .. ":micro_" .. subname, {
description = S("%s Microblock"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":micro_" .. drop,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
return stairsplus:register_micro(modname, subname, recipeitem, {
groups = groups,
tiles = images,
description = description,
drop = drop,
light_source = light,
sounds = default.node_sound_stone_defaults(),
})
end
function stairsplus:register_micro(modname, subname, recipeitem, fields)
local defs = {
[""] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":micro_" .. subname .. "_1", {
description = S("%s Microblock"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":micro_" .. drop .. "_1",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_1"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.4375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":micro_" .. subname .. "_2", {
description = S("%s Microblock"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":micro_" .. drop .. "_2",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_2"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":micro_" .. subname .. "_4", {
description = S("%s Microblock"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":micro_" .. drop .. "_4",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_4"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, -0.25, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":micro_" .. subname .. "_12", {
description = S("%s Microblock"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":micro_" .. drop .. "_12",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_12"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.25, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":micro_" .. subname .. "_14", {
description = S("%s Microblock"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":micro_" .. drop .. "_14",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_14"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":micro_" .. subname .. "_15", {
description = S("%s Microblock"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":micro_" .. drop .. "_15",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_15"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0, 0.4375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
}
}
local desc = S("%s Microblock"):format(fields.description)
for alternate, def in pairs(defs) do
def.drawtype = "nodebox"
def.paramtype = "light"
def.paramtype2 = "facedir"
def.on_place = minetest.rotate_node
for k, v in pairs(fields) do
def[k] = v
end
def.description = desc
if fields.drop then
def.drop = modname..":micro_"..fields.drop..alternate
end
minetest.register_node(":"..modname..":micro_"..subname..alternate, def)
end
minetest.register_alias(modname..":micro_"..subname.."_bottom", modname..":micro_"..subname)
end

View File

@ -1,135 +1,87 @@
-- Load translation library if intllib is installed
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
if intllib then
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
else
S = function(s) return s end
end
-- Node will be called <modname>panel_<subname>
-- Node will be called <modname>:panel_<subname>
function register_panel(modname, subname, recipeitem, groups, images, description, drop, light)
minetest.register_node(":" .. modname .. ":panel_" .. subname, {
description = S("%s Panel"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":panel_" .. drop,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
return stairsplus:register_panel(modname, subname, recipeitem, {
groups = groups,
tiles = images,
description = description,
drop = drop,
light_source = light,
sounds = default.node_sound_stone_defaults(),
})
end
function stairsplus:register_panel(modname, subname, recipeitem, fields)
local defs = {
[""] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0, 0.5},
},
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_1", {
description = S("%s Panel"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":panel_" .. drop .. "_1",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_1"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.4375, 0.5},
},
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_2", {
description = S("%s Panel"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":panel_" .. drop .. "_2",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_2"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.375, 0.5},
},
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_4", {
description = S("%s Panel"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":panel_" .. drop .. "_4",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_4"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, -0.25, 0.5},
},
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_12", {
description = S("%s Panel"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":panel_" .. drop .. "_12",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_12"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.25, 0.5},
},
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_14", {
description = S("%s Panel"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":panel_" .. drop .. "_14",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_14"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.375, 0.5},
},
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":panel_" .. subname .. "_15", {
description = S("%s Panel"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":panel_" .. drop .. "_15",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_15"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, 0, 0.5, 0.4375, 0.5},
},
on_place = stairsplus_rotate_and_place
})
}
}
local desc = S("%s Panel"):format(fields.description)
for alternate, def in pairs(defs) do
def.drawtype = "nodebox"
def.paramtype = "light"
def.paramtype2 = "facedir"
def.on_place = minetest.rotate_node
for k, v in pairs(fields) do
def[k] = v
end
def.description = desc
if fields.drop then
def.drop = modname..":panel_"..fields.drop..alternate
end
minetest.register_node(":"..modname..":panel_"..subname..alternate, def)
end
minetest.register_alias(modname..":panel_"..subname.."_bottom", modname..":panel_"..subname)
end

View File

@ -0,0 +1,45 @@
-- Default stairs/slabs/panels/microblocks
local default_nodes = {
"stone",
"cobble",
"mossycobble",
"brick",
"sandstone",
"steelblock",
"goldblock",
"copperblock",
"bronzeblock",
"diamondblock",
"desert_stone",
"glass",
"tree",
"wood",
"jungletree",
"junglewood",
"obsidian",
"obsidian_glass",
"stonebrick",
"desert_stonebrick",
"sandstonebrick",
}
for _, name in pairs(default_nodes) do
local nodename = "default:"..name
local ndef = minetest.registered_nodes[nodename]
local groups = {}
for k, v in pairs(ndef.groups) do groups[k] = v end
local drop
if type(ndef.drop) == "string" then
drop = ndef.drop:sub(9)
end
stairsplus:register_all("moreblocks", name, nodename, {
description = ndef.description,
drop = drop,
groups = groups,
sounds = ndef.sounds,
tiles = ndef.tiles,
sunlight_propagates = ndef.sunlight_propagates,
})
end

View File

@ -1,170 +1,96 @@
-- Load translation library if intllib is installed
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
if intllib then
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
else
S = function(s) return s end
end
-- Node will be called <modname>slab_<subname>
-- Node will be called <modname>:slab_<subname>
function register_slab(modname, subname, recipeitem, groups, images, description, drop, light)
minetest.register_node(":" .. modname .. ":slab_" .. subname, {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":slab_" .. drop,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
return stairsplus:register_slab(modname, subname, recipeitem, {
groups = groups,
tiles = images,
description = description,
drop = drop,
light_source = light,
sounds = default.node_sound_stone_defaults(),
})
end
function stairsplus:register_slab(modname, subname, recipeitem, fields)
local defs = {
[""] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":stairs:slab_" .. subname, {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
drop = modname .. ":slab_" .. drop,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":slab_" .. subname .. "_quarter", {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":slab_" .. drop .. "_quarter",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
["_quarter"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":slab_" .. subname .. "_three_quarter", {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":slab_" .. drop .. "_three_quarter",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_three_quarter"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.25, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":slab_" .. subname .. "_1", {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":slab_" .. drop .. "_1",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_1"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":slab_" .. subname .. "_2", {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":slab_" .. drop .. "_2",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_2"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -0.375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":slab_" .. subname .. "_14", {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":slab_" .. drop .. "_14",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_14"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":slab_" .. subname .. "_15", {
description = S("%s Slab"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":slab_" .. drop .. "_15",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_15"] = {
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.4375, 0.5},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
},
}
local desc = S("%s Slab"):format(fields.description)
for alternate, def in pairs(defs) do
def.drawtype = "nodebox"
def.paramtype = "light"
def.paramtype2 = "facedir"
def.on_place = minetest.rotate_node
for k, v in pairs(fields) do
def[k] = v
end
def.description = desc
if fields.drop then
def.drop = modname..":slab_"..fields.drop..alternate
end
minetest.register_node(":"..modname..":slab_"..subname..alternate, def)
end
minetest.register_alias("stairs:slab_"..subname, modname..":slab_"..subname)
-- Unregister default recipes, optional, see _config.txt
-- Unregister default recipes, optional, see config.lua
if allow_stair_slab_crafting == false
then
if not moreblocks.config.allow_stair_slab_crafting then
minetest.register_craft({
output = "moreblocks:nothing 1",
recipe = {
{recipeitem, recipeitem, recipeitem},
},
})
end
end
end

View File

@ -1,26 +1,28 @@
-- Load translation library if intllib is installed
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
if intllib then
S = intllib.Getter(minetest.get_current_modname())
else
S = function ( s ) return s end
else
S = function(s) return s end
end
-- Node will be called <modname>:stair_<subname>
function register_stair(modname, subname, recipeitem, groups, images, description, drop, light)
minetest.register_node(":" .. modname .. ":stair_" .. subname, {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
return stairsplus:register_stair(modname, subname, recipeitem, {
groups = groups,
tiles = images,
description = description,
drop = drop,
light_source = light,
sounds = default.node_sound_stone_defaults(),
})
end
function stairsplus:register_stair(modname, subname, recipeitem, fields)
local defs = {
[""] = {
node_box = {
type = "fixed",
fixed = {
@ -28,38 +30,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":stairs:stair_" .. subname, {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky=3, not_in_creative_inventory=1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_half", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
["_half"] = {
node_box = {
type = "fixed",
fixed = {
@ -67,19 +39,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0, 0, 0, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":stair_" .. subname .. "_right_half", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_right_half" ]= {
node_box = {
type = "fixed",
fixed = {
@ -87,20 +48,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{0, 0, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":stair_" .. subname .. "_inner", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":stair_" .. drop .. "_inner",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_inner"] = {
node_box = {
type = "fixed",
fixed = {
@ -109,20 +58,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0, -0.5, 0, 0.5, 0},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":"..modname .. ":stair_" .. subname .. "_outer", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
drop = modname .. ":stair_" .. drop .. "_outer",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_outer"] = {
node_box = {
type = "fixed",
fixed = {
@ -130,19 +67,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0, 0, 0, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_alt"] = {
node_box = {
type = "fixed",
fixed = {
@ -150,19 +76,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt_1", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_alt_1"] = {
node_box = {
type = "fixed",
fixed = {
@ -170,19 +85,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0.4375, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt_2", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_alt_2"] = {
node_box = {
type = "fixed",
fixed = {
@ -190,19 +94,8 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0.375, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
minetest.register_node(":" .. modname .. ":stair_" .. subname .. "_alt_4", {
description = S("%s Stairs"):format(S(description)),
drawtype = "nodebox",
tiles = images,
light_source = light,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = groups,
},
["_alt_4"] = {
node_box = {
type = "fixed",
fixed = {
@ -210,14 +103,30 @@ function register_stair(modname, subname, recipeitem, groups, images, descriptio
{-0.5, 0.25, 0, 0.5, 0.5, 0.5},
},
},
sounds = default.node_sound_stone_defaults(),
on_place = stairsplus_rotate_and_place
})
},
}
-- Unregister default recipes, optional, see _config.txt
local desc = S("%s Stairs"):format(fields.description)
for alternate, def in pairs(defs) do
def.drawtype = "nodebox"
def.paramtype = "light"
def.paramtype2 = "facedir"
def.on_place = minetest.rotate_node
for k, v in pairs(fields) do
def[k] = v
end
def.description = desc
if fields.drop then
def.drop = modname..":stair_"..fields.drop..alternate
end
minetest.register_node(":"..modname..":stair_"..subname..alternate, def)
end
minetest.register_alias(":stairs:stair_"..subname, modname..":stair_"..subname)
if allow_stair_slab_crafting == false
then
-- Unregister default recipes, optional, see config.lua
if not moreblocks.config.allow_stair_slab_crafting then
minetest.register_craft({
output = "moreblocks:nothing 1",
recipe = {
@ -235,6 +144,6 @@ then
{recipeitem, recipeitem, recipeitem},
},
})
end
end
end