Port door, fix button/lever bug, new visual style for receiver
@ -23,5 +23,17 @@ mesecon.rules.buttonlike =
|
|||||||
{x = 1, y =-1, z =-1},
|
{x = 1, y =-1, z =-1},
|
||||||
{x = 2, y = 0, z = 0}}
|
{x = 2, y = 0, z = 0}}
|
||||||
|
|
||||||
|
mesecon.rules.buttonlike_get = function(node)
|
||||||
|
local rules = mesecon.rules.buttonlike
|
||||||
|
if node.param2 == 2 then
|
||||||
|
rules=mesecon:rotate_rules_left(rules)
|
||||||
|
elseif node.param2 == 3 then
|
||||||
|
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
||||||
|
elseif node.param2 == 0 then
|
||||||
|
rules=mesecon:rotate_rules_right(rules)
|
||||||
|
end
|
||||||
|
return rules
|
||||||
|
end
|
||||||
|
|
||||||
mesecon.state.on = "on"
|
mesecon.state.on = "on"
|
||||||
mesecon.state.off = "off"
|
mesecon.state.off = "off"
|
||||||
|
@ -2,6 +2,15 @@
|
|||||||
-- A button that when pressed emits power for 1 second
|
-- A button that when pressed emits power for 1 second
|
||||||
-- and then turns off again
|
-- and then turns off again
|
||||||
|
|
||||||
|
mesecon.button_turnoff = function (pos)
|
||||||
|
local node = minetest.env:get_node(pos)
|
||||||
|
if node.name=="mesecons_button:button_on" then --has not been dug
|
||||||
|
mesecon:swap_node(pos, "mesecons_button:button_off")
|
||||||
|
local rules = mesecon.rules.buttonlike_get(node)
|
||||||
|
mesecon:receptor_off(pos, rules)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_off", {
|
minetest.register_node("mesecons_button:button_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -32,13 +41,12 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
description = "Button",
|
description = "Button",
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
mesecon:swap_node(pos, "mesecons_button:button_on")
|
mesecon:swap_node(pos, "mesecons_button:button_on")
|
||||||
local rules=mesecon.button_get_rules(node)
|
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
mesecon:receptor_on(pos, rules)
|
minetest.after(1, mesecon.button_turnoff, pos)
|
||||||
minetest.after(1, mesecon.button_turnoff, {pos=pos, param2=node.param2})
|
|
||||||
end,
|
end,
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.off,
|
state = mesecon.state.off,
|
||||||
rules = button_get_rules
|
rules = mesecon.rules.buttonlike_get
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -74,30 +82,10 @@ minetest.register_node("mesecons_button:button_on", {
|
|||||||
description = "Button",
|
description = "Button",
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on,
|
||||||
rules = button_get_rules
|
rules = mesecon.rules.buttonlike_get
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
|
|
||||||
mesecon.button_turnoff = function (params)
|
|
||||||
if minetest.env:get_node(params.pos).name=="mesecons_button:button_on" then
|
|
||||||
mesecon:swap_node(params.pos, "mesecons_button:button_off")
|
|
||||||
local rules=mesecon.button_get_rules(params)
|
|
||||||
mesecon:receptor_off(params.pos, rules)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
mesecon.button_get_rules = function(node)
|
|
||||||
local rules = mesecon.rules.buttonlike
|
|
||||||
if node.param2 == 2 then
|
|
||||||
rules=mesecon:rotate_rules_left(rules)
|
|
||||||
elseif node.param2 == 3 then
|
|
||||||
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
|
||||||
elseif node.param2 == 0 then
|
|
||||||
rules=mesecon:rotate_rules_right(rules)
|
|
||||||
end
|
|
||||||
return rules
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = '"mesecons_button:button_off" 2',
|
output = '"mesecons_button:button_off" 2',
|
||||||
recipe = {
|
recipe = {
|
||||||
|
@ -1,11 +1,165 @@
|
|||||||
minetest.after(0,
|
doors = {}
|
||||||
function ()
|
|
||||||
if minetest.registered_nodes["doors:door_wood_b_1"] then
|
-- Registers a door - REDEFINITION ONLY | DOORS MOD MUST HAVE BEEN LOADED BEFORE
|
||||||
mesecon:register_effector("doors:door_wood_b_1", "doors:door_wood_b_2")
|
-- name: The name of the door
|
||||||
mesecon:register_on_signal_change(function(pos, node)
|
-- def: a table with the folowing fields:
|
||||||
if node.name == "doors:door_wood_b_2" or node.name == "doors:door_wood_b_1" then
|
-- description
|
||||||
minetest.registered_nodes[node.name].on_punch(pos, node)
|
-- inventory_image
|
||||||
|
-- groups
|
||||||
|
-- tiles_bottom: the tiles of the bottom part of the door {front, side}
|
||||||
|
-- tiles_top: the tiles of the bottom part of the door {front, side}
|
||||||
|
-- If the following fields are not defined the default values are used
|
||||||
|
-- node_box_bottom
|
||||||
|
-- node_box_top
|
||||||
|
-- selection_box_bottom
|
||||||
|
-- selection_box_top
|
||||||
|
-- only_placer_can_open: if true only the player who placed the door can
|
||||||
|
-- open it
|
||||||
|
|
||||||
|
function doors:register_door(name, def)
|
||||||
|
def.groups.not_in_creative_inventory = 1
|
||||||
|
|
||||||
|
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}}
|
||||||
|
|
||||||
|
if not def.node_box_bottom then
|
||||||
|
def.node_box_bottom = box
|
||||||
end
|
end
|
||||||
end)
|
if not def.node_box_top then
|
||||||
|
def.node_box_top = box
|
||||||
end
|
end
|
||||||
end)
|
if not def.selection_box_bottom then
|
||||||
|
def.selection_box_bottom= box
|
||||||
|
end
|
||||||
|
if not def.selection_box_top then
|
||||||
|
def.selection_box_top = box
|
||||||
|
end
|
||||||
|
|
||||||
|
local tt = def.tiles_top
|
||||||
|
local tb = def.tiles_bottom
|
||||||
|
|
||||||
|
local function after_dig_node(pos, name)
|
||||||
|
if minetest.env:get_node(pos).name == name then
|
||||||
|
minetest.env:remove_node(pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_punch(pos, dir, check_name, replace, replace_dir, params)
|
||||||
|
pos.y = pos.y+dir
|
||||||
|
if not minetest.env:get_node(pos).name == check_name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local p2 = minetest.env:get_node(pos).param2
|
||||||
|
p2 = params[p2+1]
|
||||||
|
|
||||||
|
local meta = minetest.env:get_meta(pos):to_table()
|
||||||
|
minetest.env:set_node(pos, {name=replace_dir, param2=p2})
|
||||||
|
minetest.env:get_meta(pos):from_table(meta)
|
||||||
|
|
||||||
|
pos.y = pos.y-dir
|
||||||
|
meta = minetest.env:get_meta(pos):to_table()
|
||||||
|
minetest.env:set_node(pos, {name=replace, param2=p2})
|
||||||
|
minetest.env:get_meta(pos):from_table(meta)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_mesecons_signal_open (pos, node)
|
||||||
|
on_punch(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_mesecons_signal_close (pos, node)
|
||||||
|
on_punch(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function check_player_priv(pos, player)
|
||||||
|
if not def.only_placer_can_open then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
local pn = player:get_player_name()
|
||||||
|
return meta:get_string("doors_owner") == pn
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node(":"..name.."_b_1", {
|
||||||
|
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"},
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drop = name,
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = def.node_box_bottom
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = def.selection_box_bottom
|
||||||
|
},
|
||||||
|
groups = def.groups,
|
||||||
|
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
pos.y = pos.y+1
|
||||||
|
after_dig_node(pos, name.."_t_1")
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_punch = function(pos, node, puncher)
|
||||||
|
if check_player_priv(pos, puncher) then
|
||||||
|
on_punch(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = on_mesecons_signal_open
|
||||||
|
}},
|
||||||
|
|
||||||
|
can_dig = check_player_priv,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node(":"..name.."_b_2", {
|
||||||
|
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1].."^[transformfx", tb[1]},
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
drop = name,
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = def.node_box_bottom
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = def.selection_box_bottom
|
||||||
|
},
|
||||||
|
groups = def.groups,
|
||||||
|
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
pos.y = pos.y+1
|
||||||
|
after_dig_node(pos, name.."_t_2")
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_punch = function(pos, node, puncher)
|
||||||
|
if check_player_priv(pos, puncher) then
|
||||||
|
on_punch(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_off = on_mesecons_signal_close
|
||||||
|
}},
|
||||||
|
|
||||||
|
can_dig = check_player_priv,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
doors:register_door("doors:door_wood", {
|
||||||
|
description = "Wooden Door",
|
||||||
|
inventory_image = "door_wood.png",
|
||||||
|
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
|
||||||
|
tiles_bottom = {"door_wood_b.png", "door_brown.png"},
|
||||||
|
tiles_top = {"door_wood_a.png", "door_brown.png"},
|
||||||
|
})
|
||||||
|
|
||||||
|
doors:register_door("doors:door_steel", {
|
||||||
|
description = "Steel Door",
|
||||||
|
inventory_image = "door_steel.png",
|
||||||
|
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
|
||||||
|
tiles_bottom = {"door_steel_b.png", "door_grey.png"},
|
||||||
|
tiles_top = {"door_steel_a.png", "door_grey.png"},
|
||||||
|
only_placer_can_open = true,
|
||||||
|
})
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
rcvboxes = {
|
rcvboxes = {
|
||||||
{ -3/16, -3/16 , -8/16 , 3/16, 3/16, -13/32 }, -- the smaller bump
|
{ -3/16, -3/16 , -8/16 , 3/16, 3/16, -13/32 }, -- the smaller bump
|
||||||
{ -5/32, -5/32 , -13/32 , 5/32, 5/32, -12/32 }, -- the receiver itself
|
{ -1/32, -1/32 , -3/2 , 1/32, 1/32, -1/2 }, -- the wire through the block
|
||||||
{ -3/32, -.5-1/32, -.5 , 3/32, 0 , -.5002+3/32 }, -- the vertical wire bit
|
{ -2/32, -.5-1/32, -.5 , 2/32, 0 , -.5002+3/32 }, -- the vertical wire bit
|
||||||
{ -3/32, -17/32 , -7/16+0.002 , 3/32, -13/32, 16/32+0.001 } -- the horizontal wire
|
{ -2/32, -17/32 , -7/16+0.002 , 2/32, -14/32, 16/32+0.001 } -- the horizontal wire
|
||||||
}
|
}
|
||||||
|
|
||||||
local receiver_get_rules = function (node)
|
local receiver_get_rules = function (node)
|
||||||
@ -31,6 +31,7 @@ minetest.register_node("mesecons_receiver:receiver_on", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
|
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
|
||||||
@ -62,6 +63,7 @@ minetest.register_node("mesecons_receiver:receiver_off", {
|
|||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
|
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
|
||||||
@ -113,7 +115,7 @@ function mesecon:receiver_place(rcpt_pos)
|
|||||||
minetest.env:dig_node(pos)
|
minetest.env:dig_node(pos)
|
||||||
if mesecon:is_power_on(rcpt_pos) then
|
if mesecon:is_power_on(rcpt_pos) then
|
||||||
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
|
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
|
||||||
mesecon:receptor_on(pos, receiver_get_rules(node.param2))
|
mesecon:receptor_on(pos, receiver_get_rules(node))
|
||||||
else
|
else
|
||||||
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
|
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
|
||||||
end
|
end
|
||||||
|
Before Width: | Height: | Size: 242 B After Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 517 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 317 B After Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 494 B |
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 239 B |
@ -1,22 +1,6 @@
|
|||||||
-- WALL LEVER
|
-- WALL LEVER
|
||||||
local walllever_get_rules = function(node)
|
-- Basically a switch that can be attached to a wall
|
||||||
local rules = {
|
-- Powers the block 2 nodes behind (using a receiver)
|
||||||
{x = 1, y = 0, z = 0},
|
|
||||||
{x = 1, y = 1, z = 0},
|
|
||||||
{x = 1, y =-1, z = 0},
|
|
||||||
{x = 1, y =-1, z = 1},
|
|
||||||
{x = 1, y =-1, z =-1},
|
|
||||||
{x = 2, y = 0, z = 0}}
|
|
||||||
if node.param2 == 2 then
|
|
||||||
rules=mesecon:rotate_rules_left(rules)
|
|
||||||
elseif node.param2 == 3 then
|
|
||||||
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
|
||||||
elseif node.param2 == 0 then
|
|
||||||
rules=mesecon:rotate_rules_right(rules)
|
|
||||||
end
|
|
||||||
return rules
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_walllever:wall_lever_off", {
|
minetest.register_node("mesecons_walllever:wall_lever_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -49,10 +33,10 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
|
|||||||
description="Lever",
|
description="Lever",
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_on")
|
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_on")
|
||||||
mesecon:receptor_on(pos, walllever_get_rules(node))
|
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
end,
|
end,
|
||||||
mesecon = {receptor = {
|
mesecons = {receptor = {
|
||||||
rules = walllever_get_rules,
|
rules = mesecon.rules.buttonlike_get,
|
||||||
state = mesecon.state.off
|
state = mesecon.state.off
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
@ -84,15 +68,15 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
|||||||
{ -2/16, -1/16, 3/16, 2/16, 1/16, 4/16 }, -- the lever "hinge"
|
{ -2/16, -1/16, 3/16, 2/16, 1/16, 4/16 }, -- the lever "hinge"
|
||||||
{ -1/16, 0, 4/16, 1/16, 8/16, 6/16 }} -- the lever itself.
|
{ -1/16, 0, 4/16, 1/16, 8/16, 6/16 }} -- the lever itself.
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 3, mesecon_needs_receiver = 1},
|
groups = {dig_immediate = 2, not_in_creative_inventory = 1, mesecon_needs_receiver = 1},
|
||||||
drop = '"mesecons_walllever:wall_lever_off" 1',
|
drop = '"mesecons_walllever:wall_lever_off" 1',
|
||||||
description="Lever",
|
description="Lever",
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_off")
|
mesecon:swap_node(pos, "mesecons_walllever:wall_lever_off")
|
||||||
mesecon:receptor_off(pos, walllever_get_rules(node))
|
mesecon:receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||||
end,
|
end,
|
||||||
mesecon = {receptor = {
|
mesecons = {receptor = {
|
||||||
rules = walllever_get_rules,
|
rules = mesecon.rules.buttonlike_get,
|
||||||
state = mesecon.state.on
|
state = mesecon.state.on
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
|