Code cleanup, new Stairs+ recipes.

This commit is contained in:
Calinou 2014-07-21 12:24:49 +02:00
parent 28741bf242
commit f7916005c2
11 changed files with 136 additions and 98 deletions

View File

@ -17,8 +17,8 @@ minetest.register_alias("moreblocks:junglewood", "default:junglewood")
minetest.register_alias("moreblocks:jungle_wood", "default:junglewood") minetest.register_alias("moreblocks:jungle_wood", "default:junglewood")
for _, t in pairs(circular_saw.names) do for _, t in pairs(circular_saw.names) do
minetest.register_alias("moreblocks:"..t[1].."_jungle_wood"..t[2], minetest.register_alias("moreblocks:" ..t[1].. "_jungle_wood" ..t[2],
"moreblocks:"..t[1].."_junglewood"..t[2]) "moreblocks:" ..t[1].. "_junglewood" ..t[2])
end end
minetest.register_alias("moreblocks:horizontaltree", "moreblocks:horizontal_tree") minetest.register_alias("moreblocks:horizontaltree", "moreblocks:horizontal_tree")
minetest.register_alias("moreblocks:horizontaljungletree", "moreblocks:horizontal_jungle_tree") minetest.register_alias("moreblocks:horizontaljungletree", "moreblocks:horizontal_jungle_tree")

View File

@ -5,7 +5,7 @@ circular_saw.known_stairs = setmetatable({}, {
__newindex = function(k, v) __newindex = function(k, v)
local modname = minetest.get_current_modname() local modname = minetest.get_current_modname()
print(("WARNING: mod %s tried to add node %s to the circular saw" print(("WARNING: mod %s tried to add node %s to the circular saw"
.." manually."):format(modname, v)) .. " manually."):format(modname, v))
end, end,
}) })
@ -127,7 +127,7 @@ function circular_saw:update_inventory(pos, amount)
local material = name_parts[2] local material = name_parts[2]
inv:set_list("input", { -- Display as many full blocks as possible: inv:set_list("input", { -- Display as many full blocks as possible:
node_name.." ".. math.floor(amount / 8) node_name.. " " .. math.floor(amount / 8)
}) })
-- The stairnodes made of default nodes use moreblocks namespace, other mods keep own: -- The stairnodes made of default nodes use moreblocks namespace, other mods keep own:
@ -269,16 +269,16 @@ gui_slots = "listcolors[#606060AA;#808080;#101010;#202020;#FFF]"
function circular_saw.on_construct(pos) function circular_saw.on_construct(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[11,9]"..gui_slots.. meta:set_string("formspec", "size[11,9]" ..gui_slots..
"label[0,0;"..S("Input\nmaterial").."]".. "label[0,0;" ..S("Input\nmaterial").. "]" ..
"list[current_name;input;1.5,0;1,1;]".. "list[current_name;input;1.5,0;1,1;]" ..
"label[0,1;"..S("Left-over").."]".. "label[0,1;" ..S("Left-over").. "]" ..
"list[current_name;micro;1.5,1;1,1;]".. "list[current_name;micro;1.5,1;1,1;]" ..
"label[0,2;"..S("Recycle\noutput").."]".. "label[0,2;" ..S("Recycle\noutput").. "]" ..
"list[current_name;recycle;1.5,2;1,1;]".. "list[current_name;recycle;1.5,2;1,1;]" ..
"field[0.3,3.5;1,1;max_offered;"..S("Max")..":;${max_offered}]".. "field[0.3,3.5;1,1;max_offered;" ..S("Max").. ":;${max_offered}]" ..
"button[1,3.2;1,1;Set;"..S("Set").."]".. "button[1,3.2;1,1;Set;" ..S("Set").. "]" ..
"list[current_name;output;2.8,0;8,4;]".. "list[current_name;output;2.8,0;8,4;]" ..
"list[current_player;main;1.5,5;8,4;]") "list[current_player;main;1.5,5;8,4;]")
meta:set_int("anz", 0) -- No microblocks inside yet. meta:set_int("anz", 0) -- No microblocks inside yet.

View File

