summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesecons/legacy.lua83
-rw-r--r--mesecons/util.lua4
-rw-r--r--mesecons_extrawires/corner.lua2
-rw-r--r--mesecons_extrawires/tjunction.lua2
-rw-r--r--mesecons_extrawires/vertical.lua3
-rw-r--r--mesecons_insulated/init.lua2
-rw-r--r--mesecons_pistons/init.lua100
-rw-r--r--mesecons_wires/init.lua2
8 files changed, 102 insertions, 96 deletions
diff --git a/mesecons/legacy.lua b/mesecons/legacy.lua
index ad7093a..5c4e6c7 100644
--- a/mesecons/legacy.lua
+++ b/mesecons/legacy.lua
@@ -12,3 +12,86 @@ for hash, _ in pairs(old_forceloaded_blocks) do
minetest.forceload_free_block(unhash_blockpos(hash))
end
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
+})
diff --git a/mesecons/util.lua b/mesecons/util.lua
index 21ceda1..39f5696 100644
--- a/mesecons/util.lua
+++ b/mesecons/util.lua
@@ -179,10 +179,6 @@ end
function mesecon.register_node(name, spec_common, spec_off, spec_on)
spec_common.drop = spec_common.drop or name .. "_off"
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_off.__mesecon_state = "off"
diff --git a/mesecons_extrawires/corner.lua b/mesecons_extrawires/corner.lua
index 6033893..05e76b3 100644
--- a/mesecons_extrawires/corner.lua
+++ b/mesecons_extrawires/corner.lua
@@ -37,6 +37,7 @@ minetest.register_node("mesecons_extrawires:corner_on", {
sunlight_propagates = true,
selection_box = corner_selectionbox,
node_box = corner_nodebox,
+ on_rotate = screwdriver.rotate_simple,
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons_extrawires:corner_off",
mesecons = {conductor =
@@ -64,6 +65,7 @@ minetest.register_node("mesecons_extrawires:corner_off", {
sunlight_propagates = true,
selection_box = corner_selectionbox,
node_box = corner_nodebox,
+ on_rotate = screwdriver.rotate_simple,
groups = {dig_immediate = 3},
mesecons = {conductor =
{
diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua
index 70f343b..3d991d0 100644
--- a/mesecons_extrawires/tjunction.lua
+++ b/mesecons_extrawires/tjunction.lua
@@ -38,6 +38,7 @@ minetest.register_node("mesecons_extrawires:tjunction_on", {
sunlight_propagates = true,
selection_box = tjunction_selectionbox,
node_box = tjunction_nodebox,
+ on_rotate = screwdriver.rotate_simple,
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "mesecons_extrawires:tjunction_off",
mesecons = {conductor =
@@ -65,6 +66,7 @@ minetest.register_node("mesecons_extrawires:tjunction_off", {
sunlight_propagates = true,
selection_box = tjunction_selectionbox,
node_box = tjunction_nodebox,
+ on_rotate = screwdriver.rotate_simple,
groups = {dig_immediate = 3},
mesecons = {conductor =
{
diff --git a/mesecons_extrawires/vertical.lua b/mesecons_extrawires/vertical.lua
index f3232d8..af366c5 100644
--- a/mesecons_extrawires/vertical.lua
+++ b/mesecons_extrawires/vertical.lua
@@ -84,6 +84,7 @@ mesecon.register_node("mesecons_extrawires:vertical", {
sunlight_propagates = true,
selection_box = vertical_box,
node_box = vertical_box,
+ on_rotate = false,
is_vertical_conductor = true,
drop = "mesecons_extrawires:vertical_off",
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},
selection_box = top_box,
node_box = top_box,
+ on_rotate = false,
is_vertical_conductor = true,
drop = "mesecons_extrawires:vertical_off",
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},
selection_box = bottom_box,
node_box = bottom_box,
+ on_rotate = false,
is_vertical_conductor = true,
drop = "mesecons_extrawires:vertical_off",
after_place_node = vertical_update,
diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua
index 15b916b..108badf 100644
--- a/mesecons_insulated/init.lua
+++ b/mesecons_insulated/init.lua
@@ -30,6 +30,7 @@ minetest.register_node("mesecons_insulated:insulated_on", {
type = "fixed",
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},
drop = "mesecons_insulated:insulated_off",
mesecons = {conductor = {
@@ -62,6 +63,7 @@ minetest.register_node("mesecons_insulated:insulated_off", {
type = "fixed",
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},
mesecons = {conductor = {
state = mesecon.state.off,
diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua
index 999014d..c8830ac 100644
--- a/mesecons_pistons/init.lua
+++ b/mesecons_pistons/init.lua
@@ -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}}
- 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
- if vector.equals(v,pusher_dir) then
- table.remove(all_rules,k)
+ if vector.equals(v, pusher_dir) then
+ table.remove(all_rules, k)
end
end
return all_rules
@@ -31,7 +31,7 @@ end
local piston_remove_pusher = function(pos, node)
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 pushername = minetest.get_node(pusherpos).name
@@ -51,7 +51,7 @@ end
local piston_on = function(pos, node)
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 maxpush = mesecon.setting("piston_max_push", 15)
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)
if pistonspec.sticky then
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 stack = mesecon.mvps_pull_single(pullpos, vector.multiply(dir, -1), maxpull)
mesecon.mvps_process_stack(pos, dir, stack)
end
end
-local piston_onrotate = function(pos,node,_,_,newparam2)
+local piston_onrotate = function(pos, node, _, _, newparam2)
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
- minetest.after(0,mesecon.on_placenode,pos,node_copy)
+ minetest.after(0, mesecon.on_placenode, pos, node_copy)
end
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
-})
diff --git a/mesecons_wires/init.lua b/mesecons_wires/init.lua
index ced7c99..0e429ba 100644
--- a/mesecons_wires/init.lua
+++ b/mesecons_wires/init.lua
@@ -200,7 +200,6 @@ local function register_wires()
if nodeid ~= "00000000" then
groups_off["not_in_creative_inventory"] = 1
end
-
mesecon.register_node(":mesecons:wire_"..nodeid, {
description = "Mesecon",
drawtype = "nodebox",
@@ -212,6 +211,7 @@ local function register_wires()
selection_box = selectionbox,
node_box = nodebox,
walkable = false,
+ on_rotate = false,
drop = "mesecons:wire_00000000_off",
mesecon_wire = true
}, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off},