From 0aab812487480f2c644c882d5b010d7ef7644da6 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 16 Dec 2012 13:02:05 +0100 Subject: [PATCH 1/7] Fix addPosRule without mesecon: in vertical wires (issue #62) --- mesecons_extrawires/vertical.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesecons_extrawires/vertical.lua b/mesecons_extrawires/vertical.lua index 64e6e80..c20415a 100644 --- a/mesecons_extrawires/vertical.lua +++ b/mesecons_extrawires/vertical.lua @@ -35,8 +35,8 @@ local brules = local vertical_updatepos = function (pos) local node = minetest.env:get_node(pos) if minetest.registered_nodes[node.name].is_vertical_conductor then - local node_above = minetest.env:get_node(addPosRule(pos, vrules[1])) - local node_below = minetest.env:get_node(addPosRule(pos, vrules[2])) + local node_above = minetest.env:get_node(mesecon:addPosRule(pos, vrules[1])) + local node_below = minetest.env:get_node(mesecon:addPosRule(pos, vrules[2])) local namestate = minetest.registered_nodes[node.name].vertical_conductor_state -- above and below: vertical mesecon From 13befe3bbab80faf62ad88188c26c7765e7a01a7 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 16 Dec 2012 19:03:46 +0100 Subject: [PATCH 2/7] Fix #62 (Hopefully this time) --- mesecons_extrawires/vertical.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mesecons_extrawires/vertical.lua b/mesecons_extrawires/vertical.lua index c20415a..9aaa163 100644 --- a/mesecons_extrawires/vertical.lua +++ b/mesecons_extrawires/vertical.lua @@ -64,10 +64,9 @@ local vertical_updatepos = function (pos) end local vertical_update = function (pos, node) - print("update") vertical_updatepos(pos) -- this one - vertical_updatepos(addPosRule(pos, vrules[1])) -- above - vertical_updatepos(addPosRule(pos, vrules[2])) -- below + vertical_updatepos(mesecon:addPosRule(pos, vrules[1])) -- above + vertical_updatepos(mesecon:addPosRule(pos, vrules[2])) -- below end -- Vertical wire From c50b68cf8327b5c79eb1723f45b8fb46d4f6d3c9 Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Sun, 16 Dec 2012 15:12:24 -0500 Subject: [PATCH 3/7] Use a simpler way of detecting up/down piston placement (thanks Jeija). --- mesecons_pistons/init.lua | 56 +++++++++++---------------------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 840cce2..11389b3 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -184,28 +184,16 @@ minetest.register_node("mesecons_pistons:piston_normal", { paramtype2 = "facedir", after_destruct = destruct, on_timer = timer, - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.type ~= "node" then --can be placed only on nodes - return itemstack + after_place_node = function(pos, placer) + if not placer then --not placed by player + return end - if not placer then - return minetest.item_place(itemstack, placer, pointed_thing) + local pitch = placer:get_look_pitch() * (180 / math.pi) --placer pitch in degrees + if pitch > 45 then --looking upwards + minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_normal"}) + elseif pitch < 45 then --looking downwards + minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_normal"}) end - local dir = placer:get_look_dir() - if math.abs(dir.y) > math.sqrt(dir.x ^ 2 + dir.z ^ 2) then --vertical look direction is most significant - local fakestack - if dir.y > 0 then - fakestack = ItemStack("mesecons_pistons:piston_down_normal") - else - fakestack = ItemStack("mesecons_pistons:piston_up_normal") - end - local ret = minetest.item_place(fakestack, placer, pointed_thing) - if ret:is_empty() then - itemstack:take_item() - return itemstack - end - end - return minetest.item_place(itemstack, placer, pointed_thing) --place piston normally end, mesecons = {effector={ action_change = update @@ -219,28 +207,16 @@ minetest.register_node("mesecons_pistons:piston_sticky", { paramtype2 = "facedir", after_destruct = destruct, on_timer = timer, - on_place = function(itemstack, placer, pointed_thing) - if pointed_thing.type ~= "node" then --can be placed only on nodes - return itemstack + after_place_node = function(pos, placer) + if not placer then --not placed by player + return end - if not placer then - return minetest.item_place(itemstack, placer, pointed_thing) + local pitch = placer:get_look_pitch() * (180 / math.pi) --placer pitch in degrees + if pitch > 45 then --looking upwards + minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_sticky"}) + elseif pitch < 45 then --looking downwards + minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_sticky"}) end - local dir = placer:get_look_dir() - if math.abs(dir.y) > math.sqrt(dir.x ^ 2 + dir.z ^ 2) then --vertical look direction is most significant - local fakestack - if dir.y > 0 then - fakestack = ItemStack("mesecons_pistons:piston_down_sticky") - else - fakestack = ItemStack("mesecons_pistons:piston_up_sticky") - end - local ret = minetest.item_place(fakestack, placer, pointed_thing) - if ret:is_empty() then - itemstack:take_item() - return itemstack - end - end - return minetest.item_place(itemstack, placer, pointed_thing) --place piston normally end, mesecons = {effector={ action_change = update From 313b9adcd5fcfd400af7ed730a2829db3fe21015 Mon Sep 17 00:00:00 2001 From: Jeija Date: Tue, 18 Dec 2012 15:59:23 +0100 Subject: [PATCH 4/7] Should fix this bug: bit.ly/XEy94j --- mesecons/internal.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index de05bec..a4beb4a 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -46,7 +46,7 @@ function mesecon:receptor_get_rules(node) if receptor.onstate == node.name or receptor.offstate == node.name then if receptor.get_rules ~= nil then return receptor.get_rules(node.param2) - elseif mesecon.receptors[i].rules ~=nil then + elseif receptor.rules ~=nil then return receptor.rules else return mesecon:get_rules("default") From 5cdf23fb00ae257cd1d77b186cd40e889530d4f0 Mon Sep 17 00:00:00 2001 From: Jeija Date: Tue, 18 Dec 2012 16:20:24 +0100 Subject: [PATCH 5/7] Fix bug reported here: http://bit.ly/VOF35X --- mesecons_pistons/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 11389b3..57e944b 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -191,7 +191,7 @@ minetest.register_node("mesecons_pistons:piston_normal", { local pitch = placer:get_look_pitch() * (180 / math.pi) --placer pitch in degrees if pitch > 45 then --looking upwards minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_normal"}) - elseif pitch < 45 then --looking downwards + elseif pitch < -45 then --looking downwards minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_normal"}) end end, @@ -443,4 +443,4 @@ minetest.register_craft({ {"mesecons_materials:glue"}, {"mesecons_pistons:piston_normal"}, } -}) \ No newline at end of file +}) From f6ef7b005d4ca6d9b26aa5e60909713178184a73 Mon Sep 17 00:00:00 2001 From: Jeija Date: Tue, 18 Dec 2012 16:21:41 +0100 Subject: [PATCH 6/7] Same for sticky piston --- mesecons_pistons/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 57e944b..44b9095 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -214,7 +214,7 @@ minetest.register_node("mesecons_pistons:piston_sticky", { local pitch = placer:get_look_pitch() * (180 / math.pi) --placer pitch in degrees if pitch > 45 then --looking upwards minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_sticky"}) - elseif pitch < 45 then --looking downwards + elseif pitch < -45 then --looking downwards minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_sticky"}) end end, From 973a9c650f72ce694bd31dfbc5d6030751ff7c05 Mon Sep 17 00:00:00 2001 From: Jeija Date: Fri, 21 Dec 2012 16:19:38 +0100 Subject: [PATCH 7/7] Add new crafting recipe for mesecons: Cook a mese crystal --- mesecons/wires.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mesecons/wires.lua b/mesecons/wires.lua index bea84dd..e2eae5a 100644 --- a/mesecons/wires.lua +++ b/mesecons/wires.lua @@ -292,6 +292,12 @@ minetest.register_craft({ } }) +minetest.register_craft({ + type = "cooking", + output = '"mesecons:wire_00000000_off" 16', + recipe = "default:mese_crystal", +}) + minetest.register_abm( {nodenames = {"mesecons:mesecon_off", "mesecons:mesecon_on"}, interval = 2,