@ -6,8 +6,8 @@ local sound_glass = default.node_sound_glass_defaults()
local sound_leaves = default.node_sound_leaves_defaults() local sound_leaves = default.node_sound_leaves_defaults()
local function tile_tiles(name) local function tile_tiles(name)
local tex = "moreblocks_"..name..".png" local tex = "moreblocks_" ..name.. ".png"
return {tex, tex, tex, tex, tex.."^[transformR90", tex.."^[transformR90"} return {tex, tex, tex, tex, tex.. "^[transformR90", tex.. "^[transformR90"}
end end
local nodes = { local nodes = {
@ -306,13 +306,13 @@ local nodes = {
} }
for name, def in pairs(nodes) do for name, def in pairs(nodes) do
def.tiles = def.tiles or {"moreblocks_"..name..".png"} def.tiles = def.tiles or {"moreblocks_" ..name.. ".png"}
minetest.register_node("moreblocks:"..name, def) minetest.register_node("moreblocks:" ..name, def)
minetest.register_alias(name, "moreblocks:"..name) minetest.register_alias(name, "moreblocks:" ..name)
if not def.no_stairs then if not def.no_stairs then
local groups = {} local groups = {}
for k, v in pairs(def.groups) do groups[k] = v end for k, v in pairs(def.groups) do groups[k] = v end
stairsplus:register_all("moreblocks", name, "moreblocks:"..name, { stairsplus:register_all("moreblocks", name, "moreblocks:" ..name, {
description = def.description, description = def.description,
groups = groups, groups = groups,
tiles = def.tiles, tiles = def.tiles,

View File

@ -94,7 +94,7 @@ minetest.override_item("default:grass_1", {
}) })
for i = 2, 5 do for i = 2, 5 do
minetest.override_item("default:grass_"..i, { minetest.override_item("default:grass_" ..i, {
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
}) })

View File

@ -1,34 +1,34 @@
local function register_stairsplus_alias(modname, origname, newname) local function register_stairsplus_alias(modname, origname, newname)
minetest.register_alias(modname..":slab_"..origname, "moreblocks:slab_"..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.. "_inverted", "moreblocks:slab_" ..newname.. "_inverted")
minetest.register_alias(modname..":slab_"..origname.."_wall", "moreblocks:slab_"..newname.."_wall") 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", "moreblocks:slab_" ..newname.. "_quarter")
minetest.register_alias(modname..":slab_"..origname.."_quarter_inverted", "moreblocks:slab_"..newname.."_quarter_inverted") 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.. "_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", "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_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.. ":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, "moreblocks:stair_" ..newname)
minetest.register_alias(modname..":stair_"..origname.."_inverted", "moreblocks:stair_"..newname.."_inverted") 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", "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", "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.. "_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", "moreblocks:stair_" ..newname.. "_half")
minetest.register_alias(modname..":stair_"..origname.."_half_inverted", "moreblocks:stair_"..newname.."_half_inverted") 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", "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.. "_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", "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.. "_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", "moreblocks:stair_" ..newname.. "_inner")
minetest.register_alias(modname..":stair_"..origname.."_inner_inverted", "moreblocks:stair_"..newname.."_inner_inverted") 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", "moreblocks:stair_" ..newname.. "_outer")
minetest.register_alias(modname..":stair_"..origname.."_outer_inverted", "moreblocks:stair_"..newname.."_outer_inverted") 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.. "_bottom", "moreblocks:panel_" ..newname.. "_bottom")
minetest.register_alias(modname..":panel_"..origname.."_top", "moreblocks:panel_"..newname.."_top") 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.. ":panel_" ..origname.. "_vertical", "moreblocks:panel_" ..newname.. "_vertical")
minetest.register_alias(modname..":micro_"..origname.."_bottom", "moreblocks:micro_"..newname.."_bottom") minetest.register_alias(modname.. ":micro_" ..origname.. "_bottom", "moreblocks:micro_" ..newname.. "_bottom")
minetest.register_alias(modname..":micro_"..origname.."_top", "moreblocks:micro_"..newname.."_top") minetest.register_alias(modname.. ":micro_" ..origname.. "_top", "moreblocks:micro_" ..newname.. "_top")
end end
register_stairsplus_alias("stairsplus", "stone", "stone") register_stairsplus_alias("stairsplus", "stone", "stone")

View File

