Merge pull request #14 from kosc/master

Add hatches
This commit is contained in:
Oleg Matveev 2013-06-25 05:48:26 -07:00
commit 300d96784f
34 changed files with 153 additions and 2 deletions

View File

@ -1,3 +1,4 @@
default default
metals metals
instruments instruments
hatches

View File

@ -26,7 +26,7 @@ function realtest.register_anvil_recipe(RecipeDef)
end end
end end
--Unshaped metals, buckets, double ingots, sheets, hammers and locks --Unshaped metals, buckets, double ingots, sheets, hammers, locks and hatches
for i, metal in ipairs(metals.list) do for i, metal in ipairs(metals.list) do
realtest.register_anvil_recipe({ realtest.register_anvil_recipe({
item1 = "metals:"..metal.."_unshaped", item1 = "metals:"..metal.."_unshaped",
@ -77,6 +77,13 @@ for i, metal in ipairs(metals.list) do
output = "metals:"..metal.."_lock", output = "metals:"..metal.."_lock",
level = metals.levels[i] level = metals.levels[i]
}) })
realtest.register_anvil_recipe({
item1 = "metals:"..metal.."_ingot",
item2 = "scribing_table:plan_hatch",
rmitem2 = false,
output = "hatches:"..metal.."_hatch_closed",
level = metals.levels[i]
})
realtest.register_anvil_recipe({ realtest.register_anvil_recipe({
item1 = "minerals:borax", item1 = "minerals:borax",
output = "minerals:flux 8" output = "minerals:flux 8"

4
mods/hatches/depends.txt Executable file
View File

@ -0,0 +1,4 @@
default
metals
trees
joiner_table

130
mods/hatches/init.lua Executable file
View File

@ -0,0 +1,130 @@
hatches = {}
function hatches.register_hatch(name, desc, is_wooden)
local on_hatch_clicked = function(pos, node, puncher, itemstack)
if node.name == "hatches:"..name.."_hatch_opened_top" then
minetest.env:add_node(pos, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2})
elseif (node.name == "hatches:"..name.."_hatch_opened_bottom") and
(minetest.env:get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air") then
minetest.env:add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2})
minetest.env:remove_node(pos)
elseif node.name == "hatches:"..name.."_hatch_closed" then
if (minetest.env:get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "air") and (puncher:getpos().y + 1 >= pos.y) then
minetest.env:add_node({x = pos.x, y = pos.y - 1, z = pos.z}, {name = "hatches:"..name.."_hatch_opened_bottom",
param2 = node.param2})
minetest.env:remove_node(pos)
else
minetest.env:add_node(pos, {name = "hatches:"..name.."_hatch_opened_top", param2 = node.param2})
end
end
end
minetest.register_node("hatches:"..name.."_hatch_opened_top", {
drawtype = "nodebox",
tile_images = {"hatches_"..name.."_hatch.png"},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
climbable = true,
groups = {choppy=2, dig_immediate=2},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.3, 0.3, -0.4},
{-0.5, 0.3, -0.5, 0.3, 0.5, -0.4},
{0.3, -0.3, -0.5, 0.5, 0.5, -0.4},
{0.5, -0.5, -0.5, -0.3, -0.3, -0.4},
{-0.075, -0.3, -0.5, 0.075, 0.3, -0.4},
{-0.3, -0.075, -0.5, -0.075, 0.075, -0.4},
{0.075, -0.075, -0.5, 0.3, 0.075, -0.4},
},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, -0.4},
},
drop = "hatches:"..name.."_hatch_closed",
on_rightclick = function(pos, node, clicker, itemstack)
on_hatch_clicked(pos, node, clicker, itemstack)
end
})
minetest.register_node("hatches:"..name.."_hatch_closed", {
description = desc.." Hatch",
drawtype = "nodebox",
tile_images = {"hatches_"..name.."_hatch.png"},
inventory_image = "hatches_"..name.."_hatch.png",
wield_image = "hatches_"..name.."_hatch.png",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
groups = {choppy=2, dig_immediate=2},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.55, -0.5, -0.3, -0.45, 0.3},
{-0.5, -0.55, 0.3, 0.3, -0.45, 0.5},
{0.3, -0.55, -0.3, 0.5, -0.45, 0.5},
{0.5, -0.55, -0.5, -0.3, -0.45, -0.3},
{-0.075, -0.55, -0.3, 0.075, -0.45, 0.3},
{-0.3, -0.55, -0.075, -0.075, -0.45, 0.075},
{0.075, -0.55, -0.075, 0.3, -0.45, 0.075},
},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.55, -0.5, 0.5, -0.45, 0.5},
},
on_rightclick = function(pos, node, clicker, itemstack)
on_hatch_clicked(pos, node, clicker, itemstack)
end
})
minetest.register_node("hatches:"..name.."_hatch_opened_bottom", {
drawtype = "nodebox",
tile_images = {"hatches_"..name.."_hatch.png"},
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = true,
climbable = true,
groups = {choppy=2, dig_immediate=2},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.3, 0.3, -0.4},
{-0.5, 0.3, -0.5, 0.3, 0.5, -0.4},
{0.3, -0.3, -0.5, 0.5, 0.5, -0.4},
{0.5, -0.5, -0.5, -0.3, -0.3, -0.4},
{-0.075, -0.3, -0.5, 0.075, 0.3, -0.4},
{-0.3, -0.075, -0.5, -0.075, 0.075, -0.4},
{0.075, -0.075, -0.5, 0.3, 0.075, -0.4},
},
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, -0.4},
},
drop = "hatches:"..name.."_hatch_closed",
on_rightclick = function(pos, node, clicker, itemstack)
on_hatch_clicked(pos, node, clicker, itemstack)
end
})
if is_wooden then
realtest.register_joiner_table_recipe({
item1 = "trees:"..name.."_planks",
output = "hatches:"..name.."_hatch_closed 2"
})
end
end
for i, metal_name in ipairs(metals.list) do
hatches.register_hatch(metal_name, metals.desc_list[i], false)
end
for i, tree_name in ipairs(realtest.registered_trees_list) do
local tree_desc = realtest.registered_trees[tree_name].description
hatches.register_hatch(tree_name:remove_modname_prefix(), tree_desc, true)
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

View File

@ -117,6 +117,15 @@ realtest.register_instrument_plan("scribing_table:stonebricks", {
1,1,1,1,1,} 1,1,1,1,1,}
}) })
realtest.register_instrument_plan("scribing_table:plan_hatch", {
description = "Hatch Plan",
bitmap = {1,1,1,1,1,
1,0,1,0,1,
1,1,1,1,1,
1,0,1,0,1,
1,1,1,1,1,}
})
local function check_recipe(pos) local function check_recipe(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()