sapier wrote:Great mod! Thanks!
There's a small bug in it, when digging a placed hatch there seem to be two different types of hatch.
At least I've gotten two stacks that havent been combinable.
Jeija wrote:Nice mod! May I use it for my mesecon mod, so that hatches can be controlled by mesecons?
hurufu wrote:Great!
Could you put the texture to the upper side of block? So when you are walking on it, there were no empty space between you and visible texture.
Calinou wrote:Small request: When hatch is open, it has no collision (not walkable). When closed, it is climbable. It feels much better IMO :)
-- Local constants
-- This _has_ to be set to 2
local HATCH_OPENED = 2
-- This has to be != from HATCH_OPENED and is coded on 4 bits
local HATCH_CLOSED = 1
-- Local Functions
local on_hatch_punched = function(pos, node, puncher)
if (node.name ~= 'hatches:hatch_closed')
and (node.name ~= 'hatches:hatch_opened') then
return
end
local state = node.param2
-- Switch the hatch state when hit
if state == HATCH_OPENED then
node.name = 'hatches:hatch_closed'
node.param2 = HATCH_CLOSED
elseif state == HATCH_CLOSED then
node.name = 'hatches:hatch_opened'
node.param2 = HATCH_OPENED
else
print('Uninitialized node: ' .. state)
end
minetest.env:add_node(pos, {
name = node.name,
param2 = node.param2,
})
end
local on_hatch_placed = function(pos, node, placer)
if node.name ~= 'hatches:hatch_opened' then
return
end
minetest.env:add_node(pos, {
name = node.name,
param2 = HATCH_OPENED,
})
end
-- Nodes
-- As long as param2 is set to 1 for open hatches, it doesn't matter to
-- use drawtype = 'signlike'
minetest.register_node('hatches:hatch_opened', {
drawtype = 'signlike',
tile_images = {'hatch.png'},
inventory_image = 'hatch.png',
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = "wallmounted",
legacy_wallmounted = true,
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
},
material = minetest.digprop_constanttime(1.0),
drop = 'hatches:hatch_closed',
})
minetest.register_node('hatches:hatch_closed', {
description = "Hatch",
drawtype = 'raillike',
tile_images = {'hatch.png'},
inventory_image = 'hatch.png',
wield_image = "hatch.png",
paramtype = 'light',
walkable = true,
selection_box = {
type = "fixed",
fixed = {-1/2, -1/2, -1/2, 1/2, -2/5, 1/2},
},
material = minetest.digprop_constanttime(1.0),
})
-- Crafts
minetest.register_craft({
output = '"hatches:hatch_closed" 2',
recipe = {
{'"default:wood" 1', '"default:wood" 1', '"default:wood" 1'},
{'"default:wood" 1', '"default:wood" 1', '"default:wood" 1'},
},
})
-- Change the hatch state
minetest.register_on_punchnode(on_hatch_punched)
-- Reset param2 for open hatches
minetest.register_on_placenode(on_hatch_placed)
-- Mesecon Stuff:
mesecon:register_on_signal_on(on_hatch_punched)
mesecon:register_on_signal_off(on_hatch_punched)
cisoun wrote:Just a question: how can I remove then?
cisoun wrote:I just noticed that. \o/
Another bug: the hatch doesn't rotate like in the first picture. It just goes up and down. Is that normal?
neko259 wrote:cisoun wrote:I just noticed that. \o/
Another bug: the hatch doesn't rotate like in the first picture. It just goes up and down. Is that normal?
++
And if I try to dig it (and it's really hard), I can get opened hatch instead of normal (they don't stack together).
MilanFIN wrote:Will this work on the 0.4.dev-20120122-1 version?
-- Local constants
-- This _has_ to be set to 2
local HATCH_OPENED = 2
-- This has to be != from HATCH_OPENED and is coded on 4 bits
local HATCH_CLOSED = 1
-- Local Functions
local on_hatch_punched = function(pos, node, puncher)
if (node.name ~= 'hatches:hatch_closed')
and (node.name ~= 'hatches:hatch_opened') then
return
end
local state = node.param2
-- Switch the hatch state when hit
if state == HATCH_OPENED then
node.name = 'hatches:hatch_closed'
node.param2 = HATCH_CLOSED
else
node.name = 'hatches:hatch_opened'
node.param2 = HATCH_OPENED
end
minetest.env:add_node(pos, {
name = node.name,
param2 = node.param2,
})
end
-- Nodes
-- As long as param2 is set to 1 for open hatches, it doesn't matter to
-- use drawtype = 'signlike'
minetest.register_node('hatches:hatch_opened', {
drawtype = 'signlike',
tile_images = {'hatch.png'},
inventory_image = 'hatch.png',
sunlight_propagates = true,
paramtype = 'light',
paramtype2 = "wallmounted",
legacy_wallmounted = true,
walkable = false,
climbable = true,
selection_box = {
type = "wallmounted",
},
drop = 'hatches:hatch_closed',
on_punch = on_hatch_punched,
groups = { choppy=2, dig_immediate=2 },
})
minetest.register_node('hatches:hatch_closed', {
description = "Hatch",
drawtype = 'nodebox',
tile_images = {'hatch.png'},
inventory_image = 'hatch.png',
wield_image = "hatch.png",
paramtype = 'light',
is_ground_content = true,
walkable = true,
node_box = {
type = "fixed",
fixed = {-1/2, 2/5, -1/2, 1/2, 1/2, 1/2},
},
selection_box = {
type = "fixed",
fixed = {-1/2, 2/5, -1/2, 1/2, 1/2, 1/2},
},
on_punch = on_hatch_punched,
groups = { choppy=2, dig_immediate=2 },
})
-- Crafts
minetest.register_craft({
output = 'hatches:hatch_closed 2',
recipe = {
{'default:wood 1', 'default:wood 1', 'default:wood 1'},
{'default:wood 1', 'default:wood 1', 'default:wood 1'},
},
})
-- Mesecon Stuff:
mesecon:register_on_signal_on(on_hatch_punched)
mesecon:register_on_signal_off(on_hatch_punched)
Users browsing this forum: No registered users and 3 guests