@ -10,26 +10,26 @@ function stairsplus:register_6dfacedir_conversion(modname, material)
--print('ABM for '..modname..' "'..material..'"') --print('ABM for '..modname..' "'..material..'"')
local objects_list1 = { local objects_list1 = {
modname..":slab_"..material.."_inverted", modname.. ":slab_" ..material.. "_inverted",
modname..":slab_"..material.."_quarter_inverted", modname.. ":slab_" ..material.. "_quarter_inverted",
modname..":slab_"..material.."_three_quarter_inverted", modname.. ":slab_" ..material.. "_three_quarter_inverted",
modname..":stair_"..material.."_inverted", modname.. ":stair_" ..material.. "_inverted",
modname..":stair_"..material.."_wall", modname.. ":stair_" ..material.. "_wall",
modname..":stair_"..material.."_wall_half", modname.. ":stair_" ..material.. "_wall_half",
modname..":stair_"..material.."_wall_half_inverted", modname.. ":stair_" ..material.. "_wall_half_inverted",
modname..":stair_"..material.."_half_inverted", modname.. ":stair_" ..material.. "_half_inverted",
modname..":stair_"..material.."_right_half_inverted", modname.. ":stair_" ..material.. "_right_half_inverted",
modname..":panel_"..material.."_vertical", modname.. ":panel_" ..material.. "_vertical",
modname..":panel_"..material.."_top", modname.. ":panel_" ..material.. "_top",
} }
local objects_list2 = { local objects_list2 = {
modname..":slab_"..material.."_wall", modname.. ":slab_" ..material.. "_wall",
modname..":slab_"..material.."_quarter_wall", modname.. ":slab_" ..material.. "_quarter_wall",
modname..":slab_"..material.."_three_quarter_wall", modname.. ":slab_" ..material.. "_three_quarter_wall",
modname..":stair_"..material.."_inner_inverted", modname.. ":stair_" ..material.. "_inner_inverted",
modname..":stair_"..material.."_outer_inverted", modname.. ":stair_" ..material.. "_outer_inverted",
modname..":micro_"..material.."_top" modname.. ":micro_" ..material.. "_top"
} }
for _, object in pairs(objects_list1) do for _, object in pairs(objects_list1) do
@ -64,8 +64,8 @@ function stairsplus:register_6dfacedir_conversion(modname, material)
dest_object = string.gsub(dest_object, "_right_half", "_half") dest_object = string.gsub(dest_object, "_right_half", "_half")
end end
--print(" +---> convert "..object) --print(" +---> convert " ..object)
--print(" | to "..dest_object) --print(" | to " ..dest_object)
minetest.register_abm({ minetest.register_abm({
nodenames = {object}, nodenames = {object},
@ -107,8 +107,8 @@ function stairsplus:register_6dfacedir_conversion(modname, material)
dest_object = string.gsub(dest_object, "_wall", "") dest_object = string.gsub(dest_object, "_wall", "")
end end
--print(" +---> convert "..object) --print(" +---> convert " ..object)
--print(" | to "..dest_object) --print(" | to " ..dest_object)
minetest.register_abm({ minetest.register_abm({
nodenames = {object}, nodenames = {object},

View File

@ -1,6 +1,6 @@
-- Nodes will be called <modname>:{stair,slab,panel,micro}_<subname> -- Nodes will be called <modname>:{stair,slab,panel,micro}_<subname>
local modpath = minetest.get_modpath("moreblocks").."/stairsplus" local modpath = minetest.get_modpath("moreblocks").. "/stairsplus"
stairsplus = {} stairsplus = {}
stairsplus.expect_infinite_stacks = false stairsplus.expect_infinite_stacks = false
@ -34,10 +34,10 @@ function register_stair_slab_panel_micro(modname, subname, recipeitem, groups, i
}) })
end end
-- dofile(modpath.."/aliases.lua") -- Not needed as of Q2 2013, uncomment to fix old maps. -- dofile(modpath.. "/aliases.lua") -- Not needed as of Q2 2013, uncomment to fix old maps.
-- dofile(modpath.."/conversion.lua") -- Not needed as of Q2 2013, uncomment to fix old maps. -- dofile(modpath.. "/conversion.lua") -- Not needed as of Q2 2013, uncomment to fix old maps.
dofile(modpath.."/stairs.lua") dofile(modpath.. "/stairs.lua")
dofile(modpath.."/slabs.lua") dofile(modpath.. "/slabs.lua")
dofile(modpath.."/panels.lua") dofile(modpath.. "/panels.lua")
dofile(modpath.."/microblocks.lua") dofile(modpath.. "/microblocks.lua")
dofile(modpath.."/registrations.lua") dofile(modpath.. "/registrations.lua")

View File

@ -75,28 +75,43 @@ function stairsplus:register_micro(modname, subname, recipeitem, fields)
end end
def.description = desc def.description = desc
if fields.drop then if fields.drop then
def.drop = modname..":micro_"..fields.drop..alternate def.drop = modname.. ":micro_" ..fields.drop..alternate
end end
minetest.register_node(":"..modname..":micro_"..subname..alternate, def) minetest.register_node(":" ..modname.. ":micro_" ..subname..alternate, def)
end end
minetest.register_alias(modname..":micro_"..subname.."_bottom", modname..":micro_"..subname) minetest.register_alias(modname.. ":micro_" ..subname.. "_bottom", modname.. ":micro_" ..subname)
-- Some saw-less recipes: -- Some saw-less recipes:
minetest.register_craft({
type = "shapeless",
output = "moreblocks:micro_" .. subname .. " 7",
recipe = {"moreblocks:stair_" .. subname .. "_inner"},
})
minetest.register_craft({ minetest.register_craft({
output = "moreblocks:micro_" .. subname .. " 6", output = "moreblocks:micro_" .. subname .. " 6",
recipe = {{"moreblocks:stair_" .. subname}}, type = "shapeless",
recipe = {"moreblocks:stair_" .. subname},
}) })
minetest.register_craft({ minetest.register_craft({
output = "moreblocks:micro_" .. subname .. " 4", type = "shapeless",
recipe = {{"moreblocks:slab_" .. subname}}, output = "moreblocks:micro_" .. subname .. " 5",
recipe = {"moreblocks:stair_" .. subname .. "_outer"},
}) })
minetest.register_craft({ minetest.register_craft({
output = "moreblocks:micro_" .. subname .. " 2", type = "shapeless",
recipe = {{"moreblocks:panel_" .. subname}}, output = "moreblocks:micro_" .. subname .. " 4",
recipe = {"moreblocks:slab_" .. subname},
})
minetest.register_craft({
type = "shapeless",
output = "moreblocks:micro_" .. subname .. " 2",
recipe = {"moreblocks:panel_" .. subname},
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -75,11 +75,11 @@ function stairsplus:register_panel(modname, subname, recipeitem, fields)
end end
def.description = desc def.description = desc
if fields.drop then if fields.drop then
def.drop = modname..":panel_"..fields.drop..alternate def.drop = modname.. ":panel_" ..fields.drop..alternate
end end
minetest.register_node(":"..modname..":panel_"..subname..alternate, def) minetest.register_node(":" ..modname.. ":panel_" ..subname..alternate, def)
end end
minetest.register_alias(modname..":panel_"..subname.."_bottom", modname..":panel_"..subname) minetest.register_alias(modname.. ":panel_" ..subname.. "_bottom", modname.. ":panel_" ..subname)
-- Some saw-less recipes: -- Some saw-less recipes:

View File

@ -74,11 +74,11 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
end end
def.description = desc def.description = desc
if fields.drop then if fields.drop then
def.drop = modname..":slab_"..fields.drop..alternate def.drop = modname.. ":slab_" ..fields.drop..alternate
end end
minetest.register_node(":"..modname..":slab_"..subname..alternate, def) minetest.register_node(":" ..modname.. ":slab_" ..subname..alternate, def)
end end
minetest.register_alias("stairs:slab_"..subname, modname..":slab_"..subname) minetest.register_alias("stairs:slab_" ..subname, modname.. ":slab_" ..subname)
-- Some saw-less recipes: -- Some saw-less recipes:
@ -94,9 +94,16 @@ function stairsplus:register_slab(modname, subname, recipeitem, fields)
}) })
minetest.register_craft({ minetest.register_craft({
type = "shapeless",
output = "moreblocks:slab_" .. subname, output = "moreblocks:slab_" .. subname,
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname}, recipe = {{"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname}},
})
minetest.register_craft({
output = "moreblocks:slab_" .. subname,
recipe = {
{"moreblocks:panel_" .. subname},
{"moreblocks:panel_" .. subname},
},
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -115,11 +115,11 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields)
end end
def.description = desc def.description = desc
if fields.drop then if fields.drop then
def.drop = modname..":stair_"..fields.drop..alternate def.drop = modname.. ":stair_" ..fields.drop..alternate
end end
minetest.register_node(":"..modname..":stair_"..subname..alternate, def) minetest.register_node(":" ..modname.. ":stair_" ..subname..alternate, def)
end end
minetest.register_alias(":stairs:stair_"..subname, modname..":stair_"..subname) minetest.register_alias(":stairs:stair_" ..subname, modname.. ":stair_" ..subname)
-- Some saw-less recipes: -- Some saw-less recipes:
@ -206,4 +206,20 @@ function stairsplus:register_stair(modname, subname, recipeitem, fields)
output = "moreblocks:stair_" .. subname, output = "moreblocks:stair_" .. subname,
recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname}, recipe = {"moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname, "moreblocks:panel_" .. subname},
}) })
minetest.register_craft({ -- See mirrored variation of the recipe below.
output = "moreblocks:stair_" .. subname .. "_alt",
recipe = {
{"moreblocks:panel_" .. subname, ""},
{"" , "moreblocks:panel_" .. subname},
},
})
minetest.register_craft({ -- Mirrored variation of the recipe above.
output = "moreblocks:stair_" .. subname .. "_alt",
recipe = {
{"" , "moreblocks:panel_" .. subname},
{"moreblocks:panel_" .. subname, ""},
},
})
end end