mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-08-20 21:16:13 +02:00
Piston and wire cleanups and minor rotation fixes
This commit is contained in:
parent
410f43bbc1
commit
774aac6e90
@ -12,3 +12,86 @@ for hash, _ in pairs(old_forceloaded_blocks) do
|
|||||||
minetest.forceload_free_block(unhash_blockpos(hash))
|
minetest.forceload_free_block(unhash_blockpos(hash))
|
||||||
end
|
end
|
||||||
os.remove(minetest.get_worldpath()..DIR_DELIM.."mesecon_forceloaded")
|
os.remove(minetest.get_worldpath()..DIR_DELIM.."mesecon_forceloaded")
|
||||||
|
|
||||||
|
-- LBMs to convert old pistons to use facedir instead of separate up/down nodes
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "Convert up pistons to use facedir",
|
||||||
|
name = ":mesecons_pistons:update_up_pistons",
|
||||||
|
nodenames = {"mesecons_pistons:piston_up_normal_on","mesecons_pistons:piston_up_normal_off",
|
||||||
|
"mesecons_pistons:piston_up_sticky_on","mesecons_pistons:piston_up_sticky_off"},
|
||||||
|
action = function(pos, node)
|
||||||
|
if string.find(node.name, "sticky") then
|
||||||
|
if string.sub(node.name, -3, -1) == "_on" then
|
||||||
|
node.name = "mesecons_pistons:piston_sticky_on"
|
||||||
|
else
|
||||||
|
node.name = "mesecons_pistons:piston_sticky_off"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if string.sub(node.name, -3, -1) == "_on" then
|
||||||
|
node.name = "mesecons_pistons:piston_normal_on"
|
||||||
|
else
|
||||||
|
node.name = "mesecons_pistons:piston_normal_off"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local dir = {x=0, y=-1, z=0}
|
||||||
|
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "Convert down pistons to use facedir",
|
||||||
|
name = ":mesecons_pistons:update_down_pistons",
|
||||||
|
nodenames = {"mesecons_pistons:piston_down_normal_on","mesecons_pistons:piston_down_normal_off",
|
||||||
|
"mesecons_pistons:piston_down_sticky_on","mesecons_pistons:piston_down_sticky_off"},
|
||||||
|
action = function(pos, node)
|
||||||
|
if string.find(node.name, "sticky") then
|
||||||
|
if string.sub(node.name, -3, -1) == "_on" then
|
||||||
|
node.name = "mesecons_pistons:piston_sticky_on"
|
||||||
|
else
|
||||||
|
node.name = "mesecons_pistons:piston_sticky_off"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if string.sub(node.name, -3, -1) == "_on" then
|
||||||
|
node.name = "mesecons_pistons:piston_normal_on"
|
||||||
|
else
|
||||||
|
node.name = "mesecons_pistons:piston_normal_off"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local dir = {x=0, y=1, z=0}
|
||||||
|
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "Convert up piston pushers to use facedir",
|
||||||
|
name = ":mesecons_pistons:update_up_pushers",
|
||||||
|
nodenames = {"mesecons_pistons:piston_up_pusher_normal", "mesecons_pistons:piston_up_pusher_sticky"},
|
||||||
|
action = function(pos, node)
|
||||||
|
if string.find(node.name, "sticky") then
|
||||||
|
node.name = "mesecons_pistons:piston_pusher_sticky"
|
||||||
|
else
|
||||||
|
node.name = "mesecons_pistons:piston_pusher_normal"
|
||||||
|
end
|
||||||
|
local dir = {x=0, y=-1, z=0}
|
||||||
|
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_lbm({
|
||||||
|
label = "Convert down piston pushers to use facedir",
|
||||||
|
name = ":mesecons_pistons:update_down_pushers",
|
||||||
|
nodenames = {"mesecons_pistons:piston_down_pusher_normal", "mesecons_pistons:piston_down_pusher_sticky"},
|
||||||
|
action = function(pos, node)
|
||||||
|
if string.find(node.name, "sticky") then
|
||||||
|
node.name = "mesecons_pistons:piston_pusher_sticky"
|
||||||
|
else
|
||||||
|
node.name = "mesecons_pistons:piston_pusher_normal"
|
||||||
|
end
|
||||||
|
local dir = {x=0, y=1, z=0}
|
||||||
|
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
@ -179,10 +179,6 @@ end
|
|||||||
function mesecon.register_node(name, spec_common, spec_off, spec_on)
|
function mesecon.register_node(name, spec_common, spec_off, spec_on)
|
||||||
spec_common.drop = spec_common.drop or name .. "_off"
|
spec_common.drop = spec_common.drop or name .. "_off"
|
||||||
spec_common.__mesecon_basename = name
|
spec_common.__mesecon_basename = name
|
||||||
if spec_common.mesecon_wire then
|
|
||||||
-- Prevent wires from being rotated
|
|
||||||
spec_common.on_rotate = false
|
|
||||||
end
|
|
||||||
spec_on.__mesecon_state = "on"
|
spec_on.__mesecon_state = "on"
|
||||||
spec_off.__mesecon_state = "off"
|
spec_off.__mesecon_state = "off"
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ minetest.register_node("mesecons_extrawires:corner_on", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = corner_selectionbox,
|
selection_box = corner_selectionbox,
|
||||||
node_box = corner_nodebox,
|
node_box = corner_nodebox,
|
||||||
|
on_rotate = screwdriver.rotate_simple,
|
||||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons_extrawires:corner_off",
|
drop = "mesecons_extrawires:corner_off",
|
||||||
mesecons = {conductor =
|
mesecons = {conductor =
|
||||||
@ -64,6 +65,7 @@ minetest.register_node("mesecons_extrawires:corner_off", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = corner_selectionbox,
|
selection_box = corner_selectionbox,
|
||||||
node_box = corner_nodebox,
|
node_box = corner_nodebox,
|
||||||
|
on_rotate = screwdriver.rotate_simple,
|
||||||
groups = {dig_immediate = 3},
|
groups = {dig_immediate = 3},
|
||||||
mesecons = {conductor =
|
mesecons = {conductor =
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@ minetest.register_node("mesecons_extrawires:tjunction_on", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = tjunction_selectionbox,
|
selection_box = tjunction_selectionbox,
|
||||||
node_box = tjunction_nodebox,
|
node_box = tjunction_nodebox,
|
||||||
|
on_rotate = screwdriver.rotate_simple,
|
||||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons_extrawires:tjunction_off",
|
drop = "mesecons_extrawires:tjunction_off",
|
||||||
mesecons = {conductor =
|
mesecons = {conductor =
|
||||||
@ -65,6 +66,7 @@ minetest.register_node("mesecons_extrawires:tjunction_off", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = tjunction_selectionbox,
|
selection_box = tjunction_selectionbox,
|
||||||
node_box = tjunction_nodebox,
|
node_box = tjunction_nodebox,
|
||||||
|
on_rotate = screwdriver.rotate_simple,
|
||||||
groups = {dig_immediate = 3},
|
groups = {dig_immediate = 3},
|
||||||
mesecons = {conductor =
|
mesecons = {conductor =
|
||||||
{
|
{
|
||||||
|
@ -84,6 +84,7 @@ mesecon.register_node("mesecons_extrawires:vertical", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = vertical_box,
|
selection_box = vertical_box,
|
||||||
node_box = vertical_box,
|
node_box = vertical_box,
|
||||||
|
on_rotate = false,
|
||||||
is_vertical_conductor = true,
|
is_vertical_conductor = true,
|
||||||
drop = "mesecons_extrawires:vertical_off",
|
drop = "mesecons_extrawires:vertical_off",
|
||||||
after_place_node = vertical_update,
|
after_place_node = vertical_update,
|
||||||
@ -116,6 +117,7 @@ mesecon.register_node("mesecons_extrawires:vertical_top", {
|
|||||||
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
groups = {dig_immediate=3, not_in_creative_inventory=1},
|
||||||
selection_box = top_box,
|
selection_box = top_box,
|
||||||
node_box = top_box,
|
node_box = top_box,
|
||||||
|
on_rotate = false,
|
||||||
is_vertical_conductor = true,
|
is_vertical_conductor = true,
|
||||||
drop = "mesecons_extrawires:vertical_off",
|
drop = "mesecons_extrawires:vertical_off",
|
||||||
after_place_node = vertical_update,
|
after_place_node = vertical_update,
|
||||||
@ -146,6 +148,7 @@ mesecon.register_node("mesecons_extrawires:vertical_bottom", {
|
|||||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
selection_box = bottom_box,
|
selection_box = bottom_box,
|
||||||
node_box = bottom_box,
|
node_box = bottom_box,
|
||||||
|
on_rotate = false,
|
||||||
is_vertical_conductor = true,
|
is_vertical_conductor = true,
|
||||||
drop = "mesecons_extrawires:vertical_off",
|
drop = "mesecons_extrawires:vertical_off",
|
||||||
after_place_node = vertical_update,
|
after_place_node = vertical_update,
|
||||||
|
@ -30,6 +30,7 @@ minetest.register_node("mesecons_insulated:insulated_on", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
|
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
|
||||||
},
|
},
|
||||||
|
on_rotate = screwdriver.rotate_simple,
|
||||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons_insulated:insulated_off",
|
drop = "mesecons_insulated:insulated_off",
|
||||||
mesecons = {conductor = {
|
mesecons = {conductor = {
|
||||||
@ -62,6 +63,7 @@ minetest.register_node("mesecons_insulated:insulated_off", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
|
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
|
||||||
},
|
},
|
||||||
|
on_rotate = screwdriver.rotate_simple,
|
||||||
groups = {dig_immediate = 3},
|
groups = {dig_immediate = 3},
|
||||||
mesecons = {conductor = {
|
mesecons = {conductor = {
|
||||||
state = mesecon.state.off,
|
state = mesecon.state.off,
|
||||||
|
@ -12,10 +12,10 @@ local piston_get_rules = function (node)
|
|||||||
{x=0, y=-1, z=1},
|
{x=0, y=-1, z=1},
|
||||||
{x=0, y=1, z=-1},
|
{x=0, y=1, z=-1},
|
||||||
{x=0, y=-1, z=-1}}
|
{x=0, y=-1, z=-1}}
|
||||||
local pusher_dir = vector.multiply(minetest.facedir_to_dir(node.param2),-1)
|
local pusher_dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
|
||||||
for k,v in ipairs(all_rules) do
|
for k,v in ipairs(all_rules) do
|
||||||
if vector.equals(v,pusher_dir) then
|
if vector.equals(v, pusher_dir) then
|
||||||
table.remove(all_rules,k)
|
table.remove(all_rules, k)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return all_rules
|
return all_rules
|
||||||
@ -31,7 +31,7 @@ end
|
|||||||
|
|
||||||
local piston_remove_pusher = function(pos, node)
|
local piston_remove_pusher = function(pos, node)
|
||||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||||
local dir = vector.multiply(minetest.facedir_to_dir(node.param2),-1)
|
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
|
||||||
local pusherpos = vector.add(pos, dir)
|
local pusherpos = vector.add(pos, dir)
|
||||||
local pushername = minetest.get_node(pusherpos).name
|
local pushername = minetest.get_node(pusherpos).name
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ end
|
|||||||
|
|
||||||
local piston_on = function(pos, node)
|
local piston_on = function(pos, node)
|
||||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||||
local dir = vector.multiply(minetest.facedir_to_dir(node.param2),-1)
|
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
|
||||||
local np = vector.add(pos, dir)
|
local np = vector.add(pos, dir)
|
||||||
local maxpush = mesecon.setting("piston_max_push", 15)
|
local maxpush = mesecon.setting("piston_max_push", 15)
|
||||||
local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush)
|
local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush)
|
||||||
@ -74,18 +74,18 @@ local piston_off = function(pos, node)
|
|||||||
piston_remove_pusher(pos, node)
|
piston_remove_pusher(pos, node)
|
||||||
if pistonspec.sticky then
|
if pistonspec.sticky then
|
||||||
local maxpull = mesecon.setting("piston_max_pull", 15)
|
local maxpull = mesecon.setting("piston_max_pull", 15)
|
||||||
local dir = vector.multiply(minetest.facedir_to_dir(node.param2),-1)
|
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
|
||||||
local pullpos = vector.add(pos, vector.multiply(dir, 2))
|
local pullpos = vector.add(pos, vector.multiply(dir, 2))
|
||||||
local stack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), maxpull)
|
local stack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), maxpull)
|
||||||
mesecon.mvps_process_stack(pos, dir, stack)
|
mesecon.mvps_process_stack(pos, dir, stack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local piston_onrotate = function(pos,node,_,_,newparam2)
|
local piston_onrotate = function(pos, node, _, _, newparam2)
|
||||||
local node_copy = minetest.get_node(pos)
|
local node_copy = minetest.get_node(pos)
|
||||||
minetest.after(0,mesecon.on_dignode,pos,node)
|
minetest.after(0, mesecon.on_dignode, pos, node)
|
||||||
node_copy.param2 = newparam2
|
node_copy.param2 = newparam2
|
||||||
minetest.after(0,mesecon.on_placenode,pos,node_copy)
|
minetest.after(0, mesecon.on_placenode, pos, node_copy)
|
||||||
end
|
end
|
||||||
|
|
||||||
local pt = 3/16 -- pusher thickness
|
local pt = 3/16 -- pusher thickness
|
||||||
@ -342,85 +342,3 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- LBMs to convert old pistons to use facedir instead of separate up/down nodes
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "Convert up pistons to use facedir",
|
|
||||||
name = "mesecons_pistons:update_up_pistons",
|
|
||||||
nodenames = {"mesecons_pistons:piston_up_normal_on","mesecons_pistons:piston_up_normal_off",
|
|
||||||
"mesecons_pistons:piston_up_sticky_on","mesecons_pistons:piston_up_sticky_off"},
|
|
||||||
action = function(pos,node)
|
|
||||||
if string.find(node.name,"sticky") then
|
|
||||||
if string.sub(node.name,-3,-1) == "_on" then
|
|
||||||
node.name = "mesecons_pistons:piston_sticky_on"
|
|
||||||
else
|
|
||||||
node.name = "mesecons_pistons:piston_sticky_off"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if string.sub(node.name,-3,-1) == "_on" then
|
|
||||||
node.name = "mesecons_pistons:piston_normal_on"
|
|
||||||
else
|
|
||||||
node.name = "mesecons_pistons:piston_normal_off"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local dir = {x=0,y=-1,z=0}
|
|
||||||
node.param2 = minetest.dir_to_facedir(dir,true)
|
|
||||||
minetest.swap_node(pos,node)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "Convert down pistons to use facedir",
|
|
||||||
name = "mesecons_pistons:update_down_pistons",
|
|
||||||
nodenames = {"mesecons_pistons:piston_down_normal_on","mesecons_pistons:piston_down_normal_off",
|
|
||||||
"mesecons_pistons:piston_down_sticky_on","mesecons_pistons:piston_down_sticky_off"},
|
|
||||||
action = function(pos,node)
|
|
||||||
if string.find(node.name,"sticky") then
|
|
||||||
if string.sub(node.name,-3,-1) == "_on" then
|
|
||||||
node.name = "mesecons_pistons:piston_sticky_on"
|
|
||||||
else
|
|
||||||
node.name = "mesecons_pistons:piston_sticky_off"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
if string.sub(node.name,-3,-1) == "_on" then
|
|
||||||
node.name = "mesecons_pistons:piston_normal_on"
|
|
||||||
else
|
|
||||||
node.name = "mesecons_pistons:piston_normal_off"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local dir = {x=0,y=1,z=0}
|
|
||||||
node.param2 = minetest.dir_to_facedir(dir,true)
|
|
||||||
minetest.swap_node(pos,node)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "Convert up piston pushers to use facedir",
|
|
||||||
name = "mesecons_pistons:update_up_pushers",
|
|
||||||
nodenames = {"mesecons_pistons:piston_up_pusher_normal","mesecons_pistons:piston_up_pusher_sticky"},
|
|
||||||
action = function(pos,node)
|
|
||||||
if string.find(node.name,"sticky") then
|
|
||||||
node.name = "mesecons_pistons:piston_pusher_sticky"
|
|
||||||
else
|
|
||||||
node.name = "mesecons_pistons:piston_pusher_normal"
|
|
||||||
end
|
|
||||||
local dir = {x=0,y=-1,z=0}
|
|
||||||
node.param2 = minetest.dir_to_facedir(dir,true)
|
|
||||||
minetest.swap_node(pos,node)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_lbm({
|
|
||||||
label = "Convert down piston pushers to use facedir",
|
|
||||||
name = "mesecons_pistons:update_down_pushers",
|
|
||||||
nodenames = {"mesecons_pistons:piston_down_pusher_normal","mesecons_pistons:piston_down_pusher_sticky"},
|
|
||||||
action = function(pos,node)
|
|
||||||
if string.find(node.name,"sticky") then
|
|
||||||
node.name = "mesecons_pistons:piston_pusher_sticky"
|
|
||||||
else
|
|
||||||
node.name = "mesecons_pistons:piston_pusher_normal"
|
|
||||||
end
|
|
||||||
local dir = {x=0,y=1,z=0}
|
|
||||||
node.param2 = minetest.dir_to_facedir(dir,true)
|
|
||||||
minetest.swap_node(pos,node)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
@ -200,7 +200,6 @@ local function register_wires()
|
|||||||
if nodeid ~= "00000000" then
|
if nodeid ~= "00000000" then
|
||||||
groups_off["not_in_creative_inventory"] = 1
|
groups_off["not_in_creative_inventory"] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.register_node(":mesecons:wire_"..nodeid, {
|
mesecon.register_node(":mesecons:wire_"..nodeid, {
|
||||||
description = "Mesecon",
|
description = "Mesecon",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -212,6 +211,7 @@ local function register_wires()
|
|||||||
selection_box = selectionbox,
|
selection_box = selectionbox,
|
||||||
node_box = nodebox,
|
node_box = nodebox,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
|
on_rotate = false,
|
||||||
drop = "mesecons:wire_00000000_off",
|
drop = "mesecons:wire_00000000_off",
|
||||||
mesecon_wire = true
|
mesecon_wire = true
|
||||||
}, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off},
|
}, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off},
|
||||||
|
Loading…
Reference in New Issue
Block a user