From 594d061d6d33e59009914d8873f5c1584f1383f0 Mon Sep 17 00:00:00 2001 From: Jeija Date: Wed, 12 Dec 2012 03:14:57 +0100 Subject: [PATCH 01/28] Fix sticky piston retraction not working --- mesecons_pistons/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index e5228d4..fb7375b 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -216,6 +216,7 @@ minetest.register_node("mesecons_pistons:piston_sticky", { paramtype2 = "facedir", after_destruct = destruct, on_timer = timer, + is_sticky_piston = true, after_place_node = function(pos, placer) if not placer then --not placed by player return From 44dc1a128cd6574b53ae68c33a6d2583eb878087 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sat, 15 Dec 2012 18:45:51 +0100 Subject: [PATCH 02/28] Upload cleaned up mesecons to nextgen branch --- mesecons/init.lua | 6 +- mesecons/internal.lua | 497 ++++++++---------- mesecons/legacy.lua | 60 --- mesecons/oldwires.lua | 38 ++ mesecons/services.lua | 43 +- mesecons/wires.lua | 84 +-- mesecons_extrawires/vertical.lua | 18 +- mesecons_pistons/init.lua | 7 +- mesecons_textures/textures/wires_full_off.png | Bin 0 -> 465 bytes mesecons_textures/textures/wires_full_on.png | Bin 0 -> 464 bytes 10 files changed, 309 insertions(+), 444 deletions(-) create mode 100644 mesecons/oldwires.lua create mode 100644 mesecons_textures/textures/wires_full_off.png create mode 100644 mesecons_textures/textures/wires_full_on.png diff --git a/mesecons/init.lua b/mesecons/init.lua index aa3f001..0af53f1 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -22,14 +22,14 @@ -- { -- state = mesecon.state.on/off -- rules = rules/get_rules --- } +-- }, -- effector = -- { -- action_on = function -- action_off = function -- action_change = function -- rules = rules/get_rules --- } +-- }, -- conductor = -- { -- state = mesecon.state.on/off @@ -97,7 +97,7 @@ function mesecon:receptor_off(pos, rules) x = pos.x + rule.x, y = pos.y + rule.y, z = pos.z + rule.z} - if mesecon:rules_link(pos, np, rules) and not mesecon:connected_to_pw_src(np) then + if mesecon:rules_link(pos, np, rules) and not mesecon:connected_to_receptor(np) then mesecon:turnoff(np, pos) end end diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 0249728..ea21522 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -1,162 +1,202 @@ --- INTERNAL +-- Internal.lua - The core of mesecons +-- +-- For more practical developer resources see mesecons.tk +-- +-- Function overview +-- mesecon:get_effector(nodename) --> Returns the mesecons.effector -specifictation in the nodedef by the nodename +-- mesecon:get_receptor(nodename) --> Returns the mesecons.receptor -specifictation in the nodedef by the nodename +-- mesecon:get_conductor(nodename) --> Returns the mesecons.conductor-specifictation in the nodedef by the nodename +-- mesecon:get_any_inputrules (node) --> Returns the rules of a node if it is a conductor or an effector +-- mesecon:get_any_outputrules (node) --> Returns the rules of a node if it is a conductor or a receptor --- Receptors --- Nodes that can power mesecons -function mesecon:is_receptor_node(nodename) +-- RECEPTORS +-- mesecon:is_receptor(nodename) --> Returns true if nodename is a receptor +-- mesecon:is_receptor_on(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.on +-- mesecon:is_receptor_off(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.off +-- mesecon:receptor_get_rules(node) --> Returns the rules of the receptor (mesecon.rules.default if none specified) + +-- EFFECTORS +-- mesecon:is_effector(nodename) --> Returns true if nodename is an effector +-- mesecon:is_effector_on(nodename) --> Returns true if nodename is an effector with nodedef.mesecons.effector.action_off +-- mesecon:is_effector_off(nodename) --> Returns true if nodename is an effector with nodedef.mesecons.effector.action_on +-- mesecon:effector_get_rules(node) --> Returns the input rules of the effector (mesecon.rules.default if none specified) + +-- SIGNALS +-- mesecon:activate(pos, node) --> Activates the effector node at the specific pos (calls nodedef.mesecons.effector.action_on) +-- mesecon:deactivate(pos, node) --> Deactivates the effector node at the specific pos (calls nodedef.mesecons.effector.action_off) +-- mesecon:changesignal(pos, node) --> Changes the effector node at the specific pos (calls nodedef.mesecons.effector.action_change) + +-- RULES +-- mesecon:add_rules(name, rules) | deprecated? --> Saves rules table by name +-- mesecon:get_rules(name, rules) | deprecated? --> Loads rules table with name + +-- CONDUCTORS +-- mesecon:is_conductor(nodename) --> Returns true if nodename is a conductor +-- mesecon:is_conductor_on(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.on +-- mesecon:is_conductor_off(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.off +-- mesecon:get_conductor_on(offstate) --> Returns the onstate nodename of the conductor with the name offstate +-- mesecon:get_conductor_off(onstate) --> Returns the offstate nodename of the conductor with the name onstate +-- mesecon:conductor_get_rules(node) --> Returns the input+output rules of a conductor (mesecon.rules.default if none specified) + +-- HIGH-LEVEL Internals +-- mesecon:is_power_on(pos) --> Returns true if pos emits power in any way +-- mesecon:is_power_off(pos) --> Returns true if pos does not emit power in any way +-- mesecon:turnon(pos) --> Returns true whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive +-- mesecon:turnoff(pos) --> Turns off whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive +-- mesecon:connected_to_receptor(pos) --> Returns true if pos is connected to a receptor directly or via conductors; calls itself if pos is a conductor --> recursive +-- mesecon:rules_link(output, input, dug_outputrules) --> Returns true if outputposition + outputrules = inputposition and inputposition + inputrules = outputposition (if the two positions connect) +-- mesecon:rules_link_anydir(outp., inp., d_outpr.) --> Same as rules mesecon:rules_link but also returns true if output and input are swapped +-- mesecon:is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor +-- mesecon:updatenode(pos) | deprecated --> Updates the state of pos and surroundings e.g. when newly placed by a piston + +-- RULES ROTATION helpsers +-- mesecon:rotate_rules_right(rules) +-- mesecon:rotate_rules_left(rules) +-- mesecon:rotate_rules_up(rules) +-- mesecon:rotate_rules_down(rules) +-- These functions return rules that have been rotated in the specific direction + +-- General +function mesecon:get_effector(nodename) if minetest.registered_nodes[nodename] and minetest.registered_nodes[nodename].mesecons - and minetest.registered_nodes[nodename].mesecons.receptor - and minetest.registered_nodes[nodename].mesecons.receptor.state == mesecon.state.on then - return true + and minetest.registered_nodes[nodename].mesecons.effector then + return minetest.registered_nodes[nodename].mesecons.effector end - for _, receptor in ipairs(mesecon.receptors) do - if receptor.onstate == nodename then - return true - end +end + +function mesecon:get_receptor(nodename) + if minetest.registered_nodes[nodename] + and minetest.registered_nodes[nodename].mesecons + and minetest.registered_nodes[nodename].mesecons.receptor then + return minetest.registered_nodes[nodename].mesecons.receptor + end +end + +function mesecon:get_conductor(nodename) + if minetest.registered_nodes[nodename] + and minetest.registered_nodes[nodename].mesecons + and minetest.registered_nodes[nodename].mesecons.conductor then + return minetest.registered_nodes[nodename].mesecons.conductor + end +end + +function mesecon:get_any_outputrules (node) + if mesecon:is_conductor(node.name) then + return mesecon:conductor_get_rules(node) + elseif mesecon:is_receptor(node.name) then + return mesecon:receptor_get_rules(node) end return false end -function mesecon:is_receptor_node_off(nodename, pos, ownpos) - if minetest.registered_nodes[nodename] - and minetest.registered_nodes[nodename].mesecons - and minetest.registered_nodes[nodename].mesecons.receptor - and minetest.registered_nodes[nodename].mesecons.receptor.state == mesecon.state.off then +function mesecon:get_any_inputrules (node) + if mesecon:is_conductor(node.name) then + return mesecon:conductor_get_rules(node) + elseif mesecon:is_effector(node.name) then + return mesecon:effector_get_rules(node) + end + return false +end + +-- Receptors +-- Nodes that can power mesecons +function mesecon:is_receptor_on(nodename) + local receptor = mesecon:get_receptor(nodename) + if receptor and receptor.state == mesecon.state.on then return true end - for _, receptor in ipairs(mesecon.receptors) do - if receptor.offstate == nodename then - return true - end + return false +end + +function mesecon:is_receptor_off(nodename) + local receptor = mesecon:get_receptor(nodename) + if receptor and receptor.state == mesecon.state.off then + return true + end + return false +end + +function mesecon:is_receptor(nodename) + local receptor = mesecon:get_receptor(nodename) + if receptor then + return true end return false end function mesecon:receptor_get_rules(node) - if minetest.registered_nodes[node.name].mesecons - and minetest.registered_nodes[node.name].mesecons.receptor then - local rules = minetest.registered_nodes[node.name].mesecons.receptor.rules + local receptor = mesecon:get_receptor(node.name) + if receptor then + local rules = receptor.rules if type(rules) == 'function' then return rules(node) elseif rules then return rules end end - for _, receptor in ipairs(mesecon.receptors) do --TODO - 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 - return receptor.rules - else - return mesecon:get_rules("default") - end - end - end return mesecon.rules.default end -- Effectors -- Nodes that can be powered by mesecons function mesecon:is_effector_on(nodename) - if minetest.registered_nodes[nodename] - and minetest.registered_nodes[nodename].mesecons - and minetest.registered_nodes[nodename].mesecons.effector - and minetest.registered_nodes[nodename].mesecons.effector.action_off then + local effector = mesecon:get_effector(nodename) + if effector and effector.action_off then return true end - for _, effector in ipairs(mesecon.effectors) do --TODO - if effector.onstate == nodename then - return true - end - end return false end function mesecon:is_effector_off(nodename) - if minetest.registered_nodes[nodename] - and minetest.registered_nodes[nodename].mesecons - and minetest.registered_nodes[nodename].mesecons.effector - and minetest.registered_nodes[nodename].mesecons.effector.action_on then + local effector = mesecon:get_effector(nodename) + if effector and effector.action_on then return true end - for _, effector in ipairs(mesecon.effectors) do --TODO - if effector.offstate == nodename then - return true - end - end return false end function mesecon:is_effector(nodename) - if minetest.registered_nodes[nodename] - and minetest.registered_nodes[nodename].mesecons - and minetest.registered_nodes[nodename].mesecons.effector then + local effector = mesecon:get_effector(nodename) + if effector then return true end - return mesecon:is_effector_on(nodename) or mesecon:is_effector_off(nodename) --TODO + return false end -function mesecon:effector_get_input_rules(node) - if minetest.registered_nodes[node.name].mesecons - and minetest.registered_nodes[node.name].mesecons.effector then - local rules = minetest.registered_nodes[node.name].mesecons.effector.rules +function mesecon:effector_get_rules(node) + local effector = mesecon:get_effector(node.name) + if effector then + local rules = effector.rules if type(rules) == 'function' then return rules(node) elseif rules then return rules end end - for _, effector in ipairs(mesecon.effectors) do - if effector.onstate == node.name - or effector.offstate == node.name then - if effector.get_input_rules ~= nil then - return effector.get_input_rules(node.param2) - elseif effector.input_rules ~=nil then - return effector.input_rules - else - return mesecon:get_rules("default") - end - end - end return mesecon.rules.default end --Signals function mesecon:activate(pos, node) - if minetest.registered_nodes[node.name] - and minetest.registered_nodes[node.name].mesecons - and minetest.registered_nodes[node.name].mesecons.effector - and minetest.registered_nodes[node.name].mesecons.effector.action_on then - minetest.registered_nodes[node.name].mesecons.effector.action_on (pos, node) - end - for _, action in ipairs(mesecon.actions_on) do --TODO - action(pos, node) + local effector = mesecon:get_effector(node.name) + if effector and effector.action_on then + effector.action_on (pos, node) end end -function mesecon:deactivate(pos, node) --TODO - if minetest.registered_nodes[node.name] - and minetest.registered_nodes[node.name].mesecons - and minetest.registered_nodes[node.name].mesecons.effector - and minetest.registered_nodes[node.name].mesecons.effector.action_off then - minetest.registered_nodes[node.name].mesecons.effector.action_off(pos, node) - end - for _, action in ipairs(mesecon.actions_off) do - action(pos, node) +function mesecon:deactivate(pos, node) + local effector = mesecon:get_effector(node.name) + if effector and effector.action_off then + effector.action_off (pos, node) end end -function mesecon:changesignal(pos, node) --TODO - if minetest.registered_nodes[node.name] - and minetest.registered_nodes[node.name].mesecons - and minetest.registered_nodes[node.name].mesecons.effector - and minetest.registered_nodes[node.name].mesecons.effector.action_change then - minetest.registered_nodes[node.name].mesecons.effector.action_change(pos, node) - end - for _, action in ipairs(mesecon.actions_change) do - action(pos, node) +function mesecon:changesignal(pos, node) + local effector = mesecon:get_effector(node.name) + if effector and effector.action_change then + effector.action_change (pos, node) end end @@ -172,97 +212,64 @@ end -- Conductors -function mesecon:get_conductor_on(offstate) - if minetest.registered_nodes[offstate] - and minetest.registered_nodes[offstate].mesecons - and minetest.registered_nodes[offstate].mesecons.conductor then - return minetest.registered_nodes[offstate].mesecons.conductor.onstate - end - for _, conductor in ipairs(mesecon.conductors) do --TODO - if conductor.offstate == offstate then - return conductor.onstate - end - end - return false -end - -function mesecon:get_conductor_off(onstate) - if minetest.registered_nodes[onstate] - and minetest.registered_nodes[onstate].mesecons - and minetest.registered_nodes[onstate].mesecons.conductor then - return minetest.registered_nodes[onstate].mesecons.conductor.offstate - end - for _, conductor in ipairs(mesecon.conductors) do --TODO - if conductor.onstate == onstate then - return conductor.offstate - end - end - return false -end - function mesecon:is_conductor_on(nodename) - if minetest.registered_nodes[nodename] - and minetest.registered_nodes[nodename].mesecons - and minetest.registered_nodes[nodename].mesecons.conductor - and minetest.registered_nodes[nodename].mesecons.conductor.state == mesecon.state.on then + local conductor = mesecon:get_conductor(nodename) + if conductor and conductor.state == mesecon.state.on then return true end - for _, conductor in ipairs(mesecon.conductors) do --TODO - if conductor.onstate == nodename then - return true - end - end return false end function mesecon:is_conductor_off(nodename) - if minetest.registered_nodes[nodename] - and minetest.registered_nodes[nodename].mesecons - and minetest.registered_nodes[nodename].mesecons.conductor - and minetest.registered_nodes[nodename].mesecons.conductor.state == mesecon.state.off then + local conductor = mesecon:get_conductor(nodename) + if conductor and conductor.state == mesecon.state.off then return true end - for _, conductor in ipairs(mesecon.conductors) do --TODO - if conductor.offstate == nodename then - return true - end - end return false end function mesecon:is_conductor(nodename) - --TODO - return mesecon:is_conductor_on(nodename) or mesecon:is_conductor_off(nodename) + local conductor = mesecon:get_conductor(nodename) + if conductor then + return true + end + return false +end + +function mesecon:get_conductor_on(offstate) + local conductor = mesecon:get_conductor(offstate) + if conductor then + return conductor.onstate + end + return false +end + +function mesecon:get_conductor_off(onstate) + local conductor = mesecon:get_conductor(onstate) + if conductor then + return conductor.offstate + end + return false end function mesecon:conductor_get_rules(node) - if minetest.registered_nodes[node.name] - and minetest.registered_nodes[node.name].mesecons - and minetest.registered_nodes[node.name].mesecons.conductor then - local rules = minetest.registered_nodes[node.name].mesecons.conductor.rules + local conductor = mesecon:get_conductor(node.name) + if conductor then + local rules = conductor.rules if type(rules) == 'function' then return rules(node) elseif rules then return rules end end - for _, conductor in ipairs(mesecon.conductors) do --TODO - if conductor.onstate == node.name - or conductor.offstate == node.name then - if conductor.get_rules ~= nil then - return conductor.get_rules(node.param2) - else - return conductor.rules - end - end - end return mesecon.rules.default end --- +-- some more general high-level stuff + function mesecon:is_power_on(pos) local node = minetest.env:get_node(pos) - if mesecon:is_conductor_on(node.name) or mesecon:is_receptor_node(node.name) then + if mesecon:is_conductor_on(node.name) or mesecon:is_receptor_on(node.name) then return true end return false @@ -270,7 +277,7 @@ end function mesecon:is_power_off(pos) local node = minetest.env:get_node(pos) - if mesecon:is_conductor_off(node.name) or mesecon:is_receptor_node_off(node.name) then + if mesecon:is_conductor_off(node.name) or mesecon:is_receptor_off(node.name) then return true end return false @@ -326,69 +333,57 @@ function mesecon:turnoff(pos) end -function mesecon:connected_to_pw_src(pos, checked) - local c = 1 +function mesecon:connected_to_receptor(pos, checked) checked = checked or {} - while checked[c] ~= nil do --find out if node has already been checked (to prevent from endless loop) - if mesecon:cmpPos(checked[c], pos) then + + -- find out if node has already been checked (to prevent from endless loop) + for _, cp in ipairs(checked) do + if mesecon:cmpPos(cp, pos) then return false, checked end - c = c + 1 - end - checked[c] = {x=pos.x, y=pos.y, z=pos.z} --add current node to checked - - local node = minetest.env:get_node_or_nil(pos) - if node == nil then return false, checked end - if not mesecon:is_conductor(node.name) then return false, checked end - if mesecon:is_powered_by_receptor(pos) then --return if conductor is powered - return true, checked end - --Check if conductors around are connected - local connected - local rules = mesecon:conductor_get_rules(node) + -- add current position to checked + table.insert(checked, {x=pos.x, y=pos.y, z=pos.z}) - for _, rule in ipairs(rules) do - local np = mesecon:addPosRule(pos, rule) - if mesecon:rules_link(pos, np) then - connected, checked = mesecon:connected_to_pw_src(np, checked) - if connected then - return true + local node = minetest.env:get_node(pos) + + if mesecon:is_conductor(node.name) then + -- Check if conductors around are connected + local rules = mesecon:conductor_get_rules(node) + + for _, rule in ipairs(rules) do + local np = mesecon:addPosRule(pos, rule) + if mesecon:rules_link(np, pos) then + connected, checked = mesecon:connected_to_receptor(np, checked) + if connected then + return true + end end end + elseif mesecon:is_receptor_on(node.name) then + return true end + return false, checked end function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug) local outputnode = minetest.env:get_node(output) local inputnode = minetest.env:get_node(input) - local outputrules = dug_outputrules - local inputrules + local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode) + local inputrules = mesecon:get_any_inputrules (inputnode) - if outputrules == nil then - if mesecon:is_conductor(outputnode.name) then - outputrules = mesecon:conductor_get_rules(outputnode) - elseif mesecon:is_receptor_node(outputnode.name) or mesecon:is_receptor_node_off(outputnode.name) then - outputrules = mesecon:receptor_get_rules(outputnode) - else - return false - end + if not outputrules or not inputrules then + return end - if mesecon:is_conductor(inputnode.name) then - inputrules = mesecon:conductor_get_rules(inputnode) - elseif mesecon:is_effector(inputnode.name) then - inputrules = mesecon:effector_get_input_rules(inputnode) - else - return false - end - - for _, outputrule in ipairs(outputrules) do - if mesecon:cmpPos(mesecon:addPosRule(output, outputrule), input) then -- Check if output sends to input + -- Check if output sends to input + if mesecon:cmpPos(mesecon:addPosRule(output, outputrule), input) then for _, inputrule in ipairs(inputrules) do - if mesecon:cmpPos(mesecon:addPosRule(input, inputrule), output) then --Check if input accepts from output + -- Check if input accepts from output + if mesecon:cmpPos(mesecon:addPosRule(input, inputrule), output) then return true end end @@ -397,82 +392,34 @@ function mesecon:rules_link(output, input, dug_outputrules) --output/input are p return false end -function mesecon:rules_link_bothdir(pos1, pos2) +function mesecon:rules_link_anydir(pos1, pos2) return mesecon:rules_link(pos1, pos2) or mesecon:rules_link(pos2, pos1) end -function mesecon:is_powered_by_conductor(pos) - local j = 1 - local k = 1 - - local rules - local con_pos = {} - local con_rules = {} - local con_node - - local node = minetest.env:get_node(pos) - if mesecon:is_conductor(node.name) then - rules = mesecon:conductor_get_rules(node) - elseif mesecon:is_effector(node.name) then - rules = mesecon:effector_get_input_rules(node) - else - return false - end - - for _, rule in ipairs(rules) do - local con_pos = mesecon:addPosRule(pos, rule) - - con_node = minetest.env:get_node(con_pos) - - if mesecon:is_conductor_on(con_node.name) and mesecon:rules_link(con_pos, pos) then - return true - end - end - - return false -end - -function mesecon:is_powered_by_receptor(pos) - local j = 1 - local k = 1 - - local rules - local rcpt_pos = {} - local rcpt_rules = {} - local rcpt_node - - local node = minetest.env:get_node(pos) - if mesecon:is_conductor(node.name) then - rules = mesecon:conductor_get_rules(node) - elseif mesecon:is_effector(node.name) then - rules = mesecon:effector_get_input_rules(node) - else - return false - end - - for _, rule in ipairs(rules) do - local rcpt_pos = mesecon:addPosRule(pos, rule) - - rcpt_node = minetest.env:get_node(rcpt_pos) - - if mesecon:is_receptor_node(rcpt_node.name) and mesecon:rules_link(rcpt_pos, pos) then - return true - end - end - - return false -end - function mesecon:is_powered(pos) - return mesecon:is_powered_by_conductor(pos) or mesecon:is_powered_by_receptor(pos) + local node = minetest.env:get_node(pos) + local rules = mesecon:get_any_inputrules(node) + if not rules then return false end + + for _, rule in ipairs(rules) do + local np = mesecon:addPosRule(pos, rule) + local nn = minetest.env:get_node(np) + + if (mesecon:is_conductor_on (nn.name) or mesecon:is_receptor_on (nn.name)) + and mesecon:rules_link(np, pos) then + return true + end + end + + return false end function mesecon:updatenode(pos) - if mesecon:connected_to_pw_src(pos) then - mesecon:turnon(pos) - else - mesecon:turnoff(pos) - end + if mesecon:is_powered(pos) then + mesecon:turnon(pos) + else + mesecon:turnoff(pos) + end end --Rules rotation Functions: diff --git a/mesecons/legacy.lua b/mesecons/legacy.lua index 947c100..e69de29 100644 --- a/mesecons/legacy.lua +++ b/mesecons/legacy.lua @@ -1,60 +0,0 @@ ---very old: - -function mesecon:add_receptor_node(name, rules, get_rules) - if get_rules==nil and rules==nil then - rules=mesecon:get_rules("default") - end - table.insert(mesecon.receptors, {onstate = name, rules = rules, get_rules = get_rules}) -end - -function mesecon:add_receptor_node_off(name, rules, get_rules) - if get_rules==nil and rules==nil then - rules=mesecon:get_rules("default") - end - table.insert(mesecon.receptors, {offstate = name, rules = rules, get_rules = get_rules}) -end - ---old: - -function mesecon:register_receptor(onstate, offstate, rules, get_rules) - if get_rules == nil and rules == nil then - rules=mesecon:get_rules("default") - end - table.insert(mesecon.receptors, - {onstate = onstate, - offstate = offstate, - rules = input_rules, - get_rules = get_rules}) -end - -function mesecon:register_effector(onstate, offstate, input_rules, get_input_rules) - if get_input_rules==nil and input_rules==nil then - rules=mesecon:get_rules("default") - end - table.insert(mesecon.effectors, - {onstate = onstate, - offstate = offstate, - input_rules = input_rules, - get_input_rules = get_input_rules}) -end - -function mesecon:register_on_signal_on(action) - table.insert(mesecon.actions_on, action) -end - -function mesecon:register_on_signal_off(action) - table.insert(mesecon.actions_off, action) -end - -function mesecon:register_on_signal_change(action) - table.insert(mesecon.actions_change, action) -end - -function mesecon:register_conductor (onstate, offstate, rules, get_rules) - if rules == nil then - rules = mesecon:get_rules("default") - end - table.insert(mesecon.conductors, {onstate = onstate, offstate = offstate, rules = rules, get_rules = get_rules}) -end - -mesecon:add_rules("default", mesecon.rules.default) diff --git a/mesecons/oldwires.lua b/mesecons/oldwires.lua new file mode 100644 index 0000000..e9960d3 --- /dev/null +++ b/mesecons/oldwires.lua @@ -0,0 +1,38 @@ +minetest.register_node("mesecons:mesecon_off", { + drawtype = "raillike", + tiles = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"}, + inventory_image = "jeija_mesecon_off.png", + wield_image = "jeija_mesecon_off.png", + paramtype = "light", + is_ground_content = true, + walkable = false, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}, + }, + groups = {dig_immediate=3, mesecon=1, mesecon_conductor_craftable=1}, + description="Mesecons", + mesecons = {conductor={ + state = mesecon.state.off, + onstate = "mesecons:mesecon_on" + }} +}) + +minetest.register_node("mesecons:mesecon_on", { + drawtype = "raillike", + tiles = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"}, + paramtype = "light", + is_ground_content = true, + walkable = false, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}, + }, + groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1}, + drop = '"mesecons:mesecon_off" 1', + light_source = LIGHT_MAX-11, + mesecons = {conductor={ + state = mesecon.state.on, + offstate = "mesecons:mesecon_off" + }} +}) diff --git a/mesecons/services.lua b/mesecons/services.lua index 27900b1..c82e06b 100644 --- a/mesecons/services.lua +++ b/mesecons/services.lua @@ -1,28 +1,23 @@ -minetest.register_on_dignode( - function(pos, oldnode, digger) - if mesecon:is_conductor_on(oldnode.name) then - mesecon:receptor_off(pos) - end - - if mesecon:is_receptor_node(oldnode.name) then - mesecon:receptor_off(pos, mesecon:receptor_get_rules(oldnode)) +mesecon.on_placenode = function (pos, node) + if mesecon:is_receptor_on(node.name) then + mesecon:receptor_on(pos, mesecon:receptor_get_rules(node)) + elseif mesecon:is_powered(pos) then + if mesecon:is_conductor_off(node.name) then + mesecon:turnon(pos, node) + else + mesecon:changesignal(pos, node) + mesecon:activate(pos, node) end end -) +end -minetest.register_on_placenode( - function (pos, node) - if mesecon:is_receptor_node(node.name) then - mesecon:receptor_on(pos, mesecon:receptor_get_rules(node)) - end - - if mesecon:is_powered(pos) then - if mesecon:is_conductor_off(node.name) then - mesecon:turnon(pos, node) - else - mesecon:changesignal(pos, node) - mesecon:activate(pos, node) - end - end +mesecon.on_dignode = function (pos, node) + if mesecon:is_conductor_on(node.name) then + mesecon:receptor_off(pos) + elseif mesecon:is_receptor_on(node.name) then + mesecon:receptor_off(pos, mesecon:receptor_get_rules(node)) end -) +end + +minetest.register_on_placenode(mesecon.on_placenode) +minetest.register_on_dignode(mesecon.on_dignode) diff --git a/mesecons/wires.lua b/mesecons/wires.lua index bea84dd..f5c0f3b 100644 --- a/mesecons/wires.lua +++ b/mesecons/wires.lua @@ -1,39 +1,3 @@ --- Oldstyle wires: - -if NEW_STYLE_WIRES == false then --old wires -minetest.register_node("mesecons:mesecon_off", { - drawtype = "raillike", - tiles = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"}, - inventory_image = "jeija_mesecon_off.png", - wield_image = "jeija_mesecon_off.png", - paramtype = "light", - is_ground_content = true, - walkable = false, - selection_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}, - }, - groups = {dig_immediate=3, mesecon=1, mesecon_conductor_craftable=1}, - description="Mesecons", -}) - -minetest.register_node("mesecons:mesecon_on", { - drawtype = "raillike", - tiles = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"}, - paramtype = "light", - is_ground_content = true, - walkable = false, - selection_box = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5}, - }, - groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1}, - drop = '"mesecons:mesecon_off" 1', - light_source = LIGHT_MAX-11, -}) -mesecon:register_conductor("mesecons:mesecon_on", "mesecons:mesecon_off") -else -- NEW STYLE WIRES - -- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off -- The conditions in brackets define whether there is a mesecon at that place or not -- 1 = there is one; 0 = there is none @@ -52,6 +16,8 @@ box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5} box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16} box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16} +-- Registering the wires + for xp=0, 1 do for zp=0, 1 do for xm=0, 1 do @@ -191,6 +157,9 @@ end end end +-- Updating the wires: +-- Place the right connection wire + local update_on_place_dig = function (pos, node) if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].mesecons then @@ -237,38 +206,21 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old) nodename = minetest.env:get_node(pos).name if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end - if mesecon:rules_link_bothdir(pos, xppos) then xp = 1 else xp = 0 end - if mesecon:rules_link_bothdir(pos, xmpos) then xm = 1 else xm = 0 end - if mesecon:rules_link_bothdir(pos, zppos) then zp = 1 else zp = 0 end - if mesecon:rules_link_bothdir(pos, zmpos) then zm = 1 else zm = 0 end + if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end + if mesecon:rules_link_anydir(pos, xmpos) then xm = 1 else xm = 0 end + if mesecon:rules_link_anydir(pos, zppos) then zp = 1 else zp = 0 end + if mesecon:rules_link_anydir(pos, zmpos) then zm = 1 else zm = 0 end - if mesecon:rules_link_bothdir(pos, xpympos) then xp = 1 end - if mesecon:rules_link_bothdir(pos, xmympos) then xm = 1 end - if mesecon:rules_link_bothdir(pos, zpympos) then zp = 1 end - if mesecon:rules_link_bothdir(pos, zmympos) then zm = 1 end + if mesecon:rules_link_anydir(pos, xpympos) then xp = 1 end + if mesecon:rules_link_anydir(pos, xmympos) then xm = 1 end + if mesecon:rules_link_anydir(pos, zpympos) then zp = 1 end + if mesecon:rules_link_anydir(pos, zmympos) then zm = 1 end if mesecon:rules_link(pos, xpypos) then xpy = 1 else xpy = 0 end if mesecon:rules_link(pos, zpypos) then zpy = 1 else zpy = 0 end if mesecon:rules_link(pos, xmypos) then xmy = 1 else xmy = 0 end if mesecon:rules_link(pos, zmypos) then zmy = 1 else zmy = 0 end - -- Backward compatibility - if replace_old then - xp = (xp == 1 or (string.find(minetest.env:get_node(xppos ).name, "mesecons:mesecon_") ~= nil or - string.find(minetest.env:get_node(xpympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0 - zp = (zp == 1 or (string.find(minetest.env:get_node(zppos ).name, "mesecons:mesecon_") ~= nil or - string.find(minetest.env:get_node(zpympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0 - xm = (xm == 1 or (string.find(minetest.env:get_node(xmpos ).name, "mesecons:mesecon_") ~= nil or - string.find(minetest.env:get_node(xmympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0 - zm = (zm == 1 or (string.find(minetest.env:get_node(zmpos ).name, "mesecons:mesecon_") ~= nil or - string.find(minetest.env:get_node(zmympos).name, "mesecons:mesecon_") ~= nil)) and 1 or 0 - - xpy = (xpy == 1 or string.find(minetest.env:get_node(xpypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0 - zpy = (zpy == 1 or string.find(minetest.env:get_node(zpypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0 - xmy = (xmy == 1 or string.find(minetest.env:get_node(xmypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0 - zmy = (zmy == 1 or string.find(minetest.env:get_node(zmypos).name, "mesecons:mesecon_") ~=nil) and 1 or 0 - end - if xpy == 1 then xp = 1 end if zpy == 1 then zp = 1 end if xmy == 1 then xm = 1 end @@ -291,13 +243,3 @@ minetest.register_craft({ {'"default:mese"'}, } }) - -minetest.register_abm( - {nodenames = {"mesecons:mesecon_off", "mesecons:mesecon_on"}, - interval = 2, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - mesecon:update_autoconnect(pos, false, true) - end, -}) -end diff --git a/mesecons_extrawires/vertical.lua b/mesecons_extrawires/vertical.lua index 64e6e80..652205d 100644 --- a/mesecons_extrawires/vertical.lua +++ b/mesecons_extrawires/vertical.lua @@ -78,7 +78,7 @@ minetest.register_node("mesecons_extrawires:vertical_on", { walkable = false, paramtype = "light", sunlight_propagates = true, - groups = {dig_immediate = 3}, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, selection_box = vbox, node_box = vbox, is_vertical_conductor = true, @@ -118,11 +118,11 @@ minetest.register_node("mesecons_extrawires:vertical_off", { minetest.register_node("mesecons_extrawires:vertical_top_on", { description = "Vertical mesecon", drawtype = "nodebox", - tiles = {"wires_vertical_on.png"}, + tiles = {"wires_full_on.png"}, walkable = false, paramtype = "light", sunlight_propagates = true, - groups = {dig_immediate = 3}, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, selection_box = tbox, node_box = tbox, is_vertical_conductor = true, @@ -140,11 +140,11 @@ minetest.register_node("mesecons_extrawires:vertical_top_on", { minetest.register_node("mesecons_extrawires:vertical_top_off", { description = "Vertical mesecon", drawtype = "nodebox", - tiles = {"wires_vertical_off.png"}, + tiles = {"wires_full_off.png"}, walkable = false, paramtype = "light", sunlight_propagates = true, - groups = {dig_immediate = 3}, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, selection_box = tbox, node_box = tbox, is_vertical_conductor = true, @@ -163,12 +163,12 @@ minetest.register_node("mesecons_extrawires:vertical_top_off", { minetest.register_node("mesecons_extrawires:vertical_bottom_on", { description = "Vertical mesecon", drawtype = "nodebox", - tiles = {"wires_vertical_on.png"}, + tiles = {"wires_full_on.png"}, walkable = false, paramtype = "light", sunlight_propagates = true, vertical_conductor_state = "on", - groups = {dig_immediate = 3}, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, selection_box = bbox, node_box = bbox, mesecons = {conductor = { @@ -184,11 +184,11 @@ minetest.register_node("mesecons_extrawires:vertical_bottom_on", { minetest.register_node("mesecons_extrawires:vertical_bottom_off", { description = "Vertical mesecon", drawtype = "nodebox", - tiles = {"wires_vertical_off.png"}, + tiles = {"wires_full_off.png"}, walkable = false, paramtype = "light", sunlight_propagates = true, - groups = {dig_immediate = 3}, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, selection_box = bbox, node_box = bbox, is_vertical_conductor = true, diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index dd3f599..3971e19 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -247,5 +247,8 @@ function mesecon:piston_get_direction(node) end end -dofile(minetest.get_modpath("mesecons_pistons").."/pistons_down.lua") -dofile(minetest.get_modpath("mesecons_pistons").."/pistons_up.lua") +-- dofile(minetest.get_modpath("mesecons_pistons").."/pistons_down.lua") +-- dofile(minetest.get_modpath("mesecons_pistons").."/pistons_up.lua") +-- Dropped +-- We need a better way to have these piston types +-- There should be a facedir for vertical orientations diff --git a/mesecons_textures/textures/wires_full_off.png b/mesecons_textures/textures/wires_full_off.png new file mode 100644 index 0000000000000000000000000000000000000000..58164fa2680d22b2f680492fdf92f11fb5cf2e7c GIT binary patch literal 465 zcmV;?0WSWDP)HAlqT)hN9y`y;bGc|N6{Gdi8=m5}j%2LikrPZnJ9`yH1v zJvS4J80;K_FOBmJyz+d0GrUW+k8tea6Q#DIMd zZ00WbcEP)tY{s1jP!-&Rx~@U30>HXD%L26uwMu7I?tIH_#R8<&9 zd8lx6`{{7!q19y^1)Zh>$hE;d8@p@#?4`$b+oC7EycE_oNO#M(9$=aZ^K8h^&nc`q zet-Qskz%%Ue(8aJ!F1aK5fFh|L8SfZmLI(cJ=S@4N@+8?!{1+!E;%obYTFWM&r!4J zg%J_Pv5+oVL^vE2h~8(8PLp!Ecz+9KPP$~(d|c7{%+XSW2rvuY-YOuZQ*A3V^QR-- zHZXJQ*Ow6iA0Gp%!ttnler{J+ac}i$dlt;vC3=5vZ{i Date: Sat, 15 Dec 2012 21:21:54 +0100 Subject: [PATCH 03/28] Bugfix, param2 for conductors --- mesecons/internal.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index ea21522..419a337 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -288,7 +288,7 @@ function mesecon:turnon(pos) if mesecon:is_conductor_off(node.name) then local rules = mesecon:conductor_get_rules(node) - minetest.env:add_node(pos, {name = mesecon:get_conductor_on(node.name)}) + minetest.env:add_node(pos, {name = mesecon:get_conductor_on(node.name), param2 = node.param2}) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) @@ -312,7 +312,7 @@ function mesecon:turnoff(pos) if mesecon:is_conductor_on(node.name) then local rules = mesecon:conductor_get_rules(node) - minetest.env:add_node(pos, {name = mesecon:get_conductor_off(node.name)}) + minetest.env:add_node(pos, {name = mesecon:get_conductor_off(node.name), param2 = node.param2}) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) From a1852204fbc2bd056f3286f316c94076d5fd7e2b Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 16 Dec 2012 11:58:43 +0100 Subject: [PATCH 04/28] Cleanup and improve piston code --- mesecons/internal.lua | 8 +--- mesecons/services.lua | 4 ++ mesecons/util.lua | 9 ++++ mesecons/wires.lua | 8 ++-- mesecons_pistons/init.lua | 87 ++++++++++++++++++++++----------------- 5 files changed, 69 insertions(+), 47 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 419a337..bde0593 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -297,9 +297,7 @@ function mesecon:turnon(pos) mesecon:turnon(np) end end - end - - if mesecon:is_effector(node.name) then + elseif mesecon:is_effector(node.name) then mesecon:changesignal(pos, node) if mesecon:is_effector_off(node.name) then mesecon:activate(pos, node) @@ -321,9 +319,7 @@ function mesecon:turnoff(pos) mesecon:turnoff(np) end end - end - - if mesecon:is_effector(node.name) then + elseif mesecon:is_effector(node.name) then mesecon:changesignal(pos, node) if mesecon:is_effector_on(node.name) and not mesecon:is_powered(pos) then diff --git a/mesecons/services.lua b/mesecons/services.lua index c82e06b..ada9351 100644 --- a/mesecons/services.lua +++ b/mesecons/services.lua @@ -8,6 +8,10 @@ mesecon.on_placenode = function (pos, node) mesecon:changesignal(pos, node) mesecon:activate(pos, node) end + elseif mesecon:is_conductor_on(node.name) then + mesecon:swap_node(pos, mesecon:get_conductor_off(node.name)) + elseif mesecon:is_effector_on (node.name) then + mesecon:deactivate(pos, node) end end diff --git a/mesecons/util.lua b/mesecons/util.lua index b95cf6e..2871c0a 100644 --- a/mesecons/util.lua +++ b/mesecons/util.lua @@ -6,6 +6,15 @@ function mesecon:swap_node(pos, name) minetest.env:get_meta(pos):from_table(data) end +function mesecon:move_node(pos, newpos) + local node = minetest.env:get_node(pos) + local meta = minetest.env:get_meta(pos):to_table() + minetest.env:remove_node(pos) + minetest.env:add_node(newpos, node) + minetest.env:get_meta(pos):from_table(meta) +end + + function mesecon:addPosRule(p, r) return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z} end diff --git a/mesecons/wires.lua b/mesecons/wires.lua index f5c0f3b..6c5f6ef 100644 --- a/mesecons/wires.lua +++ b/mesecons/wires.lua @@ -216,10 +216,10 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old) if mesecon:rules_link_anydir(pos, zpympos) then zp = 1 end if mesecon:rules_link_anydir(pos, zmympos) then zm = 1 end - if mesecon:rules_link(pos, xpypos) then xpy = 1 else xpy = 0 end - if mesecon:rules_link(pos, zpypos) then zpy = 1 else zpy = 0 end - if mesecon:rules_link(pos, xmypos) then xmy = 1 else xmy = 0 end - if mesecon:rules_link(pos, zmypos) then zmy = 1 else zmy = 0 end + if mesecon:rules_link_anydir(pos, xpypos) then xpy = 1 else xpy = 0 end + if mesecon:rules_link_anydir(pos, zpypos) then zpy = 1 else zpy = 0 end + if mesecon:rules_link_anydir(pos, xmypos) then xmy = 1 else xmy = 0 end + if mesecon:rules_link_anydir(pos, zmypos) then zmy = 1 else zmy = 0 end if xpy == 1 then xp = 1 end if zpy == 1 then zp = 1 end diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 0eb2b6e..92dbd32 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -1,5 +1,25 @@ --PISTONS +-- Get mesecon rules of pistons +piston_rules = +{{x=0, y=0, z=1}, --everything apart from z- (pusher side) + {x=1, y=0, z=0}, + {x=-1, y=0, z=0}, + {x=1, y=1, z=0}, + {x=1, y=-1, z=0}, + {x=-1, y=1, z=0}, + {x=-1, y=-1, z=0}, + {x=0, y=1, z=1}, + {x=0, y=-1, z=1}} + +local piston_get_rules = function (node) + local rules = piston_rules + for i = 1, node.param2 do + rules = mesecon:rotate_rules_left(rules) + end + return rules +end + --starts the timer to make the piston update to its new state local update = function(pos, node) local timer = minetest.env:get_node_timer(pos) @@ -44,11 +64,12 @@ end function mesecon:piston_push(pos) local node = minetest.env:get_node(pos) local dir = mesecon:piston_get_direction(node) - pos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to first node being pushed + pos = addPosRule(pos, dir) --move to first node being pushed --determine the number of nodes that need to be pushed local count = 0 local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed + while true do local checknode = minetest.env:get_node(checkpos) @@ -69,10 +90,13 @@ function mesecon:piston_push(pos) return end - checkpos.x, checkpos.y, checkpos.z = checkpos.x + dir.x, checkpos.y + dir.y, checkpos.z + dir.z + checkpos = addPosRule(checkpos, dir) end - local checknode = minetest.env:get_node(pos) + local thisnode = minetest.env:get_node(pos) + minetest.env:remove_node(pos) + mesecon.on_dignode(pos, thisnode) + local nextnode --add pusher if node.name == "mesecons_pistons:piston_normal" then @@ -91,25 +115,15 @@ function mesecon:piston_push(pos) --move nodes forward for i = 1, count do - pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to the next node + pos = addPosRule(pos, dir) --move to the next node - --check for conductor --wip: not sure if still needed - if mesecon:is_conductor_on(checknode.name) then - checknode.name = mesecon:get_conductor_off(checknode.name) - end - - --move the node forward - local nextnode = minetest.env:get_node(pos) - minetest.env:add_node(pos, checknode) - checknode = nextnode - end - - --update nodes - for i = 1, count do - mesecon:updatenode(pos) + nextnode = minetest.env:get_node(pos) + minetest.env:remove_node(pos) + mesecon.on_dignode(pos, thisnode) + minetest.env:add_node(pos, thisnode) + mesecon.on_placenode(pos, thisnode) + thisnode = nextnode nodeupdate(pos) - - pos.x, pos.y, pos.z = pos.x - dir.x, pos.y - dir.y, pos.z - dir.z --move to the previous node end end @@ -140,23 +154,17 @@ function mesecon:piston_pull(pos) --retract piston minetest.env:remove_node(pos) --remove pusher - if node.name == "mesecons_pistons:piston_sticky" - or node.name == "mesecons_pistons:piston_up_sticky" - or node.name == "mesecons_pistons:piston_down_sticky" then --retract block if piston is sticky - local checkpos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to the node to be retracted - checknode = minetest.env:get_node(checkpos) - if checknode.name ~= "air" - and checknode.name ~= "ignore" - and minetest.registered_nodes[checknode.name].liquidtype == "none" - and not mesecon:is_mvps_stopper(checknode.name) then - minetest.env:add_node(pos, checknode) - minetest.env:remove_node(checkpos) - mesecon:updatenode(checkpos) - nodeupdate(checkpos) + if minetest.registered_nodes[node.name].is_sticky_piston then --retract block if piston is sticky + local retractpos = addPosRule(pos, dir) --move to the node to be retracted + local retractnode = minetest.env:get_node(retractpos) + if minetest.registered_nodes[retractnode.name].liquidtype == "none" + and not mesecon:is_mvps_stopper(retractnode.name) then + mesecon:move_node(retractpos, pos) + mesecon.on_dignode(retractpos, retractnode) + mesecon.on_placenode(pos, retractnode) + nodeupdate(pos) end end - mesecon:updatenode(pos) - nodeupdate(pos) end --push direction of a piston @@ -208,7 +216,8 @@ minetest.register_node("mesecons_pistons:piston_normal", { return minetest.item_place(itemstack, placer, pointed_thing) --place piston normally end, mesecons = {effector={ - action_change = update + action_change = update, + rules = piston_get_rules }} }) @@ -219,6 +228,7 @@ minetest.register_node("mesecons_pistons:piston_sticky", { paramtype2 = "facedir", after_destruct = destruct, on_timer = timer, + is_sticky_piston = true, on_place = function(itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then --can be placed only on nodes return itemstack @@ -243,7 +253,8 @@ minetest.register_node("mesecons_pistons:piston_sticky", { return minetest.item_place(itemstack, placer, pointed_thing) --place piston normally end, mesecons = {effector={ - action_change = update + action_change = update, + rules = piston_get_rules }} }) @@ -307,6 +318,7 @@ minetest.register_node("mesecons_pistons:piston_up_normal", { groups = {cracky=3, mesecon=2}, after_destruct = destruct, on_timer = timer, + is_sticky_piston = true, mesecons = {effector={ action_change = update }}, @@ -393,6 +405,7 @@ minetest.register_node("mesecons_pistons:piston_down_sticky", { groups = {cracky=3, mesecon=2}, after_destruct = destruct, on_timer = timer, + is_sticky_piston = true, mesecons = {effector={ action_change = update }}, From c76c274cc01c1c3b04c247604d7c0c933ab4e7a6 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 16 Dec 2012 12:00:11 +0100 Subject: [PATCH 05/28] Remove mesecons:updatenode --- mesecons/internal.lua | 9 --------- 1 file changed, 9 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index bde0593..e9cde2d 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -47,7 +47,6 @@ -- mesecon:rules_link(output, input, dug_outputrules) --> Returns true if outputposition + outputrules = inputposition and inputposition + inputrules = outputposition (if the two positions connect) -- mesecon:rules_link_anydir(outp., inp., d_outpr.) --> Same as rules mesecon:rules_link but also returns true if output and input are swapped -- mesecon:is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor --- mesecon:updatenode(pos) | deprecated --> Updates the state of pos and surroundings e.g. when newly placed by a piston -- RULES ROTATION helpsers -- mesecon:rotate_rules_right(rules) @@ -410,14 +409,6 @@ function mesecon:is_powered(pos) return false end -function mesecon:updatenode(pos) - if mesecon:is_powered(pos) then - mesecon:turnon(pos) - else - mesecon:turnoff(pos) - end -end - --Rules rotation Functions: function mesecon:rotate_rules_right(rules) local nr={}; From 2c4a46a5572e9f633faba97a52d2245d17930db4 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 16 Dec 2012 16:29:03 +0100 Subject: [PATCH 06/28] Minor cleanup, use addPosRule --- mesecons/init.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mesecons/init.lua b/mesecons/init.lua index 0af53f1..900d4bb 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -79,10 +79,7 @@ function mesecon:receptor_on(pos, rules) rules = rules or mesecon.rules.default for _, rule in ipairs(rules) do - local np = { - x = pos.x + rule.x, - y = pos.y + rule.y, - z = pos.z + rule.z} + local np = mesecon:addPosRule(pos, rule) if mesecon:rules_link(pos, np, rules) then mesecon:turnon(np, pos) end @@ -93,10 +90,7 @@ function mesecon:receptor_off(pos, rules) rules = rules or mesecon.rules.default for _, rule in ipairs(rules) do - local np = { - x = pos.x + rule.x, - y = pos.y + rule.y, - z = pos.z + rule.z} + local np = mesecon:addPosRule(pos, rule) if mesecon:rules_link(pos, np, rules) and not mesecon:connected_to_receptor(np) then mesecon:turnoff(np, pos) end From 6b1bfe6391a67471d5a1870c9f3778f1c8bd1353 Mon Sep 17 00:00:00 2001 From: Jeija Date: Wed, 19 Dec 2012 17:34:05 +0100 Subject: [PATCH 07/28] Add rule-name system. Every input rule can now have a name, that could help e.g. the microcontroller to know where a signal comes from. --- mesecons/init.lua | 10 ++++--- mesecons/internal.lua | 43 ++++++++++++++++--------------- mesecons_microcontroller/init.lua | 10 +++---- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/mesecons/init.lua b/mesecons/init.lua index 900d4bb..6378946 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -80,8 +80,9 @@ function mesecon:receptor_on(pos, rules) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) - if mesecon:rules_link(pos, np, rules) then - mesecon:turnon(np, pos) + local link, rulename = mesecon:rules_link(pos, np, rules) + if link then + mesecon:turnon(np, rulename) end end end @@ -91,8 +92,9 @@ function mesecon:receptor_off(pos, rules) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) - if mesecon:rules_link(pos, np, rules) and not mesecon:connected_to_receptor(np) then - mesecon:turnoff(np, pos) + local link, rulename = mesecon:rules_link(pos, np, rules) + if link then + mesecon:turnoff(np, rulename) end end end diff --git a/mesecons/internal.lua b/mesecons/internal.lua index e9cde2d..96e407e 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -41,8 +41,8 @@ -- HIGH-LEVEL Internals -- mesecon:is_power_on(pos) --> Returns true if pos emits power in any way -- mesecon:is_power_off(pos) --> Returns true if pos does not emit power in any way --- mesecon:turnon(pos) --> Returns true whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive --- mesecon:turnoff(pos) --> Turns off whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive +-- mesecon:turnon(pos, rulename) --> Returns true whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive, the rulename is the name of the input rule that caused calling turnon +-- mesecon:turnoff(pos, rulename) --> Turns off whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive, the rulename is the name of the input rule that caused calling turnoff -- mesecon:connected_to_receptor(pos) --> Returns true if pos is connected to a receptor directly or via conductors; calls itself if pos is a conductor --> recursive -- mesecon:rules_link(output, input, dug_outputrules) --> Returns true if outputposition + outputrules = inputposition and inputposition + inputrules = outputposition (if the two positions connect) -- mesecon:rules_link_anydir(outp., inp., d_outpr.) --> Same as rules mesecon:rules_link but also returns true if output and input are swapped @@ -178,24 +178,24 @@ end --Signals -function mesecon:activate(pos, node) +function mesecon:activate(pos, node, rulename) local effector = mesecon:get_effector(node.name) if effector and effector.action_on then - effector.action_on (pos, node) + effector.action_on (pos, node, rulename) end end -function mesecon:deactivate(pos, node) +function mesecon:deactivate(pos, node, rulename) local effector = mesecon:get_effector(node.name) if effector and effector.action_off then - effector.action_off (pos, node) + effector.action_off (pos, node, rulename) end end -function mesecon:changesignal(pos, node) +function mesecon:changesignal(pos, node, rulename) local effector = mesecon:get_effector(node.name) if effector and effector.action_change then - effector.action_change (pos, node) + effector.action_change (pos, node, rulename) end end @@ -282,7 +282,7 @@ function mesecon:is_power_off(pos) return false end -function mesecon:turnon(pos) +function mesecon:turnon(pos, rulename) local node = minetest.env:get_node(pos) if mesecon:is_conductor_off(node.name) then @@ -291,20 +291,21 @@ function mesecon:turnon(pos) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) + local link, rulename = mesecon:rules_link(pos, np) - if mesecon:rules_link(pos, np) then - mesecon:turnon(np) + if link then + mesecon:turnon(np, rulename) end end elseif mesecon:is_effector(node.name) then - mesecon:changesignal(pos, node) + mesecon:changesignal(pos, node, rulename) if mesecon:is_effector_off(node.name) then - mesecon:activate(pos, node) + mesecon:activate(pos, node, rulename) end end end -function mesecon:turnoff(pos) +function mesecon:turnoff(pos, rulename) local node = minetest.env:get_node(pos) if mesecon:is_conductor_on(node.name) then @@ -313,16 +314,17 @@ function mesecon:turnoff(pos) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) + local link, rulename = mesecon:rules_link(pos, np) - if mesecon:rules_link(pos, np) then - mesecon:turnoff(np) + if link then + mesecon:turnoff(np, rulename) end end elseif mesecon:is_effector(node.name) then - mesecon:changesignal(pos, node) + mesecon:changesignal(pos, node, rulename) if mesecon:is_effector_on(node.name) and not mesecon:is_powered(pos) then - mesecon:deactivate(pos, node) + mesecon:deactivate(pos, node, rulename) end end end @@ -363,12 +365,11 @@ function mesecon:connected_to_receptor(pos, checked) return false, checked end -function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug) +function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule local outputnode = minetest.env:get_node(output) local inputnode = minetest.env:get_node(input) local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode) local inputrules = mesecon:get_any_inputrules (inputnode) - if not outputrules or not inputrules then return end @@ -379,7 +380,7 @@ function mesecon:rules_link(output, input, dug_outputrules) --output/input are p for _, inputrule in ipairs(inputrules) do -- Check if input accepts from output if mesecon:cmpPos(mesecon:addPosRule(input, inputrule), output) then - return true + return true, inputrule.name end end end diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua index 3117880..6120ade 100644 --- a/mesecons_microcontroller/init.lua +++ b/mesecons_microcontroller/init.lua @@ -30,16 +30,16 @@ if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end local input_rules={} -if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end -if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end -if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end -if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end +if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0, name = "A"}) end +if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1, name = "B"}) end +if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0, name = "C"}) end +if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1, name = "D"}) end mesecon:add_rules(nodename, rules) local mesecons = {effector = { rules = input_rules, - action_change = function (pos, node) + action_change = function (pos, node, rulename) update_yc(pos) end }} From 5aa0815ffb9b1661311958da6a1e757e9c52a0c9 Mon Sep 17 00:00:00 2001 From: Jeija Date: Wed, 19 Dec 2012 18:20:21 +0100 Subject: [PATCH 08/28] hopefully fix http://minetest.net/forum/viewtopic.php?pid=58093#p58093 --- mesecons_pistons/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 92dbd32..028eb54 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -64,7 +64,7 @@ end function mesecon:piston_push(pos) local node = minetest.env:get_node(pos) local dir = mesecon:piston_get_direction(node) - pos = addPosRule(pos, dir) --move to first node being pushed + pos = mesecon:addPosRule(pos, dir) --move to first node being pushed --determine the number of nodes that need to be pushed local count = 0 @@ -90,7 +90,7 @@ function mesecon:piston_push(pos) return end - checkpos = addPosRule(checkpos, dir) + checkpos = mesecon:addPosRule(checkpos, dir) end local thisnode = minetest.env:get_node(pos) @@ -115,7 +115,7 @@ function mesecon:piston_push(pos) --move nodes forward for i = 1, count do - pos = addPosRule(pos, dir) --move to the next node + pos = mesecon:addPosRule(pos, dir) --move to the next node nextnode = minetest.env:get_node(pos) minetest.env:remove_node(pos) @@ -155,7 +155,7 @@ function mesecon:piston_pull(pos) --retract piston minetest.env:remove_node(pos) --remove pusher if minetest.registered_nodes[node.name].is_sticky_piston then --retract block if piston is sticky - local retractpos = addPosRule(pos, dir) --move to the node to be retracted + local retractpos = mesecon:addPosRule(pos, dir) --move to the node to be retracted local retractnode = minetest.env:get_node(retractpos) if minetest.registered_nodes[retractnode.name].liquidtype == "none" and not mesecon:is_mvps_stopper(retractnode.name) then From f114cb8ddcbb2e007889a6bf45b8b3383c793756 Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 20 Dec 2012 20:16:07 +0100 Subject: [PATCH 09/28] Fix movestone crash bug --- mesecons_movestones/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua index b17874f..a7e5f2c 100644 --- a/mesecons_movestones/init.lua +++ b/mesecons_movestones/init.lua @@ -68,7 +68,7 @@ minetest.register_node("mesecons_movestones:movestone", { local checknode={} local collpos={x=pos.x, y=pos.y, z=pos.z} repeat -- Check if it collides with a stopper - collpos = addPosRule(collpos, direction) + collpos = mesecon:addPosRule(collpos, direction) checknode=minetest.env:get_node(collpos) if mesecon:is_mvps_stopper(checknode.name) then return @@ -138,7 +138,7 @@ minetest.register_node("mesecons_movestones:sticky_movestone", { local checknode={} local collpos={x=pos.x, y=pos.y, z=pos.z} repeat -- Check if it collides with a stopper - collpos = addPosRule(collpos, direction) + collpos = mesecon:addPosRule(collpos, direction) checknode=minetest.env:get_node(collpos) if mesecon:is_mvps_stopper(checknode.name) then return From 9019a4aff7a59bf5d6b4bc1efa177ffd45f6d125 Mon Sep 17 00:00:00 2001 From: Jeija Date: Fri, 21 Dec 2012 16:04:19 +0100 Subject: [PATCH 10/28] Bugfix, wires sometimes turned off for no reason --- mesecons/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesecons/init.lua b/mesecons/init.lua index 6378946..f53a5bf 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -93,7 +93,7 @@ function mesecon:receptor_off(pos, rules) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) local link, rulename = mesecon:rules_link(pos, np, rules) - if link then + if link and not mesecon:connected_to_receptor(np) then mesecon:turnoff(np, rulename) end end From 34fa8a116702864f295f8858cfbd61dc4085bb3b Mon Sep 17 00:00:00 2001 From: Andres Eduardo Montoya Cruz <> Date: Fri, 21 Dec 2012 20:24:43 -0500 Subject: [PATCH 11/28] now the insulated wires change their color when they are turn on --- mesecons_extrawires/crossing.lua | 2 +- mesecons_extrawires/tjunction.lua | 12 ++++++------ mesecons_insulated/init.lua | 16 ++++++++-------- ...s.png => jeija_insulated_wire_sides_off.png} | Bin .../textures/jeija_insulated_wire_sides_on.png | Bin 0 -> 169 bytes 5 files changed, 15 insertions(+), 15 deletions(-) rename mesecons_textures/textures/{jeija_insulated_wire_sides.png => jeija_insulated_wire_sides_off.png} (100%) create mode 100644 mesecons_textures/textures/jeija_insulated_wire_sides_on.png diff --git a/mesecons_extrawires/crossing.lua b/mesecons_extrawires/crossing.lua index 2b35af1..9b381bf 100644 --- a/mesecons_extrawires/crossing.lua +++ b/mesecons_extrawires/crossing.lua @@ -6,7 +6,7 @@ end minetest.register_node("mesecons_extrawires:crossing_on", { drawtype = "nodebox", - tiles = {"jeija_insulated_wire_sides.png"}, + tiles = {"jeija_insulated_wire_sides_on.png"}, paramtype = "light", walkable = false, stack_max = 99, diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua index cb16cfb..aa100f5 100644 --- a/mesecons_extrawires/tjunction.lua +++ b/mesecons_extrawires/tjunction.lua @@ -28,11 +28,11 @@ end minetest.register_node("mesecons_extrawires:tjunction_on", { drawtype = "nodebox", tiles = { - "jeija_insulated_wire_sides.png", - "jeija_insulated_wire_sides.png", + "jeija_insulated_wire_sides_on.png", + "jeija_insulated_wire_sides_on.png", "jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png", - "jeija_insulated_wire_sides.png", + "jeija_insulated_wire_sides_on.png", "jeija_insulated_wire_ends_on.png" }, paramtype = "light", @@ -55,11 +55,11 @@ minetest.register_node("mesecons_extrawires:tjunction_off", { drawtype = "nodebox", description = "T-junction", tiles = { - "jeija_insulated_wire_sides.png", - "jeija_insulated_wire_sides.png", + "jeija_insulated_wire_sides_off.png", + "jeija_insulated_wire_sides_off.png", "jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png", - "jeija_insulated_wire_sides.png", + "jeija_insulated_wire_sides_off.png", "jeija_insulated_wire_ends_off.png" }, paramtype = "light", diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua index 8bf75c7..37f64c8 100644 --- a/mesecons_insulated/init.lua +++ b/mesecons_insulated/init.lua @@ -11,12 +11,12 @@ minetest.register_node("mesecons_insulated:insulated_on", { drawtype = "nodebox", description = "insulated mesecons", tiles = { - "jeija_insulated_wire_sides.png", - "jeija_insulated_wire_sides.png", + "jeija_insulated_wire_sides_on.png", + "jeija_insulated_wire_sides_on.png", "jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png", - "jeija_insulated_wire_sides.png", - "jeija_insulated_wire_sides.png" + "jeija_insulated_wire_sides_on.png", + "jeija_insulated_wire_sides_on.png" }, paramtype = "light", paramtype2 = "facedir", @@ -43,12 +43,12 @@ minetest.register_node("mesecons_insulated:insulated_off", { drawtype = "nodebox", description = "insulated mesecons", tiles = { - "jeija_insulated_wire_sides.png", - "jeija_insulated_wire_sides.png", + "jeija_insulated_wire_sides_off.png", + "jeija_insulated_wire_sides_off.png", "jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png", - "jeija_insulated_wire_sides.png", - "jeija_insulated_wire_sides.png" + "jeija_insulated_wire_sides_off.png", + "jeija_insulated_wire_sides_off.png" }, paramtype = "light", paramtype2 = "facedir", diff --git a/mesecons_textures/textures/jeija_insulated_wire_sides.png b/mesecons_textures/textures/jeija_insulated_wire_sides_off.png similarity index 100% rename from mesecons_textures/textures/jeija_insulated_wire_sides.png rename to mesecons_textures/textures/jeija_insulated_wire_sides_off.png diff --git a/mesecons_textures/textures/jeija_insulated_wire_sides_on.png b/mesecons_textures/textures/jeija_insulated_wire_sides_on.png new file mode 100644 index 0000000000000000000000000000000000000000..f76e9a876d2da3af73af78cf9a50b9c785892ee0 GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPaj|i(S<0IG4>w!XMo-U3d7N?UFCd~RYU-9q%dbX9C z{}(S>^l$Q+ Date: Fri, 21 Dec 2012 20:46:57 -0500 Subject: [PATCH 12/28] Fix up piston retraction. The node property is_sticky_piston was applied to piston_up_normal rather than piston_up_sticky. --- 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 fb7375b..47956cc 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -294,7 +294,6 @@ minetest.register_node("mesecons_pistons:piston_up_normal", { groups = {cracky=3, mesecon=2}, after_destruct = destruct, on_timer = timer, - is_sticky_piston = true, mesecons = {effector={ action_change = update }}, @@ -306,6 +305,7 @@ minetest.register_node("mesecons_pistons:piston_up_sticky", { groups = {cracky=3, mesecon=2}, after_destruct = destruct, on_timer = timer, + is_sticky_piston = true, mesecons = {effector={ action_change = update }}, From e2ec7b5b04f5f14092205b26594124d40de2f1ec Mon Sep 17 00:00:00 2001 From: Jeija Date: Sat, 22 Dec 2012 23:39:17 +0100 Subject: [PATCH 13/28] Fix pressure plates (forgot to add mesecons field to some of the nodedefs) --- mesecons_pressureplates/init.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mesecons_pressureplates/init.lua b/mesecons_pressureplates/init.lua index 2e88d2f..78389a4 100644 --- a/mesecons_pressureplates/init.lua +++ b/mesecons_pressureplates/init.lua @@ -16,7 +16,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", { type = "fixed", fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, }, - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3, mesecon = 2}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3}, description="Wood Pressure Plate", on_timer = function(pos, elapsed) @@ -30,7 +30,9 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", { end return true end, - + mesecons = {receptor = { + state = mesecon.state.off + }}, on_construct = function(pos) minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) end, @@ -50,7 +52,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", { type = "fixed", fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 }, }, - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2}, + groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1}, drop='"mesecons_pressureplates:pressure_plate_wood_off" 1', on_timer = function(pos, elapsed) @@ -61,7 +63,9 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", { end return true end, - + mesecons = {receptor = { + state = mesecon.state.on + }}, on_construct = function(pos) minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) end, @@ -106,14 +110,12 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", { end return true end, - + mesecons = {receptor = { + state = mesecon.state.off + }}, on_construct = function(pos) minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) end, - - mesecons = {receptor = { - state = mesecon.state.off - }} }) minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", { @@ -141,14 +143,12 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", { end return true end, - + mesecons = {receptor = { + state = mesecon.state.on + }}, on_construct = function(pos) minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) end, - - mesecons = {receptor = { - state = mesecon.state.off - }} }) minetest.register_craft({ From af8fd75fa484cdf881e2414f3baa3a0eed6562e9 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 23 Dec 2012 17:20:59 +0100 Subject: [PATCH 14/28] Fix sticky piston up --- 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 fb7375b..47956cc 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -294,7 +294,6 @@ minetest.register_node("mesecons_pistons:piston_up_normal", { groups = {cracky=3, mesecon=2}, after_destruct = destruct, on_timer = timer, - is_sticky_piston = true, mesecons = {effector={ action_change = update }}, @@ -306,6 +305,7 @@ minetest.register_node("mesecons_pistons:piston_up_sticky", { groups = {cracky=3, mesecon=2}, after_destruct = destruct, on_timer = timer, + is_sticky_piston = true, mesecons = {effector={ action_change = update }}, From d91e0b66cb7971ba54d071a0955f17d1a7b0162e Mon Sep 17 00:00:00 2001 From: Jeija Date: Wed, 26 Dec 2012 22:54:28 +0100 Subject: [PATCH 15/28] Re-write pistons from scratch, propably fixes a lot of bugs and doesn't cause too many new ones. --- .mesecons_pistons/depends.txt | 3 + .mesecons_pistons/init.lua | 459 +++++++++++++++++++++ mesecons/internal.lua | 40 +- mesecons/services.lua | 7 +- mesecons/settings.lua | 1 + mesecons_lamp/init.lua | 35 +- mesecons_movestones/init.lua | 16 +- mesecons_mvps/init.lua | 117 ++++-- mesecons_pistons/depends.txt | 1 - mesecons_pistons/init.lua | 747 ++++++++++++++++++++-------------- 10 files changed, 1029 insertions(+), 397 deletions(-) create mode 100644 .mesecons_pistons/depends.txt create mode 100644 .mesecons_pistons/init.lua diff --git a/.mesecons_pistons/depends.txt b/.mesecons_pistons/depends.txt new file mode 100644 index 0000000..a596cf8 --- /dev/null +++ b/.mesecons_pistons/depends.txt @@ -0,0 +1,3 @@ +mesecons +mesecons_materials +mesecons_mvps diff --git a/.mesecons_pistons/init.lua b/.mesecons_pistons/init.lua new file mode 100644 index 0000000..0a3838d --- /dev/null +++ b/.mesecons_pistons/init.lua @@ -0,0 +1,459 @@ +--PISTONS + +-- Get mesecon rules of pistons +piston_rules = +{{x=0, y=0, z=1}, --everything apart from z- (pusher side) + {x=1, y=0, z=0}, + {x=-1, y=0, z=0}, + {x=1, y=1, z=0}, + {x=1, y=-1, z=0}, + {x=-1, y=1, z=0}, + {x=-1, y=-1, z=0}, + {x=0, y=1, z=1}, + {x=0, y=-1, z=1}} + +local piston_get_rules = function (node) + local rules = piston_rules + for i = 1, node.param2 do + rules = mesecon:rotate_rules_left(rules) + end + return rules +end + +--starts the timer to make the piston update to its new state +local update = function(pos, node) + local timer = minetest.env:get_node_timer(pos) + timer:stop() + timer:start(0) +end + +--on_destruct callback, removes the piston pusher if it is present +local destruct = function(pos, oldnode) + local dir = mesecon:piston_get_direction(oldnode) + pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check + + --ensure piston is extended + local checknode = minetest.env:get_node(pos) + if checknode.name == "mesecons_pistons:piston_pusher_normal" + or checknode.name == "mesecons_pistons:piston_pusher_sticky" then + if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston + minetest.env:remove_node(pos) --remove the pusher + end + elseif oldnode.name == "mesecons_pistons:piston_up_normal" or oldnode.name == "mesecons_pistons:piston_up_sticky" then + if checknode.name == "mesecons_pistons:piston_up_pusher_normal" or checknode.name == "mesecons_pistons:piston_up_pusher_sticky" then + minetest.env:remove_node(pos) --remove the pusher + end + elseif oldnode.name == "mesecons_pistons:piston_down_normal" or oldnode.name == "mesecons_pistons:piston_down_sticky" then + if checknode.name == "mesecons_pistons:piston_down_pusher_normal" or checknode.name == "mesecons_pistons:piston_down_pusher_sticky" then + minetest.env:remove_node(pos) --remove the pusher + end + end +end + +--node timer callback, pushes/pulls the piston depending on whether it is powered +local timer = function(pos, elapsed) + if mesecon:is_powered(pos) then + mesecon:piston_push(pos) + else + mesecon:piston_pull(pos) + end + return false +end + +--piston push action +function mesecon:piston_push(pos) + local node = minetest.env:get_node(pos) + local dir = mesecon:piston_get_direction(node) + pos = mesecon:addPosRule(pos, dir) --move to first node being pushed + + --determine the number of nodes that need to be pushed + local count = 0 + local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed + + while true do + local checknode = minetest.env:get_node(checkpos) + + --check for collision with stopper or bounds + if mesecon:is_mvps_stopper(checknode.name) or checknode.name == "ignore" then + return + end + + --check for column end + if checknode.name == "air" + or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then + break + end + + --limit piston pushing capacity + count = count + 1 + if count > 15 then + return + end + + checkpos = mesecon:addPosRule(checkpos, dir) + end + + local thisnode = minetest.env:get_node(pos) + minetest.env:remove_node(pos) + mesecon.on_dignode(pos, thisnode) + local nextnode + + --add pusher + if node.name == "mesecons_pistons:piston_normal" then + minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2}) + elseif node.name == "mesecons_pistons:piston_sticky" then + minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_sticky", param2=node.param2}) + elseif node.name == "mesecons_pistons:piston_up_normal" then + minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_normal"}) + elseif node.name == "mesecons_pistons:piston_up_sticky" then + minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_sticky"}) + elseif node.name == "mesecons_pistons:piston_down_normal" then + minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_normal"}) + elseif node.name == "mesecons_pistons:piston_down_sticky" then + minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_sticky"}) + end + + --move nodes forward + for i = 1, count do + pos = mesecon:addPosRule(pos, dir) --move to the next node + + nextnode = minetest.env:get_node(pos) + minetest.env:remove_node(pos) + mesecon.on_dignode(pos, thisnode) + minetest.env:add_node(pos, thisnode) + mesecon.on_placenode(pos, thisnode) + thisnode = nextnode + nodeupdate(pos) + end +end + +--piston pull action +function mesecon:piston_pull(pos) + local node = minetest.env:get_node(pos) + local dir = mesecon:piston_get_direction(node) + pos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to first node being replaced + + --ensure piston is extended + local checknode = minetest.env:get_node(pos) + if node.name == "mesecons_pistons:piston_up_normal" or node.name == "mesecons_pistons:piston_up_sticky" then --up piston + if checknode.name ~= "mesecons_pistons:piston_up_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_up_pusher_sticky" then + return --piston is not extended + end + elseif node.name == "mesecons_pistons:piston_down_normal" or node.name == "mesecons_pistons:piston_down_sticky" then --down piston + if checknode.name ~= "mesecons_pistons:piston_down_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_down_pusher_sticky" then + return --piston is not extended + end + else --horizontal piston + if checknode.name ~= "mesecons_pistons:piston_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_pusher_sticky" then + return --piston is not extended + end + if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston + return --piston is not extended + end + end + + --retract piston + minetest.env:remove_node(pos) --remove pusher + if minetest.registered_nodes[node.name].is_sticky_piston then --retract block if piston is sticky + local retractpos = mesecon:addPosRule(pos, dir) --move to the node to be retracted + local retractnode = minetest.env:get_node(retractpos) + if minetest.registered_nodes[retractnode.name].liquidtype == "none" + and not mesecon:is_mvps_stopper(retractnode.name) then + mesecon:move_node(retractpos, pos) + mesecon.on_dignode(retractpos, retractnode) + mesecon.on_placenode(pos, retractnode) + nodeupdate(pos) + end + end +end + +--push direction of a piston +function mesecon:piston_get_direction(node) + if node.name == "mesecons_pistons:piston_up_normal" or node.name == "mesecons_pistons:piston_up_sticky" then + return {x=0, y=1, z=0} + elseif node.name == "mesecons_pistons:piston_down_normal" or node.name == "mesecons_pistons:piston_down_sticky" then + return {x=0, y=-1, z=0} + elseif node.param2 == 3 then + return {x=1, y=0, z=0} + elseif node.param2 == 2 then + return {x=0, y=0, z=1} + elseif node.param2 == 1 then + return {x=-1, y=0, z=0} + else --node.param2 == 0 + return {x=0, y=0, z=-1} + end +end + +--horizontal pistons +minetest.register_node("mesecons_pistons:piston_normal", { + description = "Piston", + tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"}, + groups = {cracky=3, mesecon=2}, + paramtype2 = "facedir", + after_destruct = destruct, + on_timer = timer, + after_place_node = function(pos, placer) + if not placer then --not placed by player + return + end + 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 + end, + mesecons = {effector={ + action_change = update, + rules = piston_get_rules + }} +}) + +minetest.register_node("mesecons_pistons:piston_sticky", { + description = "Sticky Piston", + tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"}, + groups = {cracky=3, mesecon=2}, + paramtype2 = "facedir", + after_destruct = destruct, + on_timer = timer, + is_sticky_piston = true, + after_place_node = function(pos, placer) + if not placer then --not placed by player + return + end + 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 + end, + mesecons = {effector={ + action_change = update, + rules = piston_get_rules + }} +}) + +minetest.register_node("mesecons_pistons:piston_pusher_normal", { + drawtype = "nodebox", + tiles = {"jeija_piston_pusher_normal.png"}, + paramtype = "light", + paramtype2 = "facedir", + diggable = false, + selection_box = { + type = "fixed", + fixed = { + {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, + }, + }, + node_box = { + type = "fixed", + fixed = { + {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, + }, + }, +}) + +minetest.register_node("mesecons_pistons:piston_pusher_sticky", { + drawtype = "nodebox", + tiles = { + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_sticky.png" + }, + paramtype = "light", + paramtype2 = "facedir", + diggable = false, + selection_box = { + type = "fixed", + fixed = { + {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, + }, + }, + node_box = { + type = "fixed", + fixed = { + {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, + {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, + }, + }, +}) + +mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal") +mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky") + +-- up pistons +minetest.register_node("mesecons_pistons:piston_up_normal", { + tiles = {"jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky=3, mesecon=2}, + after_destruct = destruct, + on_timer = timer, + mesecons = {effector={ + action_change = update + }}, + drop = "mesecons_pistons:piston_normal", +}) + +minetest.register_node("mesecons_pistons:piston_up_sticky", { + tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky=3, mesecon=2}, + after_destruct = destruct, + on_timer = timer, + is_sticky_piston = true, + mesecons = {effector={ + action_change = update + }}, + drop = "mesecons_pistons:piston_sticky", +}) + +minetest.register_node("mesecons_pistons:piston_up_pusher_normal", { + drawtype = "nodebox", + tiles = {"jeija_piston_pusher_normal.png"}, + paramtype = "light", + diggable = false, + selection_box = { + type = "fixed", + fixed = { + {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, + {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, + }, + }, + node_box = { + type = "fixed", + fixed = { + {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, + {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, + }, + }, +}) + +minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { + drawtype = "nodebox", + tiles = { + "jeija_piston_pusher_sticky.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png" + }, + paramtype = "light", + diggable = false, + selection_box = { + type = "fixed", + fixed = { + {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, + {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, + }, + }, + node_box = { + type = "fixed", + fixed = { + {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, + {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, + }, + }, +}) + +mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal") +mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky") + +--down pistons +minetest.register_node("mesecons_pistons:piston_down_normal", { + tiles = {"jeija_piston_tb.png", "jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky=3, mesecon=2}, + after_destruct = destruct, + on_timer = timer, + mesecons = {effector={ + action_change = update + }}, + drop = "mesecons_pistons:piston_normal", +}) + +minetest.register_node("mesecons_pistons:piston_down_sticky", { + tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky=3, mesecon=2}, + after_destruct = destruct, + on_timer = timer, + is_sticky_piston = true, + mesecons = {effector={ + action_change = update + }}, + drop = "mesecons_pistons:piston_sticky", +}) + +minetest.register_node("mesecons_pistons:piston_down_pusher_normal", { + drawtype = "nodebox", + tiles = {"jeija_piston_pusher_normal.png"}, + paramtype = "light", + diggable = false, + selection_box = { + type = "fixed", + fixed = { + {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, + {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, + }, + }, + node_box = { + type = "fixed", + fixed = { + {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, + {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, + }, + }, +}) + +minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { + drawtype = "nodebox", + tiles = { + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_sticky.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png" + }, + paramtype = "light", + diggable = false, + selection_box = { + type = "fixed", + fixed = { + {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, + {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, + }, + }, + node_box = { + type = "fixed", + fixed = { + {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, + {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, + }, + }, +}) + +mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal") +mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky") + +--craft recipes +minetest.register_craft({ + output = '"mesecons_pistons:piston_normal" 2', + recipe = { + {"default:wood", "default:wood", "default:wood"}, + {"default:cobble", "default:steel_ingot", "default:cobble"}, + {"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"}, + } +}) + +minetest.register_craft({ + output = "mesecons_pistons:piston_sticky", + recipe = { + {"mesecons_materials:glue"}, + {"mesecons_pistons:piston_normal"}, + } +}) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 3f2ceb3..c7efd1a 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -413,45 +413,45 @@ end --Rules rotation Functions: function mesecon:rotate_rules_right(rules) - local nr={}; + local nr = {} for i, rule in ipairs(rules) do - nr[i]={} - nr[i].z=rule.x - nr[i].x=-rule.z - nr[i].y=rule.y + table.insert(nr, { + x = -rule.z, + y = rule.y, + z = rule.x}) end return nr end function mesecon:rotate_rules_left(rules) - local nr={}; + local nr = {} for i, rule in ipairs(rules) do - nr[i]={} - nr[i].z=-rules[i].x - nr[i].x=rules[i].z - nr[i].y=rules[i].y + table.insert(nr, { + x = rule.z, + y = rule.y, + z = -rule.x}) end return nr end function mesecon:rotate_rules_down(rules) - local nr={}; + local nr = {} for i, rule in ipairs(rules) do - nr[i]={} - nr[i].y=rule.x - nr[i].x=-rule.y - nr[i].z=rule.z + table.insert(nr, { + x = -rule.y, + y = rule.x, + z = rule.z}) end return nr end function mesecon:rotate_rules_up(rules) - local nr={}; + local nr = {} for i, rule in ipairs(rules) do - nr[i]={} - nr[i].y=-rule.x - nr[i].x=rule.y - nr[i].z=rule.z + table.insert(nr, { + x = rule.y, + y = -rule.x, + z = rule.z}) end return nr end diff --git a/mesecons/services.lua b/mesecons/services.lua index ada9351..a3aab43 100644 --- a/mesecons/services.lua +++ b/mesecons/services.lua @@ -2,8 +2,9 @@ mesecon.on_placenode = function (pos, node) if mesecon:is_receptor_on(node.name) then mesecon:receptor_on(pos, mesecon:receptor_get_rules(node)) elseif mesecon:is_powered(pos) then - if mesecon:is_conductor_off(node.name) then - mesecon:turnon(pos, node) + if mesecon:is_conductor(node.name) then + mesecon:turnon (pos) + mesecon:receptor_on (pos, mesecon:conductor_get_rules(node)) else mesecon:changesignal(pos, node) mesecon:activate(pos, node) @@ -17,7 +18,7 @@ end mesecon.on_dignode = function (pos, node) if mesecon:is_conductor_on(node.name) then - mesecon:receptor_off(pos) + mesecon:receptor_off(pos, mesecon:conductor_get_rules(node)) elseif mesecon:is_receptor_on(node.name) then mesecon:receptor_off(pos, mesecon:receptor_get_rules(node)) end diff --git a/mesecons/settings.lua b/mesecons/settings.lua index 398ee6d..20776ee 100644 --- a/mesecons/settings.lua +++ b/mesecons/settings.lua @@ -3,3 +3,4 @@ BLINKY_PLANT_INTERVAL = 3 NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires PRESSURE_PLATE_INTERVAL = 0.1 OBJECT_DETECTOR_RADIUS = 6 +PISTON_MAXIMUM_PUSH = 15 diff --git a/mesecons_lamp/init.lua b/mesecons_lamp/init.lua index d20236b..175a22b 100644 --- a/mesecons_lamp/init.lua +++ b/mesecons_lamp/init.lua @@ -2,6 +2,13 @@ -- A lamp is "is an electrical device used to create artificial light" (wikipedia) -- guess what? +mesecon_lamp_box = { + type = "wallmounted", + wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, + wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, + wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125}, +} + minetest.register_node("mesecons_lamp:lamp_on", { drawtype = "nodebox", tiles = {"jeija_meselamp_on.png"}, @@ -11,18 +18,8 @@ minetest.register_node("mesecons_lamp:lamp_on", { sunlight_propagates = true, walkable = true, light_source = LIGHT_MAX, - node_box = { - type = "wallmounted", - wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, - wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, - wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125}, - }, - selection_box = { - type = "wallmounted", - wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, - wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, - wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125}, - }, + node_box = mesecon_lamp_box, + selection_box = mesecon_lamp_box, groups = {dig_immediate=3,not_in_creative_inventory=1, mesecon_effector_on = 1}, drop='"mesecons_lamp:lamp_off" 1', mesecons = {effector = { @@ -41,18 +38,8 @@ minetest.register_node("mesecons_lamp:lamp_off", { paramtype2 = "wallmounted", sunlight_propagates = true, walkable = true, - node_box = { - type = "wallmounted", - wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, - wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, - wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125}, - }, - selection_box = { - type = "wallmounted", - wall_top = {-0.3125,0.375,-0.3125,0.3125,0.5,0.3125}, - wall_bottom = {-0.3125,-0.5,-0.3125,0.3125,-0.375,0.3125}, - wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125}, - }, + node_box = mesecon_lamp_box, + selection_box = mesecon_lamp_box, groups = {dig_immediate=3, mesecon_receptor_off = 1, mesecon_effector_off = 1}, description="Meselamp", mesecons = {effector = { diff --git a/mesecons_movestones/init.lua b/mesecons_movestones/init.lua index a7e5f2c..91b57c7 100644 --- a/mesecons_movestones/init.lua +++ b/mesecons_movestones/init.lua @@ -70,7 +70,7 @@ minetest.register_node("mesecons_movestones:movestone", { repeat -- Check if it collides with a stopper collpos = mesecon:addPosRule(collpos, direction) checknode=minetest.env:get_node(collpos) - if mesecon:is_mvps_stopper(checknode.name) then + if mesecon:is_mvps_stopper(checknode.name, direction) then return end until checknode.name=="air" @@ -97,7 +97,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", { on_step = function(self, dtime) local pos = self.object:getpos() - local direction=mesecon:get_movestone_direction(pos) + local direction = mesecon:get_movestone_direction(pos) if not direction then minetest.env:add_node(pos, {name="mesecons_movestones:movestone"}) @@ -105,9 +105,9 @@ minetest.register_entity("mesecons_movestones:movestone_entity", { return end - self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3}) + self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2}) - mesecon:mvps_push(pos, direction) + mesecon:mvps_push(pos, direction, 100) end, }) @@ -140,7 +140,7 @@ minetest.register_node("mesecons_movestones:sticky_movestone", { repeat -- Check if it collides with a stopper collpos = mesecon:addPosRule(collpos, direction) checknode=minetest.env:get_node(collpos) - if mesecon:is_mvps_stopper(checknode.name) then + if mesecon:is_mvps_stopper(checknode.name, direction) then return end until checknode.name=="air" @@ -149,7 +149,7 @@ minetest.register_node("mesecons_movestones:sticky_movestone", { repeat -- Check if it collides with a stopper (pull direction) collpos={x=collpos.x-direction.x, y=collpos.y-direction.y, z=collpos.z-direction.z} checknode=minetest.env:get_node(collpos) - if mesecon:is_mvps_stopper(checknode.name) then + if mesecon:is_mvps_stopper(checknode.name, direction) then return end until checknode.name=="air" @@ -192,9 +192,9 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", { return end - self.object:setvelocity({x=direction.x*3, y=direction.y*3, z=direction.z*3}) + self.object:setvelocity({x=direction.x*2, y=direction.y*2, z=direction.z*2}) - mesecon:mvps_push(pos, direction) + mesecon:mvps_push(pos, direction, 100) --STICKY mesecon:mvps_pull_all(pos, direction) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index 3903910..57c538d 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -2,42 +2,99 @@ mesecon.mvps_stoppers={} -function mesecon:is_mvps_stopper(nodename) - local i=1 - repeat - i=i+1 - if mesecon.mvps_stoppers[i]==nodename then return true end - until mesecon.mvps_stoppers[i]==nil - return false +function mesecon:is_mvps_stopper(node, pushdir, stack, stackid) + local get_stopper = mesecon.mvps_stoppers[node.name] + if type (get_stopper) == "function" then + get_stopper = get_stopper(node, pushdir, stack, stackid) + end + return get_stopper end -function mesecon:register_mvps_stopper(nodename) - local i=1 - repeat - i=i+1 - if mesecon.mvps_stoppers[i]==nil then break end - until false - mesecon.mvps_stoppers[i]=nodename +function mesecon:register_mvps_stopper(nodename, get_stopper) + if get_stopper == nil then + get_stopper = true + end + mesecon.mvps_stoppers[nodename] = get_stopper end -function mesecon:mvps_push(pos, direction) -- pos: pos of mvps; direction: direction of push - pos.x=pos.x+direction.x - pos.y=pos.y+direction.y - pos.z=pos.z+direction.z +function mesecon:mvps_process_stack(stack) + -- update mesecons for placed nodes ( has to be done after all nodes have been added ) + for _, n in ipairs(stack) do + mesecon.on_placenode(n.pos, n.node) + mesecon:update_autoconnect(n.pos) + end +end - local lpos = {x=pos.x, y=pos.y, z=pos.z} - local lnode = minetest.env:get_node(lpos) - local newnode - minetest.env:remove_node(lpos) - while not(lnode.name == "ignore" or lnode.name == "air" or not(minetest.registered_nodes[lnode.name].liquidtype == "none")) do - lpos.x=lpos.x+direction.x - lpos.y=lpos.y+direction.y - lpos.z=lpos.z+direction.z - newnode = lnode - lnode = minetest.env:get_node(lpos) - minetest.env:add_node(lpos, newnode) - nodeupdate(lpos) +function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed + np = {x = pos.x, y = pos.y, z = pos.z} + + -- determine the number of nodes to be pushed + local nodes = {} + while true do + nn = minetest.env:get_node_or_nil(np) + if not nn or #nodes > maximum then + -- don't push at all, something is in the way (unloaded map or too many nodes) + return end + + if nn.name == "air" + or minetest.registered_nodes[nn.name].liquidtype ~= "none" then --is liquid + break + end + + table.insert (nodes, {node = nn, pos = np}) + + np = mesecon:addPosRule(np, dir) + end + + -- determine if one of the nodes blocks the push + for id, n in ipairs(nodes) do + if mesecon:is_mvps_stopper(n.node, dir, nodes, id) then + return + end + end + + -- remove all nodes + for _, n in ipairs(nodes) do + minetest.env:remove_node(n.pos) + nodeupdate(n.pos) + end + + -- update mesecons for removed nodes ( has to be done after all nodes have been removed ) + for _, n in ipairs(nodes) do + mesecon.on_dignode(n.pos, n.node) + mesecon:update_autoconnect(n.pos) + end + + -- add nodes + for _, n in ipairs(nodes) do + np = mesecon:addPosRule(n.pos, dir) + minetest.env:add_node(np, n.node) + nodeupdate(np) + end + + for i in ipairs(nodes) do + nodes[i].pos = mesecon:addPosRule(nodes[i].pos, dir) + end + + return true, nodes +end + +function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons) + np = mesecon:addPosRule(pos, dir) + nn = minetest.env:get_node(np) + + if minetest.registered_nodes[nn.name].liquidtype == "none" + and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then + minetest.env:remove_node(np) + minetest.env:add_node(pos, nn) + + nodeupdate(np) + nodeupdate(pos) + mesecon.on_dignode(np, nn) + mesecon:update_autoconnect(np) + end + return {{pos = np, node = nn}} end function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull diff --git a/mesecons_pistons/depends.txt b/mesecons_pistons/depends.txt index a596cf8..01f085b 100644 --- a/mesecons_pistons/depends.txt +++ b/mesecons_pistons/depends.txt @@ -1,3 +1,2 @@ mesecons -mesecons_materials mesecons_mvps diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 47956cc..75547d2 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -1,4 +1,7 @@ ---PISTONS +-- +-- +-- +-- -- Get mesecon rules of pistons piston_rules = @@ -20,242 +23,194 @@ local piston_get_rules = function (node) return rules end ---starts the timer to make the piston update to its new state -local update = function(pos, node) - local timer = minetest.env:get_node_timer(pos) - timer:stop() - timer:start(0) -end - ---on_destruct callback, removes the piston pusher if it is present -local destruct = function(pos, oldnode) - local dir = mesecon:piston_get_direction(oldnode) - pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check - - --ensure piston is extended - local checknode = minetest.env:get_node(pos) - if checknode.name == "mesecons_pistons:piston_pusher_normal" - or checknode.name == "mesecons_pistons:piston_pusher_sticky" then - if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston - minetest.env:remove_node(pos) --remove the pusher - end - elseif oldnode.name == "mesecons_pistons:piston_up_normal" or oldnode.name == "mesecons_pistons:piston_up_sticky" then - if checknode.name == "mesecons_pistons:piston_up_pusher_normal" or checknode.name == "mesecons_pistons:piston_up_pusher_sticky" then - minetest.env:remove_node(pos) --remove the pusher - end - elseif oldnode.name == "mesecons_pistons:piston_down_normal" or oldnode.name == "mesecons_pistons:piston_down_sticky" then - if checknode.name == "mesecons_pistons:piston_down_pusher_normal" or checknode.name == "mesecons_pistons:piston_down_pusher_sticky" then - minetest.env:remove_node(pos) --remove the pusher - end +piston_facedir_direction = function (node) + local rules = {{x = 0, y = 0, z = -1}} + for i = 1, node.param2 do + rules = mesecon:rotate_rules_left(rules) end + return rules[1] end ---node timer callback, pushes/pulls the piston depending on whether it is powered -local timer = function(pos, elapsed) - if mesecon:is_powered(pos) then - mesecon:piston_push(pos) +piston_get_direction = function (dir, node) + if type(dir) == "function" then + return dir(node) else - mesecon:piston_pull(pos) + return dir end - return false end ---piston push action -function mesecon:piston_push(pos) +local piston_remove_pusher = function (pos, node) + pistonspec = minetest.registered_nodes[node.name].mesecons_piston + + dir = piston_get_direction(pistonspec.dir, node) + local pusherpos = mesecon:addPosRule(pos, dir) + minetest.env:remove_node(pusherpos) + nodeupdate(pusherpos) +end + +local piston_on = function (pos, node) + local pistonspec = minetest.registered_nodes[node.name].mesecons_piston + + dir = piston_get_direction(pistonspec.dir, node) + local np = mesecon:addPosRule(pos, dir) + success, stack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH) + if success then + minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.onname}) + minetest.env:add_node(np, {param2 = node.param2, name = pistonspec.pusher}) + mesecon:mvps_process_stack(stack) + end +end + +local piston_off = function (pos, node) + local pistonspec = minetest.registered_nodes[node.name].mesecons_piston + minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.offname}) + piston_remove_pusher (pos, node) + + if pistonspec.sticky then + dir = piston_get_direction(pistonspec.dir, node) + pullpos = mesecon:addPosRule(pos, dir) + stack = mesecon:mvps_pull_single(pullpos, dir) + mesecon:mvps_process_stack(stack) + end +end + +local piston_orientate = function (pos, placer) + -- not placed by player + if not placer then return end + + -- placer pitch in degrees + local pitch = placer:get_look_pitch() * (180 / math.pi) + local node = minetest.env:get_node(pos) - local dir = mesecon:piston_get_direction(node) - pos = mesecon:addPosRule(pos, dir) --move to first node being pushed - - --determine the number of nodes that need to be pushed - local count = 0 - local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed - - while true do - local checknode = minetest.env:get_node(checkpos) - - --check for collision with stopper or bounds - if mesecon:is_mvps_stopper(checknode.name) or checknode.name == "ignore" then - return - end - - --check for column end - if checknode.name == "air" - or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then - break - end - - --limit piston pushing capacity - count = count + 1 - if count > 15 then - return - end - - checkpos = mesecon:addPosRule(checkpos, dir) - end - - local thisnode = minetest.env:get_node(pos) - minetest.env:remove_node(pos) - mesecon.on_dignode(pos, thisnode) - local nextnode - - --add pusher - if node.name == "mesecons_pistons:piston_normal" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2}) - elseif node.name == "mesecons_pistons:piston_sticky" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_sticky", param2=node.param2}) - elseif node.name == "mesecons_pistons:piston_up_normal" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_normal"}) - elseif node.name == "mesecons_pistons:piston_up_sticky" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_sticky"}) - elseif node.name == "mesecons_pistons:piston_down_normal" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_normal"}) - elseif node.name == "mesecons_pistons:piston_down_sticky" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_sticky"}) - end - - --move nodes forward - for i = 1, count do - pos = mesecon:addPosRule(pos, dir) --move to the next node - - nextnode = minetest.env:get_node(pos) - minetest.env:remove_node(pos) - mesecon.on_dignode(pos, thisnode) - minetest.env:add_node(pos, thisnode) - mesecon.on_placenode(pos, thisnode) - thisnode = nextnode - nodeupdate(pos) + local pistonspec = minetest.registered_nodes[node.name].mesecons_piston + if pitch > 55 then --looking upwards + minetest.env:add_node(pos, {name=pistonspec.piston_down}) + elseif pitch < -55 then --looking downwards + minetest.env:add_node(pos, {name=pistonspec.piston_up}) end end ---piston pull action -function mesecon:piston_pull(pos) - local node = minetest.env:get_node(pos) - local dir = mesecon:piston_get_direction(node) - pos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to first node being replaced - --ensure piston is extended - local checknode = minetest.env:get_node(pos) - if node.name == "mesecons_pistons:piston_up_normal" or node.name == "mesecons_pistons:piston_up_sticky" then --up piston - if checknode.name ~= "mesecons_pistons:piston_up_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_up_pusher_sticky" then - return --piston is not extended - end - elseif node.name == "mesecons_pistons:piston_down_normal" or node.name == "mesecons_pistons:piston_down_sticky" then --down piston - if checknode.name ~= "mesecons_pistons:piston_down_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_down_pusher_sticky" then - return --piston is not extended - end - else --horizontal piston - if checknode.name ~= "mesecons_pistons:piston_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_pusher_sticky" then - return --piston is not extended - end - if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston - return --piston is not extended - end - end +-- Horizontal pistons - --retract piston - minetest.env:remove_node(pos) --remove pusher - if minetest.registered_nodes[node.name].is_sticky_piston then --retract block if piston is sticky - local retractpos = mesecon:addPosRule(pos, dir) --move to the node to be retracted - local retractnode = minetest.env:get_node(retractpos) - if minetest.registered_nodes[retractnode.name].liquidtype == "none" - and not mesecon:is_mvps_stopper(retractnode.name) then - mesecon:move_node(retractpos, pos) - mesecon.on_dignode(retractpos, retractnode) - mesecon.on_placenode(pos, retractnode) - nodeupdate(pos) - end - end -end +local pt = 2/16 -- pusher thickness ---push direction of a piston -function mesecon:piston_get_direction(node) - if node.name == "mesecons_pistons:piston_up_normal" or node.name == "mesecons_pistons:piston_up_sticky" then - return {x=0, y=1, z=0} - elseif node.name == "mesecons_pistons:piston_down_normal" or node.name == "mesecons_pistons:piston_down_sticky" then - return {x=0, y=-1, z=0} - elseif node.param2 == 3 then - return {x=1, y=0, z=0} - elseif node.param2 == 2 then - return {x=0, y=0, z=1} - elseif node.param2 == 1 then - return {x=-1, y=0, z=0} - else --node.param2 == 0 - return {x=0, y=0, z=-1} - end -end +local piston_pusher_box = { + type = "fixed", + fixed = { + {-2/16, -2/16, -.5 + pt, 2/16, 2/16, .5 + pt}, + {-.5 , -.5 , -.5 , .5 , .5 , -.5 + pt}, + } +} ---horizontal pistons -minetest.register_node("mesecons_pistons:piston_normal", { +local piston_on_box = { + type = "fixed", + fixed = { + {-.5, -.5, -.5 + pt, .5, .5, .5} + } +} + + +-- Normal (non-sticky) ones: + +local pistonspec_normal = { + offname = "mesecons_pistons:piston_normal_off", + onname = "mesecons_pistons:piston_normal_on", + dir = piston_facedir_direction, + pusher = "mesecons_pistons:piston_pusher_normal", + piston_down = "mesecons_pistons:piston_down_normal_off", + piston_up = "mesecons_pistons:piston_up_normal_off", +} + +-- offstate +minetest.register_node("mesecons_pistons:piston_normal_off", { description = "Piston", tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"}, - groups = {cracky=3, mesecon=2}, + groups = {cracky = 3}, paramtype2 = "facedir", - after_destruct = destruct, - on_timer = timer, - after_place_node = function(pos, placer) - if not placer then --not placed by player - return - end - 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 - end, + after_place_node = piston_orientate, + mesecons_piston = pistonspec_normal, mesecons = {effector={ - action_change = update, + action_on = piston_on, rules = piston_get_rules }} }) -minetest.register_node("mesecons_pistons:piston_sticky", { - description = "Sticky Piston", - tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"}, - groups = {cracky=3, mesecon=2}, +-- onstate +minetest.register_node("mesecons_pistons:piston_normal_on", { + drawtype = "nodebox", + tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype = "light", paramtype2 = "facedir", - after_destruct = destruct, - on_timer = timer, - is_sticky_piston = true, - after_place_node = function(pos, placer) - if not placer then --not placed by player - return - end - 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 - end, + drop = {"mesecons_pistons:piston_normal_off"}, + after_dig_node = piston_remove_pusher, + node_box = piston_on_box, + selection_box = piston_on_box, + mesecons_piston = pistonspec_normal, mesecons = {effector={ - action_change = update, + action_off = piston_off, rules = piston_get_rules }} }) +-- pusher minetest.register_node("mesecons_pistons:piston_pusher_normal", { drawtype = "nodebox", tiles = {"jeija_piston_pusher_normal.png"}, paramtype = "light", paramtype2 = "facedir", diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, + corresponding_piston = "mesecons_pistons:piston_normal_on", + selection_box = piston_pusher_box, + node_box = piston_pusher_box, }) +-- Sticky ones + +local pistonspec_sticky = { + offname = "mesecons_pistons:piston_sticky_off", + onname = "mesecons_pistons:piston_sticky_on", + dir = piston_facedir_direction, + pusher = "mesecons_pistons:piston_pusher_sticky", + sticky = true, + piston_down = "mesecons_pistons:piston_down_sticky_off", + piston_up = "mesecons_pistons:piston_up_sticky_off", +} + +-- offstate +minetest.register_node("mesecons_pistons:piston_sticky_off", { + description = "Sticky Piston", + tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"}, + groups = {cracky = 3}, + paramtype2 = "facedir", + after_place_node = piston_orientate, + mesecons_piston = pistonspec_sticky, + mesecons = {effector={ + action_on = piston_on, + rules = piston_get_rules + }} +}) + +-- onstate +minetest.register_node("mesecons_pistons:piston_sticky_on", { + drawtype = "nodebox", + tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype = "light", + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_normal_off"}, + after_dig_node = piston_remove_pusher, + node_box = piston_on_box, + selection_box = piston_on_box, + mesecons_piston = pistonspec_sticky, + mesecons = {effector={ + action_off = piston_off, + rules = piston_get_rules + }} +}) + +-- pusher minetest.register_node("mesecons_pistons:piston_pusher_sticky", { drawtype = "nodebox", tiles = { @@ -269,70 +224,125 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", { paramtype = "light", paramtype2 = "facedir", diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, + corresponding_piston = "mesecons_pistons:piston_sticky_on", + selection_box = piston_pusher_box, + node_box = piston_pusher_box, }) -mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal") -mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky") +-- +-- +-- UP +-- +-- ---up pistons -minetest.register_node("mesecons_pistons:piston_up_normal", { +local piston_up_pusher_box = { + type = "fixed", + fixed = { + {-2/16, -.5 - pt, -2/16, 2/16, .5, 2/16}, + {-.5 , .5 - pt, -.5 , .5 , .5, .5}, + } +} + +local piston_up_on_box = { + type = "fixed", + fixed = { + {-.5, -.5, -.5 , .5, .5-pt, .5} + } +} + +-- Normal + +local pistonspec_normal_down = { + offname = "mesecons_pistons:piston_up_normal_off", + onname = "mesecons_pistons:piston_up_normal_on", + dir = {x = 0, y = 1, z = 0}, + pusher = "mesecons_pistons:piston_up_pusher_normal" +} + +-- offstate +minetest.register_node("mesecons_pistons:piston_up_normal_off", { tiles = {"jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_normal_off"}, + mesecons_piston = pistonspec_normal_down, mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_normal", + action_on = piston_on, + }} }) -minetest.register_node("mesecons_pistons:piston_up_sticky", { - tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, - is_sticky_piston = true, +-- onstate +minetest.register_node("mesecons_pistons:piston_up_normal_on", { + drawtype = "nodebox", + tiles = {"jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype = "light", + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_normal_off"}, + after_dig_node = piston_remove_pusher, + node_box = piston_up_on_box, + selection_box = piston_up_on_box, + mesecons_piston = pistonspec_normal_down, mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_sticky", + action_off = piston_off, + }} }) +-- pusher minetest.register_node("mesecons_pistons:piston_up_pusher_normal", { drawtype = "nodebox", tiles = {"jeija_piston_pusher_normal.png"}, paramtype = "light", + paramtype2 = "facedir", diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, + corresponding_piston = "mesecons_pistons:piston_up_normal_on", + selection_box = piston_up_pusher_box, + node_box = piston_up_pusher_box, }) + + +-- Sticky + + +local pistonspec_sticky_up = { + offname = "mesecons_pistons:piston_up_sticky_off", + onname = "mesecons_pistons:piston_up_sticky_on", + dir = {x = 0, y = 1, z = 0}, + pusher = "mesecons_pistons:piston_up_pusher_sticky", + sticky = true +} + +-- offstate +minetest.register_node("mesecons_pistons:piston_up_sticky_off", { + tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_sticky_off"}, + mesecons_piston = pistonspec_sticky_up, + mesecons = {effector={ + action_on = piston_on, + }} +}) + +-- onstate +minetest.register_node("mesecons_pistons:piston_up_sticky_on", { + drawtype = "nodebox", + tiles = {"jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype = "light", + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_normal_off"}, + after_dig_node = piston_remove_pusher, + node_box = piston_up_on_box, + selection_box = piston_up_on_box, + mesecons_piston = pistonspec_sticky_up, + mesecons = {effector={ + action_off = piston_off, + }} +}) + +-- pusher minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { drawtype = "nodebox", tiles = { @@ -344,71 +354,133 @@ minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { "jeija_piston_pusher_normal.png" }, paramtype = "light", + paramtype2 = "facedir", diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, + corresponding_piston = "mesecons_pistons:piston_up_sticky_on", + selection_box = piston_up_pusher_box, + node_box = piston_up_pusher_box, }) -mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal") -mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky") +-- +-- +-- DOWN +-- +-- ---down pistons -minetest.register_node("mesecons_pistons:piston_down_normal", { +local piston_down_pusher_box = { + type = "fixed", + fixed = { + {-2/16, -.5, -2/16, 2/16, .5 + pt, 2/16}, + {-.5 , -.5, -.5 , .5 , -.5 + pt, .5}, + } +} + +local piston_down_on_box = { + type = "fixed", + fixed = { + {-.5, -.5+pt, -.5 , .5, .5, .5} + } +} + + + +-- Normal + +local pistonspec_normal_down = { + offname = "mesecons_pistons:piston_down_normal_off", + onname = "mesecons_pistons:piston_down_normal_on", + dir = {x = 0, y = -1, z = 0}, + pusher = "mesecons_pistons:piston_down_pusher_normal", +} + +-- offstate +minetest.register_node("mesecons_pistons:piston_down_normal_off", { tiles = {"jeija_piston_tb.png", "jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_normal_off"}, + mesecons_piston = pistonspec_normal_down, mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_normal", + action_on = piston_on, + }} }) -minetest.register_node("mesecons_pistons:piston_down_sticky", { - tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, - is_sticky_piston = true, +-- onstate +minetest.register_node("mesecons_pistons:piston_down_normal_on", { + drawtype = "nodebox", + tiles = {"jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype = "light", + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_normal_off"}, + after_dig_node = piston_remove_pusher, + node_box = piston_down_on_box, + selection_box = piston_down_on_box, + mesecons_piston = pistonspec_normal_down, mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_sticky", + action_off = piston_off, + }} }) +-- pusher minetest.register_node("mesecons_pistons:piston_down_pusher_normal", { drawtype = "nodebox", - tiles = {"jeija_piston_pusher_normal.png"}, + tiles = { + "jeija_piston_pusher_sticky.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png", + "jeija_piston_pusher_normal.png" + }, paramtype = "light", + paramtype2 = "facedir", diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, + corresponding_piston = "mesecons_pistons:piston_down_normal_on", + selection_box = piston_down_pusher_box, + node_box = piston_down_pusher_box, }) +-- Sticky + +local pistonspec_sticky_down = { + onname = "mesecons_pistons:piston_down_sticky_on", + offname = "mesecons_pistons:piston_down_sticky_off", + dir = {x = 0, y = -1, z = 0}, + pusher = "mesecons_pistons:piston_down_pusher_sticky", + sticky = true +} + +-- offstate +minetest.register_node("mesecons_pistons:piston_down_sticky_off", { + tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_sticky_off"}, + mesecons_piston = pistonspec_sticky_down, + mesecons = {effector={ + action_on = piston_on, + }} +}) + +-- onstate +minetest.register_node("mesecons_pistons:piston_down_sticky_on", { + drawtype = "nodebox", + tiles = {"jeija_piston_tb.png"}, + groups = {cracky = 3, not_in_creative_inventory = 1}, + paramtype = "light", + paramtype2 = "facedir", + drop = {"mesecons_pistons:piston_sticky_off"}, + after_dig_node = piston_remove_pusher, + node_box = piston_down_on_box, + selection_box = piston_down_on_box, + mesecons_piston = pistonspec_sticky_down, + mesecons = {effector={ + action_off = piston_off, + }} +}) + +-- pusher minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { drawtype = "nodebox", tiles = { @@ -420,25 +492,78 @@ minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { "jeija_piston_pusher_normal.png" }, paramtype = "light", + paramtype2 = "facedir", diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, + corresponding_piston = "mesecons_pistons:piston_down_sticky_on", + selection_box = piston_down_pusher_box, + node_box = piston_down_pusher_box, }) -mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal") -mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky") + +-- Register pushers as stoppers if they would be seperated from the piston +local piston_pusher_get_stopper = function (node, dir, stack, stackid) + if (stack[stackid + 1] + and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].corresponding_piston + and stack[stackid + 1].node.param2 == node.param2) + or (stack[stackid - 1] + and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].corresponding_piston + and stack[stackid - 1].node.param2 == node.param2) then + return false + end + return true +end + +local piston_pusher_up_down_get_stopper = function (node, dir, stack, stackid) + if (stack[stackid + 1] + and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].corresponding_piston) + or (stack[stackid - 1] + and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].corresponding_piston) then + return false + end + return true +end + +mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal", piston_pusher_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky", piston_pusher_get_stopper) + +mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal", piston_pusher_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky", piston_pusher_up_down_get_stopper) + +mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal", piston_pusher_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky", piston_pusher_up_down_get_stopper) + + +-- Register pistons as stoppers if they would be seperated from the stopper +local piston_up_down_get_stopper = function (node, dir, stack, stackid) + if (stack[stackid + 1] + and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher) + or (stack[stackid - 1] + and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher) then + return false + end + return true +end + +local piston_get_stopper = function (node, dir, stack, stackid) + if (stack[stackid + 1] + and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher + and stack[stackid + 1].node.param2 == node.param2) + or (stack[stackid - 1] + and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher + and stack[stackid + 1].node.param2 == node.param2) then + return false + end + return true +end + +mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_pusher_get_stopper) + +mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_up_down_get_stopper) + +mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_up_down_get_stopper) --craft recipes minetest.register_craft({ From 5a88a9715fc822d02d06b7f03a8bbf0e7c9ad7ba Mon Sep 17 00:00:00 2001 From: Jeija Date: Wed, 26 Dec 2012 22:55:01 +0100 Subject: [PATCH 16/28] Re-write pistons from scratch, propably fixes a lot of bugs and doesn't cause too many new ones. --- .mesecons_pistons/depends.txt | 3 - .mesecons_pistons/init.lua | 459 ---------------------------------- 2 files changed, 462 deletions(-) delete mode 100644 .mesecons_pistons/depends.txt delete mode 100644 .mesecons_pistons/init.lua diff --git a/.mesecons_pistons/depends.txt b/.mesecons_pistons/depends.txt deleted file mode 100644 index a596cf8..0000000 --- a/.mesecons_pistons/depends.txt +++ /dev/null @@ -1,3 +0,0 @@ -mesecons -mesecons_materials -mesecons_mvps diff --git a/.mesecons_pistons/init.lua b/.mesecons_pistons/init.lua deleted file mode 100644 index 0a3838d..0000000 --- a/.mesecons_pistons/init.lua +++ /dev/null @@ -1,459 +0,0 @@ ---PISTONS - --- Get mesecon rules of pistons -piston_rules = -{{x=0, y=0, z=1}, --everything apart from z- (pusher side) - {x=1, y=0, z=0}, - {x=-1, y=0, z=0}, - {x=1, y=1, z=0}, - {x=1, y=-1, z=0}, - {x=-1, y=1, z=0}, - {x=-1, y=-1, z=0}, - {x=0, y=1, z=1}, - {x=0, y=-1, z=1}} - -local piston_get_rules = function (node) - local rules = piston_rules - for i = 1, node.param2 do - rules = mesecon:rotate_rules_left(rules) - end - return rules -end - ---starts the timer to make the piston update to its new state -local update = function(pos, node) - local timer = minetest.env:get_node_timer(pos) - timer:stop() - timer:start(0) -end - ---on_destruct callback, removes the piston pusher if it is present -local destruct = function(pos, oldnode) - local dir = mesecon:piston_get_direction(oldnode) - pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check - - --ensure piston is extended - local checknode = minetest.env:get_node(pos) - if checknode.name == "mesecons_pistons:piston_pusher_normal" - or checknode.name == "mesecons_pistons:piston_pusher_sticky" then - if checknode.param2 == oldnode.param2 then --pusher is facing the same direction as the piston - minetest.env:remove_node(pos) --remove the pusher - end - elseif oldnode.name == "mesecons_pistons:piston_up_normal" or oldnode.name == "mesecons_pistons:piston_up_sticky" then - if checknode.name == "mesecons_pistons:piston_up_pusher_normal" or checknode.name == "mesecons_pistons:piston_up_pusher_sticky" then - minetest.env:remove_node(pos) --remove the pusher - end - elseif oldnode.name == "mesecons_pistons:piston_down_normal" or oldnode.name == "mesecons_pistons:piston_down_sticky" then - if checknode.name == "mesecons_pistons:piston_down_pusher_normal" or checknode.name == "mesecons_pistons:piston_down_pusher_sticky" then - minetest.env:remove_node(pos) --remove the pusher - end - end -end - ---node timer callback, pushes/pulls the piston depending on whether it is powered -local timer = function(pos, elapsed) - if mesecon:is_powered(pos) then - mesecon:piston_push(pos) - else - mesecon:piston_pull(pos) - end - return false -end - ---piston push action -function mesecon:piston_push(pos) - local node = minetest.env:get_node(pos) - local dir = mesecon:piston_get_direction(node) - pos = mesecon:addPosRule(pos, dir) --move to first node being pushed - - --determine the number of nodes that need to be pushed - local count = 0 - local checkpos = {x=pos.x, y=pos.y, z=pos.z} --first node being pushed - - while true do - local checknode = minetest.env:get_node(checkpos) - - --check for collision with stopper or bounds - if mesecon:is_mvps_stopper(checknode.name) or checknode.name == "ignore" then - return - end - - --check for column end - if checknode.name == "air" - or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then - break - end - - --limit piston pushing capacity - count = count + 1 - if count > 15 then - return - end - - checkpos = mesecon:addPosRule(checkpos, dir) - end - - local thisnode = minetest.env:get_node(pos) - minetest.env:remove_node(pos) - mesecon.on_dignode(pos, thisnode) - local nextnode - - --add pusher - if node.name == "mesecons_pistons:piston_normal" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2}) - elseif node.name == "mesecons_pistons:piston_sticky" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_sticky", param2=node.param2}) - elseif node.name == "mesecons_pistons:piston_up_normal" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_normal"}) - elseif node.name == "mesecons_pistons:piston_up_sticky" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_up_pusher_sticky"}) - elseif node.name == "mesecons_pistons:piston_down_normal" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_normal"}) - elseif node.name == "mesecons_pistons:piston_down_sticky" then - minetest.env:add_node(pos, {name="mesecons_pistons:piston_down_pusher_sticky"}) - end - - --move nodes forward - for i = 1, count do - pos = mesecon:addPosRule(pos, dir) --move to the next node - - nextnode = minetest.env:get_node(pos) - minetest.env:remove_node(pos) - mesecon.on_dignode(pos, thisnode) - minetest.env:add_node(pos, thisnode) - mesecon.on_placenode(pos, thisnode) - thisnode = nextnode - nodeupdate(pos) - end -end - ---piston pull action -function mesecon:piston_pull(pos) - local node = minetest.env:get_node(pos) - local dir = mesecon:piston_get_direction(node) - pos = {x=pos.x + dir.x, y=pos.y + dir.y, z=pos.z + dir.z} --move to first node being replaced - - --ensure piston is extended - local checknode = minetest.env:get_node(pos) - if node.name == "mesecons_pistons:piston_up_normal" or node.name == "mesecons_pistons:piston_up_sticky" then --up piston - if checknode.name ~= "mesecons_pistons:piston_up_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_up_pusher_sticky" then - return --piston is not extended - end - elseif node.name == "mesecons_pistons:piston_down_normal" or node.name == "mesecons_pistons:piston_down_sticky" then --down piston - if checknode.name ~= "mesecons_pistons:piston_down_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_down_pusher_sticky" then - return --piston is not extended - end - else --horizontal piston - if checknode.name ~= "mesecons_pistons:piston_pusher_normal" and checknode.name ~= "mesecons_pistons:piston_pusher_sticky" then - return --piston is not extended - end - if checknode.param2 ~= node.param2 then --pusher is not facing the same direction as the piston - return --piston is not extended - end - end - - --retract piston - minetest.env:remove_node(pos) --remove pusher - if minetest.registered_nodes[node.name].is_sticky_piston then --retract block if piston is sticky - local retractpos = mesecon:addPosRule(pos, dir) --move to the node to be retracted - local retractnode = minetest.env:get_node(retractpos) - if minetest.registered_nodes[retractnode.name].liquidtype == "none" - and not mesecon:is_mvps_stopper(retractnode.name) then - mesecon:move_node(retractpos, pos) - mesecon.on_dignode(retractpos, retractnode) - mesecon.on_placenode(pos, retractnode) - nodeupdate(pos) - end - end -end - ---push direction of a piston -function mesecon:piston_get_direction(node) - if node.name == "mesecons_pistons:piston_up_normal" or node.name == "mesecons_pistons:piston_up_sticky" then - return {x=0, y=1, z=0} - elseif node.name == "mesecons_pistons:piston_down_normal" or node.name == "mesecons_pistons:piston_down_sticky" then - return {x=0, y=-1, z=0} - elseif node.param2 == 3 then - return {x=1, y=0, z=0} - elseif node.param2 == 2 then - return {x=0, y=0, z=1} - elseif node.param2 == 1 then - return {x=-1, y=0, z=0} - else --node.param2 == 0 - return {x=0, y=0, z=-1} - end -end - ---horizontal pistons -minetest.register_node("mesecons_pistons:piston_normal", { - description = "Piston", - tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"}, - groups = {cracky=3, mesecon=2}, - paramtype2 = "facedir", - after_destruct = destruct, - on_timer = timer, - after_place_node = function(pos, placer) - if not placer then --not placed by player - return - end - 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 - end, - mesecons = {effector={ - action_change = update, - rules = piston_get_rules - }} -}) - -minetest.register_node("mesecons_pistons:piston_sticky", { - description = "Sticky Piston", - tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"}, - groups = {cracky=3, mesecon=2}, - paramtype2 = "facedir", - after_destruct = destruct, - on_timer = timer, - is_sticky_piston = true, - after_place_node = function(pos, placer) - if not placer then --not placed by player - return - end - 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 - end, - mesecons = {effector={ - action_change = update, - rules = piston_get_rules - }} -}) - -minetest.register_node("mesecons_pistons:piston_pusher_normal", { - drawtype = "nodebox", - tiles = {"jeija_piston_pusher_normal.png"}, - paramtype = "light", - paramtype2 = "facedir", - diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, -}) - -minetest.register_node("mesecons_pistons:piston_pusher_sticky", { - drawtype = "nodebox", - tiles = { - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_sticky.png" - }, - paramtype = "light", - paramtype2 = "facedir", - diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.2, -0.3, 0.2, 0.2, 0.5}, - {-0.5, -0.5, -0.5, 0.5, 0.5, -0.3}, - }, - }, -}) - -mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal") -mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky") - --- up pistons -minetest.register_node("mesecons_pistons:piston_up_normal", { - tiles = {"jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, - mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_normal", -}) - -minetest.register_node("mesecons_pistons:piston_up_sticky", { - tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, - is_sticky_piston = true, - mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_sticky", -}) - -minetest.register_node("mesecons_pistons:piston_up_pusher_normal", { - drawtype = "nodebox", - tiles = {"jeija_piston_pusher_normal.png"}, - paramtype = "light", - diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, -}) - -minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { - drawtype = "nodebox", - tiles = { - "jeija_piston_pusher_sticky.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png" - }, - paramtype = "light", - diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.5, -0.2, 0.2, 0.3, 0.2}, - {-0.5, 0.3, -0.5, 0.5, 0.5, 0.5}, - }, - }, -}) - -mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal") -mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky") - ---down pistons -minetest.register_node("mesecons_pistons:piston_down_normal", { - tiles = {"jeija_piston_tb.png", "jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, - mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_normal", -}) - -minetest.register_node("mesecons_pistons:piston_down_sticky", { - tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, - groups = {cracky=3, mesecon=2}, - after_destruct = destruct, - on_timer = timer, - is_sticky_piston = true, - mesecons = {effector={ - action_change = update - }}, - drop = "mesecons_pistons:piston_sticky", -}) - -minetest.register_node("mesecons_pistons:piston_down_pusher_normal", { - drawtype = "nodebox", - tiles = {"jeija_piston_pusher_normal.png"}, - paramtype = "light", - diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, -}) - -minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { - drawtype = "nodebox", - tiles = { - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_sticky.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png" - }, - paramtype = "light", - diggable = false, - selection_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, - node_box = { - type = "fixed", - fixed = { - {-0.2, -0.3, -0.2, 0.2, 0.5, 0.2}, - {-0.5, -0.5, -0.5, 0.5, -0.3, 0.5}, - }, - }, -}) - -mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal") -mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky") - ---craft recipes -minetest.register_craft({ - output = '"mesecons_pistons:piston_normal" 2', - recipe = { - {"default:wood", "default:wood", "default:wood"}, - {"default:cobble", "default:steel_ingot", "default:cobble"}, - {"default:cobble", "group:mesecon_conductor_craftable", "default:cobble"}, - } -}) - -minetest.register_craft({ - output = "mesecons_pistons:piston_sticky", - recipe = { - {"mesecons_materials:glue"}, - {"mesecons_pistons:piston_normal"}, - } -}) From 7fe4947056656982ee9af9fad8d67d14e7086c9a Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 27 Dec 2012 09:28:04 +0100 Subject: [PATCH 17/28] Bugfix foes for pistons, delayyrs, gates and microcontrollers. Rework delayers. --- mesecons/init.lua | 3 +- mesecons/internal.lua | 37 +++++++++++----- mesecons_delayer/init.lua | 92 ++++++++++++++------------------------- mesecons_mvps/init.lua | 2 +- 4 files changed, 62 insertions(+), 72 deletions(-) diff --git a/mesecons/init.lua b/mesecons/init.lua index f53a5bf..011c96f 100644 --- a/mesecons/init.lua +++ b/mesecons/init.lua @@ -70,6 +70,7 @@ dofile(minetest.get_modpath("mesecons").."/internal.lua"); -- Deprecated stuff -- To be removed in future releases +-- Currently there is nothing here dofile(minetest.get_modpath("mesecons").."/legacy.lua"); -- API @@ -100,7 +101,7 @@ function mesecon:receptor_off(pos, rules) end -print("[OK] mesecons") +print("[OK] Mesecons") --The actual wires dofile(minetest.get_modpath("mesecons").."/wires.lua"); diff --git a/mesecons/internal.lua b/mesecons/internal.lua index c7efd1a..2d84787 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -331,9 +331,26 @@ function mesecon:turnoff(pos, rulename) end -function mesecon:connected_to_receptor(pos, checked) - checked = checked or {} +function mesecon:connected_to_receptor(pos) + local node = minetest.env:get_node(pos) + -- Check if conductors around are connected + local rules = mesecon:get_any_inputrules(node) + if not rules then return false end + + for _, rule in ipairs(rules) do + local np = mesecon:addPosRule(pos, rule) + if mesecon:rules_link(np, pos) then + if mesecon:find_receptor_on(np, {}) then + return true + end + end + end + + return false +end + +function mesecon:find_receptor_on(pos, checked) -- find out if node has already been checked (to prevent from endless loop) for _, cp in ipairs(checked) do if mesecon:cmpPos(cp, pos) then @@ -343,27 +360,25 @@ function mesecon:connected_to_receptor(pos, checked) -- add current position to checked table.insert(checked, {x=pos.x, y=pos.y, z=pos.z}) - local node = minetest.env:get_node(pos) - if mesecon:is_conductor(node.name) then - -- Check if conductors around are connected - local rules = mesecon:conductor_get_rules(node) + if mesecon:is_receptor_on(node.name) then + return true + end + if mesecon:is_conductor(node.name) then + local rules = mesecon:conductor_get_rules(node) for _, rule in ipairs(rules) do local np = mesecon:addPosRule(pos, rule) if mesecon:rules_link(np, pos) then - connected, checked = mesecon:connected_to_receptor(np, checked) - if connected then + if mesecon:find_receptor_on(np, checked) then return true end end end - elseif mesecon:is_receptor_on(node.name) then - return true end - return false, checked + return false end function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua index 6bdb72d..2175c3c 100644 --- a/mesecons_delayer/init.lua +++ b/mesecons_delayer/init.lua @@ -1,28 +1,16 @@ -- Function that get the input/output rules of the delayer local delayer_get_output_rules = function(node) - local rules = {} - if node.param2 == 0 then - table.insert(rules, {x = 1, y = 0, z = 0}) - elseif node.param2 == 2 then - table.insert(rules, {x =-1, y = 0, z = 0}) - elseif node.param2 == 1 then - table.insert(rules, {x = 0, y = 0, z =-1}) - elseif node.param2 == 3 then - table.insert(rules, {x = 0, y = 0, z = 1}) + local rules = {{x = 0, y = 0, z = 1}} + for i = 0, node.param2 do + rules = mesecon:rotate_rules_left(rules) end return rules end local delayer_get_input_rules = function(node) - local rules = {} - if node.param2 == 0 then - table.insert(rules, {x =-1, y = 0, z = 0}) - elseif node.param2 == 2 then - table.insert(rules, {x = 1, y = 0, z = 0}) - elseif node.param2 == 1 then - table.insert(rules, {x = 0, y = 0, z = 1}) - elseif node.param2 == 3 then - table.insert(rules, {x = 0, y = 0, z =-1}) + local rules = {{x = 0, y = 0, z = -1}} + for i = 0, node.param2 do + rules = mesecon:rotate_rules_left(rules) end return rules end @@ -30,54 +18,30 @@ end -- Functions that are called after the delay time local delayer_turnon = function(params) - local rules = delayer_get_output_rules(params) + local rules = delayer_get_output_rules(params.node) mesecon:receptor_on(params.pos, rules) end local delayer_turnoff = function(params) - local rules = delayer_get_output_rules(params) + local rules = delayer_get_output_rules(params.node) mesecon:receptor_off(params.pos, rules) end -local delayer_update = function(pos, node) - if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then - local time = 0 - if node.name=="mesecons_delayer:delayer_off_1" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_on_1") - time=0.1 - elseif node.name=="mesecons_delayer:delayer_off_2" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_on_2") - time=0.3 - elseif node.name=="mesecons_delayer:delayer_off_3" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_on_3") - time=0.5 - elseif node.name=="mesecons_delayer:delayer_off_4" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_on_4") - time=1 - end - minetest.after(time, delayer_turnon, {pos=pos, param2=node.param2}) - end - - if string.find(node.name, "mesecons_delayer:delayer_on")~=nil then - local time = 0 - if node.name=="mesecons_delayer:delayer_on_1" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_off_1") - time=0.1 - elseif node.name=="mesecons_delayer:delayer_on_2" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_off_2") - time=0.3 - elseif node.name=="mesecons_delayer:delayer_on_3" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_off_3") - time=0.5 - elseif node.name=="mesecons_delayer:delayer_on_4" then - mesecon:swap_node(pos, "mesecons_delayer:delayer_off_4") - time=1 - end - minetest.after(time, delayer_turnoff, {pos=pos, param2=node.param2}) - end +local delayer_activate = function(pos, node) + local def = minetest.registered_nodes[node.name] + local time = def.delayer_time + mesecon:swap_node(pos, def.delayer_onstate) + minetest.after(time, delayer_turnon , {pos = pos, node = node}) end ---Actually register the 2 (states) x 4 (delay times) delayers +local delayer_deactivate = function(pos, node) + local def = minetest.registered_nodes[node.name] + local time = def.delayer_time + mesecon:swap_node(pos, def.delayer_offstate) + minetest.after(time, delayer_turnoff, {pos = pos, node = node}) +end + +-- Register the 2 (states) x 4 (delay times) delayers for i = 1, 4 do local groups = {} @@ -87,6 +51,12 @@ else groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1} end +local delaytime +if i == 1 then delaytime = 0.1 +elseif i == 2 then delaytime = 0.3 +elseif i == 3 then delaytime = 0.5 +elseif i == 4 then delaytime = 1.0 end + boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab { -2/16, -7/16, -4/16, 2/16, -26/64, -3/16 }, -- the jeweled "on" indicator @@ -138,6 +108,8 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { mesecon:swap_node(pos,"mesecons_delayer:delayer_off_1") end end, + delayer_time = delaytime, + delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i), mesecons = { receptor = { @@ -147,7 +119,7 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { effector = { rules = delayer_get_input_rules, - action_change = delayer_update + action_on = delayer_activate } } }) @@ -190,6 +162,8 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { mesecon:swap_node(pos,"mesecons_delayer:delayer_on_1") end end, + delayer_time = delaytime, + delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i), mesecons = { receptor = { @@ -199,7 +173,7 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { effector = { rules = delayer_get_input_rules, - action_change = delayer_update + action_off = delayer_deactivate } } }) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index 57c538d..98bbc94 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -20,7 +20,7 @@ end function mesecon:mvps_process_stack(stack) -- update mesecons for placed nodes ( has to be done after all nodes have been added ) for _, n in ipairs(stack) do - mesecon.on_placenode(n.pos, n.node) + mesecon.on_placenode(n.pos, minetest.env:get_node(n.pos)) mesecon:update_autoconnect(n.pos) end end From d1ace465c7d5c3153dcab84fd4ba2b9d235028a6 Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 27 Dec 2012 09:54:19 +0100 Subject: [PATCH 18/28] Add experimental 'corner' wire, an insulated bended wire (needs textures and maybe rename it) --- mesecons_extrawires/corner.lua | 83 +++++++++++++++++++++++++++++++ mesecons_extrawires/init.lua | 1 + mesecons_extrawires/tjunction.lua | 15 +++--- mesecons_insulated/init.lua | 2 +- 4 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 mesecons_extrawires/corner.lua diff --git a/mesecons_extrawires/corner.lua b/mesecons_extrawires/corner.lua new file mode 100644 index 0000000..885a1ca --- /dev/null +++ b/mesecons_extrawires/corner.lua @@ -0,0 +1,83 @@ +local corner_nodebox = { + type = "fixed", + fixed = {{ -16/32-0.001, -17/32, -3/32, 0, -13/32, 3/32 }, + { -3/32, -17/32, -16/32+0.001, 3/32, -13/32, 3/32}} +} + +local corner_selectionbox = { + type = "fixed", + fixed = { -16/32-0.001, -18/32, -16/32, 5/32, -12/32, 5/32 }, +} + +local corner_get_rules = function (node) + local rules = + {{x = 1, y = 0, z = 0}, + {x = 0, y = 0, z = -1}} + + for i = 0, node.param2 do + rules = mesecon:rotate_rules_left(rules) + end + + return rules +end + +minetest.register_node("mesecons_extrawires:corner_on", { + drawtype = "nodebox", + tiles = { + "jeija_insulated_wire_sides_on.png", + "jeija_insulated_wire_sides_on.png", + "jeija_insulated_wire_ends_on.png", + "jeija_insulated_wire_ends_on.png", + "jeija_insulated_wire_sides_on.png", + "jeija_insulated_wire_ends_on.png" + }, + paramtype = "light", + paramtype2 = "facedir", + walkable = false, + sunlight_propagates = true, + selection_box = corner_selectionbox, + node_box = corner_nodebox, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, + drop = "mesecons_extrawires:insulated_off", + mesecons = {conductor = + { + state = mesecon.state.on, + rules = corner_get_rules, + offstate = "mesecons_extrawires:corner_off" + }} +}) + +minetest.register_node("mesecons_extrawires:corner_off", { + drawtype = "nodebox", + description = "Mesecon Corner", + tiles = { + "jeija_insulated_wire_sides_off.png", + "jeija_insulated_wire_sides_off.png", + "jeija_insulated_wire_ends_off.png", + "jeija_insulated_wire_ends_off.png", + "jeija_insulated_wire_sides_off.png", + "jeija_insulated_wire_ends_off.png" + }, + paramtype = "light", + paramtype2 = "facedir", + walkable = false, + sunlight_propagates = true, + selection_box = corner_selectionbox, + node_box = corner_nodebox, + groups = {dig_immediate = 3}, + mesecons = {conductor = + { + state = mesecon.state.off, + rules = corner_get_rules, + onstate = "mesecons_extrawires:corner_on" + }} +}) + +minetest.register_craft({ + output = '"mesecons_extrawires:corner_off" 3', + recipe = { + {"", "", ""}, + {"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", ""}, + {"", "mesecons_insulated:insulated_off", ""}, + } +}) diff --git a/mesecons_extrawires/init.lua b/mesecons_extrawires/init.lua index 31dfcd2..ec51a93 100644 --- a/mesecons_extrawires/init.lua +++ b/mesecons_extrawires/init.lua @@ -1,4 +1,5 @@ -- dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua"); -- The crossing code is not active right now because it is hard to maintain dofile(minetest.get_modpath("mesecons_extrawires").."/tjunction.lua"); +dofile(minetest.get_modpath("mesecons_extrawires").."/corner.lua"); dofile(minetest.get_modpath("mesecons_extrawires").."/vertical.lua"); diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua index aa100f5..9188b5b 100644 --- a/mesecons_extrawires/tjunction.lua +++ b/mesecons_extrawires/tjunction.lua @@ -11,17 +11,14 @@ local tjunction_selectionbox = { local tjunction_get_rules = function (node) local rules = - {{x = 1, y = 0, z = 0}, - {x =-1, y = 0, z = 0}, - {x = 0, y = 0, z = -1}} + {{x = 0, y = 0, z = 1}, + {x = 1, y = 0, z = 0}, + {x = 0, y = 0, z = -1}} - if node.param2 == 1 then + for i = 0, node.param2 do rules = mesecon:rotate_rules_left(rules) - elseif node.param2 == 2 then - rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) - elseif node.param2 == 3 then - rules = mesecon:rotate_rules_right(rules) end + return rules end @@ -42,7 +39,7 @@ minetest.register_node("mesecons_extrawires:tjunction_on", { selection_box = tjunction_selectionbox, node_box = tjunction_nodebox, groups = {dig_immediate = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1}, - drop = "mesecons_insulated:insulated_off", + drop = "mesecons_extrawires:tjunction_off", mesecons = {conductor = { state = mesecon.state.on, diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua index 37f64c8..77bfd24 100644 --- a/mesecons_insulated/init.lua +++ b/mesecons_insulated/init.lua @@ -9,7 +9,7 @@ end minetest.register_node("mesecons_insulated:insulated_on", { drawtype = "nodebox", - description = "insulated mesecons", + description = "Insulated Mesecon", tiles = { "jeija_insulated_wire_sides_on.png", "jeija_insulated_wire_sides_on.png", From ac0fb9113997e87c724ed5ece9e9914936ed6a3b Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 27 Dec 2012 10:50:20 +0100 Subject: [PATCH 19/28] Minor cleanup of mesecno torch and add another rule to it (behind above) --- mesecons/internal.lua | 8 +-- mesecons_torch/init.lua | 140 +++++++++++++++++++--------------------- 2 files changed, 69 insertions(+), 79 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index 2d84787..ac16103 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -428,7 +428,7 @@ end --Rules rotation Functions: function mesecon:rotate_rules_right(rules) - local nr = {} + nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = -rule.z, @@ -439,7 +439,7 @@ function mesecon:rotate_rules_right(rules) end function mesecon:rotate_rules_left(rules) - local nr = {} + nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = rule.z, @@ -450,7 +450,7 @@ function mesecon:rotate_rules_left(rules) end function mesecon:rotate_rules_down(rules) - local nr = {} + nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = -rule.y, @@ -461,7 +461,7 @@ function mesecon:rotate_rules_down(rules) end function mesecon:rotate_rules_up(rules) - local nr = {} + nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = rule.y, diff --git a/mesecons_torch/init.lua b/mesecons_torch/init.lua index 8b9a59b..801220e 100644 --- a/mesecons_torch/init.lua +++ b/mesecons_torch/init.lua @@ -1,53 +1,54 @@ --MESECON TORCHES -local torch_get_rules = function(node) - local rules = { - {x=1, y=0, z=0}, - {x=0, y=0, z=1}, - {x=0, y=0, z=-1}, - {x=0, y=1, z=0}, - {x=0, y=-1, z=0}} - if node.param2 == 5 then - rules=mesecon:rotate_rules_right(rules) - elseif node.param2 == 2 then - rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) --180 degrees - elseif node.param2 == 4 then - rules=mesecon:rotate_rules_left(rules) - elseif node.param2 == 1 then - rules=mesecon:rotate_rules_down(rules) - elseif node.param2 == 0 then - rules=mesecon:rotate_rules_up(rules) +local rotate_torch_rules = function (rules, param2) + if param2 == 5 then + return mesecon:rotate_rules_right(rules) + elseif param2 == 2 then + return mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) --180 degrees + elseif param2 == 4 then + return mesecon:rotate_rules_left(rules) + elseif param2 == 1 then + return mesecon:rotate_rules_down(rules) + elseif param2 == 0 then + return mesecon:rotate_rules_up(rules) + else + return rules end - return rules +end + +local torch_get_output_rules = function(node) + local rules = { + {x = 1, y = 0, z = 0}, + {x = 0, y = 0, z = 1}, + {x = 0, y = 0, z =-1}, + {x = 0, y = 1, z = 0}, + {x = 0, y =-1, z = 0}} + + return rotate_torch_rules(rules, node.param2) end local torch_get_input_rules = function(node) - local rules = {x=0, y=0, z=0} + local rules = {{x = -2, y = 0, z = 0}, + {x = -1, y = 1, z = 0}} - if node.param2 == 4 then - rules.z = -2 - elseif node.param2 == 2 then - rules.x = -2 - elseif node.param2 == 5 then - rules.z = 2 - elseif node.param2 == 3 then - rules.x = 2 - elseif node.param2 == 1 then - rules.y = 2 - elseif node.param2 == 0 then - rules.y = -2 - end - return rules + return rotate_torch_rules(rules, node.param2) end minetest.register_craft({ output = '"mesecons_torch:mesecon_torch_on" 4', recipe = { - {"group:mesecon_conductor_craftable"}, - {"default:stick"}, - } + {"group:mesecon_conductor_craftable"}, + {"default:stick"},} }) +local torch_selectionbox = +{ + type = "wallmounted", + wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, + wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1}, +} + minetest.register_node("mesecons_torch:mesecon_torch_off", { drawtype = "torchlike", tiles = {"jeija_torches_off.png", "jeija_torches_off_ceiling.png", "jeija_torches_off_side.png"}, @@ -55,19 +56,12 @@ minetest.register_node("mesecons_torch:mesecon_torch_off", { paramtype = "light", walkable = false, paramtype2 = "wallmounted", - selection_box = { - type = "wallmounted", - wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, - wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, - wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1}, - }, - legacy_wallmounted = true, - groups = {dig_immediate=3,not_in_creative_inventory=1}, - drop = '"mesecons_torch:mesecon_torch_on" 1', - description="Mesecon Torch", + selection_box = torch_selectionbox, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, + drop = "mesecons_torch:mesecon_torch_on", mesecons = {receptor = { state = mesecon.state.off, - rules = torch_get_rules + rules = torch_get_output_rules }} }) @@ -80,43 +74,39 @@ minetest.register_node("mesecons_torch:mesecon_torch_on", { sunlight_propagates = true, walkable = false, paramtype2 = "wallmounted", - selection_box = { - type = "wallmounted", - wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1}, - wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1}, - wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1}, - }, - legacy_wallmounted = true, + selection_box = torch_selectionbox, groups = {dig_immediate=3}, light_source = LIGHT_MAX-5, description="Mesecon Torch", mesecons = {receptor = { state = mesecon.state.on, - rules = torch_get_rules - }} + rules = torch_get_output_rules + }}, }) minetest.register_abm({ - nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"}, - interval = 1, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local node = minetest.env:get_node(pos) - local pa = torch_get_input_rules(node) + nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"}, + interval = 1, + chance = 1, + action = function(pos, node) + local is_powered = false + for _, rule in ipairs(torch_get_input_rules(node)) do + local src = mesecon:addPosRule(pos, rule) + if mesecon:is_power_on(src) then + is_powered = true + end + end - local postc = {x=pos.x-pa.x, y=pos.y-pa.y, z=pos.z-pa.z} - if mesecon:is_power_on(postc) then - if node.name ~= "mesecons_torch:mesecon_torch_off" then - minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_off",param2=node.param2}) - mesecon:receptor_off(pos, torch_get_rules(node)) - end - else - if node.name ~= "mesecons_torch:mesecon_torch_on" then - minetest.env:add_node(pos, {name="mesecons_torch:mesecon_torch_on",param2=node.param2}) - mesecon:receptor_on(pos, torch_get_rules(node)) - end - end - end + if is_powered then + if node.name == "mesecons_torch:mesecon_torch_on" then + mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off") + mesecon:receptor_off(pos, torch_get_output_rules(node)) + end + elseif node.name == "mesecons_torch:mesecon_torch_off" then + mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on") + mesecon:receptor_on(pos, torch_get_output_rules(node)) + end + end }) -- Param2 Table (Block Attached To) From d3b77b5be33b7103b5fe3fc07246c903b02b2d90 Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 27 Dec 2012 12:03:05 +0100 Subject: [PATCH 20/28] Compatibility with old pistons --- mesecons_alias/init.lua | 8 +++++++- mesecons_pistons/init.lua | 19 +++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/mesecons_alias/init.lua b/mesecons_alias/init.lua index eaebbc6..395c368 100644 --- a/mesecons_alias/init.lua +++ b/mesecons_alias/init.lua @@ -11,7 +11,7 @@ minetest.register_alias("mesecons:wireless_receiver", "mesecons_wireless:wireles minetest.register_alias("mesecons:wireless_transmitter", "mesecons_wireless:wireless_transmitter_off") minetest.register_alias("mesecons:switch", "mesecons_switch:mesecon_switch_off") minetest.register_alias("mesecons:button", "mesecons_button:button_off") -minetest.register_alias("mesecons:piston", "mesecons_pistons:piston_normal") +minetest.register_alias("mesecons:piston", "mesecons_pistons:piston_normal_off") minetest.register_alias("mesecons:blinky_plant", "mesecons_blinkyplant:blinky_plant_off") minetest.register_alias("mesecons:mesecon_torch", "mesecons_torch:mesecon_torch_on") minetest.register_alias("mesecons:torch", "mesecons_torch:mesecon_torch_on") @@ -30,3 +30,9 @@ minetest.register_alias("mesecons:solarpanel", "mesecons_solarpanel:solar_panel_ --Backwards compatibility minetest.register_alias("mesecons:mesecon_off", "mesecons:wire_00000000_off") +minetest.register_alias("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky_on") +minetest.register_alias("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal_on") +minetest.register_alias("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal_on") +minetest.register_alias("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal_on") +minetest.register_alias("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky_on") +minetest.register_alias("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky_on") diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 75547d2..828b466 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -1,8 +1,3 @@ --- --- --- --- - -- Get mesecon rules of pistons piston_rules = {{x=0, y=0, z=1}, --everything apart from z- (pusher side) @@ -44,8 +39,12 @@ local piston_remove_pusher = function (pos, node) dir = piston_get_direction(pistonspec.dir, node) local pusherpos = mesecon:addPosRule(pos, dir) - minetest.env:remove_node(pusherpos) - nodeupdate(pusherpos) + local pushername = minetest.env:get_node(pusherpos).name + + if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly) + minetest.env:remove_node(pusherpos) + nodeupdate(pusherpos) + end end local piston_on = function (pos, node) @@ -252,7 +251,7 @@ local piston_up_on_box = { -- Normal -local pistonspec_normal_down = { +local pistonspec_normal_up = { offname = "mesecons_pistons:piston_up_normal_off", onname = "mesecons_pistons:piston_up_normal_on", dir = {x = 0, y = 1, z = 0}, @@ -265,7 +264,7 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", { groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype2 = "facedir", drop = {"mesecons_pistons:piston_normal_off"}, - mesecons_piston = pistonspec_normal_down, + mesecons_piston = pistonspec_normal_up, mesecons = {effector={ action_on = piston_on, }} @@ -282,7 +281,7 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", { after_dig_node = piston_remove_pusher, node_box = piston_up_on_box, selection_box = piston_up_on_box, - mesecons_piston = pistonspec_normal_down, + mesecons_piston = pistonspec_normal_up, mesecons = {effector={ action_off = piston_off, }} From cdd9a93da9c8ed5e89993bc225647dbce71f96f4 Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Thu, 27 Dec 2012 12:13:40 -0500 Subject: [PATCH 21/28] revamped textures for all pistons, tweaked thickness of piston pusher --- mesecons_pistons/init.lua | 177 ++++++++++++++---- .../textures/jeija_piston_pusher_normal.png | Bin 793 -> 0 bytes .../textures/jeija_piston_pusher_sticky.png | Bin 782 -> 0 bytes .../textures/jeija_piston_side.png | Bin 793 -> 0 bytes .../textures/jeija_piston_sticky_side.png | Bin 782 -> 0 bytes .../textures/jeija_piston_tb.png | Bin 778 -> 0 bytes .../textures/mesecons_piston_back.png | Bin 0 -> 763 bytes .../textures/mesecons_piston_bottom.png | Bin 0 -> 791 bytes .../textures/mesecons_piston_left.png | Bin 0 -> 790 bytes .../textures/mesecons_piston_on_front.png | Bin 0 -> 759 bytes .../textures/mesecons_piston_pusher_back.png | Bin 0 -> 781 bytes .../mesecons_piston_pusher_bottom.png | Bin 0 -> 762 bytes .../textures/mesecons_piston_pusher_front.png | Bin 0 -> 759 bytes .../mesecons_piston_pusher_front_sticky.png | Bin 0 -> 738 bytes .../textures/mesecons_piston_pusher_left.png | Bin 0 -> 790 bytes .../textures/mesecons_piston_pusher_right.png | Bin 0 -> 802 bytes .../textures/mesecons_piston_pusher_top.png | Bin 0 -> 787 bytes .../textures/mesecons_piston_right.png | Bin 0 -> 786 bytes .../textures/mesecons_piston_top.png | Bin 0 -> 790 bytes 19 files changed, 138 insertions(+), 39 deletions(-) delete mode 100644 mesecons_textures/textures/jeija_piston_pusher_normal.png delete mode 100644 mesecons_textures/textures/jeija_piston_pusher_sticky.png delete mode 100644 mesecons_textures/textures/jeija_piston_side.png delete mode 100644 mesecons_textures/textures/jeija_piston_sticky_side.png delete mode 100644 mesecons_textures/textures/jeija_piston_tb.png create mode 100644 mesecons_textures/textures/mesecons_piston_back.png create mode 100644 mesecons_textures/textures/mesecons_piston_bottom.png create mode 100644 mesecons_textures/textures/mesecons_piston_left.png create mode 100644 mesecons_textures/textures/mesecons_piston_on_front.png create mode 100644 mesecons_textures/textures/mesecons_piston_pusher_back.png create mode 100644 mesecons_textures/textures/mesecons_piston_pusher_bottom.png create mode 100644 mesecons_textures/textures/mesecons_piston_pusher_front.png create mode 100644 mesecons_textures/textures/mesecons_piston_pusher_front_sticky.png create mode 100644 mesecons_textures/textures/mesecons_piston_pusher_left.png create mode 100644 mesecons_textures/textures/mesecons_piston_pusher_right.png create mode 100644 mesecons_textures/textures/mesecons_piston_pusher_top.png create mode 100644 mesecons_textures/textures/mesecons_piston_right.png create mode 100644 mesecons_textures/textures/mesecons_piston_top.png diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 828b466..ab04026 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -92,7 +92,7 @@ end -- Horizontal pistons -local pt = 2/16 -- pusher thickness +local pt = 3/16 -- pusher thickness local piston_pusher_box = { type = "fixed", @@ -124,7 +124,14 @@ local pistonspec_normal = { -- offstate minetest.register_node("mesecons_pistons:piston_normal_off", { description = "Piston", - tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_side.png"}, + tiles = { + "mesecons_piston_top.png", + "mesecons_piston_bottom.png", + "mesecons_piston_left.png", + "mesecons_piston_right.png", + "mesecons_piston_back.png", + "mesecons_piston_pusher_front.png" + }, groups = {cracky = 3}, paramtype2 = "facedir", after_place_node = piston_orientate, @@ -138,7 +145,14 @@ minetest.register_node("mesecons_pistons:piston_normal_off", { -- onstate minetest.register_node("mesecons_pistons:piston_normal_on", { drawtype = "nodebox", - tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_top.png", + "mesecons_piston_bottom.png", + "mesecons_piston_left.png", + "mesecons_piston_right.png", + "mesecons_piston_back.png", + "mesecons_piston_on_front.png" + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -156,7 +170,14 @@ minetest.register_node("mesecons_pistons:piston_normal_on", { -- pusher minetest.register_node("mesecons_pistons:piston_pusher_normal", { drawtype = "nodebox", - tiles = {"jeija_piston_pusher_normal.png"}, + tiles = { + "mesecons_piston_pusher_top.png", + "mesecons_piston_pusher_bottom.png", + "mesecons_piston_pusher_left.png", + "mesecons_piston_pusher_right.png", + "mesecons_piston_pusher_back.png", + "mesecons_piston_pusher_front.png" + }, paramtype = "light", paramtype2 = "facedir", diggable = false, @@ -180,7 +201,14 @@ local pistonspec_sticky = { -- offstate minetest.register_node("mesecons_pistons:piston_sticky_off", { description = "Sticky Piston", - tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"}, + tiles = { + "mesecons_piston_top.png", + "mesecons_piston_bottom.png", + "mesecons_piston_left.png", + "mesecons_piston_right.png", + "mesecons_piston_back.png", + "mesecons_piston_pusher_front_sticky.png" + }, groups = {cracky = 3}, paramtype2 = "facedir", after_place_node = piston_orientate, @@ -194,7 +222,14 @@ minetest.register_node("mesecons_pistons:piston_sticky_off", { -- onstate minetest.register_node("mesecons_pistons:piston_sticky_on", { drawtype = "nodebox", - tiles = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_top.png", + "mesecons_piston_bottom.png", + "mesecons_piston_left.png", + "mesecons_piston_right.png", + "mesecons_piston_back.png", + "mesecons_piston_on_front.png" + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -213,12 +248,12 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", { minetest.register_node("mesecons_pistons:piston_pusher_sticky", { drawtype = "nodebox", tiles = { - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_sticky.png" + "mesecons_piston_pusher_top.png", + "mesecons_piston_pusher_bottom.png", + "mesecons_piston_pusher_left.png", + "mesecons_piston_pusher_right.png", + "mesecons_piston_pusher_back.png", + "mesecons_piston_pusher_front_sticky.png" }, paramtype = "light", paramtype2 = "facedir", @@ -260,7 +295,14 @@ local pistonspec_normal_up = { -- offstate minetest.register_node("mesecons_pistons:piston_up_normal_off", { - tiles = {"jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_pusher_front.png", + "mesecons_piston_back.png", + "mesecons_piston_left.png^[transformR270", + "mesecons_piston_right.png^[transformR90", + "mesecons_piston_bottom.png", + "mesecons_piston_top.png^[transformR180", + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype2 = "facedir", drop = {"mesecons_pistons:piston_normal_off"}, @@ -273,7 +315,14 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", { -- onstate minetest.register_node("mesecons_pistons:piston_up_normal_on", { drawtype = "nodebox", - tiles = {"jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_on_front.png", + "mesecons_piston_back.png", + "mesecons_piston_left.png^[transformR270", + "mesecons_piston_right.png^[transformR90", + "mesecons_piston_bottom.png", + "mesecons_piston_top.png^[transformR180", + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -290,7 +339,14 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", { -- pusher minetest.register_node("mesecons_pistons:piston_up_pusher_normal", { drawtype = "nodebox", - tiles = {"jeija_piston_pusher_normal.png"}, + tiles = { + "mesecons_piston_pusher_front.png", + "mesecons_piston_pusher_back.png", + "mesecons_piston_pusher_left.png^[transformR270", + "mesecons_piston_pusher_right.png^[transformR90", + "mesecons_piston_pusher_bottom.png", + "mesecons_piston_pusher_top.png^[transformR180", + }, paramtype = "light", paramtype2 = "facedir", diggable = false, @@ -314,7 +370,15 @@ local pistonspec_sticky_up = { -- offstate minetest.register_node("mesecons_pistons:piston_up_sticky_off", { - tiles = {"jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_pusher_front_sticky.png", + "mesecons_piston_back.png", + "mesecons_piston_left.png^[transformR270", + "mesecons_piston_right.png^[transformR90", + "mesecons_piston_bottom.png", + "mesecons_piston_top.png^[transformR180", + "mesecons_piston_tb.png" + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype2 = "facedir", drop = {"mesecons_pistons:piston_sticky_off"}, @@ -327,7 +391,14 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", { -- onstate minetest.register_node("mesecons_pistons:piston_up_sticky_on", { drawtype = "nodebox", - tiles = {"jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_on_front.png", + "mesecons_piston_back.png", + "mesecons_piston_left.png^[transformR270", + "mesecons_piston_right.png^[transformR90", + "mesecons_piston_bottom.png", + "mesecons_piston_top.png^[transformR180", + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -345,12 +416,12 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", { minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", { drawtype = "nodebox", tiles = { - "jeija_piston_pusher_sticky.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png" + "mesecons_piston_pusher_front_sticky.png", + "mesecons_piston_pusher_back.png", + "mesecons_piston_pusher_left.png^[transformR270", + "mesecons_piston_pusher_right.png^[transformR90", + "mesecons_piston_pusher_bottom.png", + "mesecons_piston_pusher_top.png^[transformR180", }, paramtype = "light", paramtype2 = "facedir", @@ -394,7 +465,14 @@ local pistonspec_normal_down = { -- offstate minetest.register_node("mesecons_pistons:piston_down_normal_off", { - tiles = {"jeija_piston_tb.png", "jeija_piston_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_back.png", + "mesecons_piston_pusher_front.png", + "mesecons_piston_left.png^[transformR90", + "mesecons_piston_right.png^[transformR270", + "mesecons_piston_bottom.png^[transformR180", + "mesecons_piston_top.png", + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype2 = "facedir", drop = {"mesecons_pistons:piston_normal_off"}, @@ -407,7 +485,14 @@ minetest.register_node("mesecons_pistons:piston_down_normal_off", { -- onstate minetest.register_node("mesecons_pistons:piston_down_normal_on", { drawtype = "nodebox", - tiles = {"jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_back.png", + "mesecons_piston_on_front.png", + "mesecons_piston_left.png^[transformR90", + "mesecons_piston_right.png^[transformR270", + "mesecons_piston_bottom.png^[transformR180", + "mesecons_piston_top.png", + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -425,12 +510,12 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", { minetest.register_node("mesecons_pistons:piston_down_pusher_normal", { drawtype = "nodebox", tiles = { - "jeija_piston_pusher_sticky.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png" + "mesecons_piston_pusher_back.png", + "mesecons_piston_pusher_front.png", + "mesecons_piston_pusher_left.png^[transformR90", + "mesecons_piston_pusher_right.png^[transformR270", + "mesecons_piston_pusher_bottom.png^[transformR180", + "mesecons_piston_pusher_top.png", }, paramtype = "light", paramtype2 = "facedir", @@ -452,7 +537,14 @@ local pistonspec_sticky_down = { -- offstate minetest.register_node("mesecons_pistons:piston_down_sticky_off", { - tiles = {"jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_back.png", + "mesecons_piston_pusher_front_sticky.png", + "mesecons_piston_left.png^[transformR90", + "mesecons_piston_right.png^[transformR270", + "mesecons_piston_bottom.png^[transformR180", + "mesecons_piston_top.png", + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype2 = "facedir", drop = {"mesecons_pistons:piston_sticky_off"}, @@ -465,7 +557,14 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", { -- onstate minetest.register_node("mesecons_pistons:piston_down_sticky_on", { drawtype = "nodebox", - tiles = {"jeija_piston_tb.png"}, + tiles = { + "mesecons_piston_back.png", + "mesecons_piston_on_front.png", + "mesecons_piston_left.png^[transformR90", + "mesecons_piston_right.png^[transformR270", + "mesecons_piston_bottom.png^[transformR180", + "mesecons_piston_top.png", + }, groups = {cracky = 3, not_in_creative_inventory = 1}, paramtype = "light", paramtype2 = "facedir", @@ -483,12 +582,12 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", { minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", { drawtype = "nodebox", tiles = { - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_sticky.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png", - "jeija_piston_pusher_normal.png" + "mesecons_piston_pusher_back.png", + "mesecons_piston_pusher_front_sticky.png", + "mesecons_piston_pusher_left.png^[transformR90", + "mesecons_piston_pusher_right.png^[transformR270", + "mesecons_piston_pusher_bottom.png^[transformR180", + "mesecons_piston_pusher_top.png", }, paramtype = "light", paramtype2 = "facedir", diff --git a/mesecons_textures/textures/jeija_piston_pusher_normal.png b/mesecons_textures/textures/jeija_piston_pusher_normal.png deleted file mode 100644 index d4a35253ec0c12d9f812cfc2e224a291646e3d37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 793 zcmV+!1LpjRP)Px#32;bRa{vGgP5=N469IKCxxWAa00(qQO+^RX1P=i<0H-);;{X5xt4TybR4C5{ z!CP{rBuS){{eFKso%+7dxyZ6C8btHij1bc8hF9<2;nnK# z_V1rjmHw91j;CRauO%pooKh-F|diFVT23_B)+D|4EoM!2Ak=TlM`+m;3Xc|6w{^>)KTu+ytM}B?%*WlPEs-~)%H|odn0aHpH z+d%7v>ZV3X)39o@v?+gn)`JKkQQJDTI|0=-uh%8>7#$Cfb<17v+1ty-ci;c%jXpE{ zKDIp7asgI{AARB-eb_2$3)TIhIz2tbi+GXV-;3%neA;{Y?dPlaZ&=GXV^v*Nht{-o z01-rpV5~YPm;bD=&ba<_RXo`j+62c3%H^*Xz`d5AA>bOV|u(M^jGg>k{T zl)U8t)cf7~zKN4R{AXV$Nr8L4e(1oBT!NA)n3mP!K}y54poF`k?0Amr+fit$u37;dO_vUj6hx XU{h&y>z;%|00000NkvXXu0mjfk!^as diff --git a/mesecons_textures/textures/jeija_piston_pusher_sticky.png b/mesecons_textures/textures/jeija_piston_pusher_sticky.png deleted file mode 100644 index 971150c131fa50693c3f8d6687c89a829b77fab6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 782 zcmV+p1M&QcP)Px#32;bRa{vGgP5=N469IKCxxWAa00(qQO+^RX1P=i<7E|oqvH$=Aph-kQR4C5{ z!QXGwMjQa}yYrpTiGL+7PJ(Gm2r8{mwKtxoJ@SX_Z$s)64?H5!ctJu)8 zpFZ)Mo5j_~H>^&7&6=R+2x&<1LpZq*HPPwZKV-et8s6C#J^pCpVzOkX&(Rh^SiTW`Aya;9FB~1V6{Zov%EgV z9tlI%josHTuXq>+u1|pZzr1-ujYA3Rbd4LZY{4u>R!gLW5(?#pO(GseBkub_5F|C7 zGajNgh*och$_{!VQLVNetSSYqwwUaQ#P=eeWs7{pSMx$CW(;LaP)-#P1XFJjfFNky zLOsvi+4cOteLfh)vAkQD-%tsQGK8inP2dV31Y0e*Z3GWI!GyNTy&sN$;(4BzQzK{> zB`QUTF-q}=&`LGsN7J?~ql!?V3;}>~bOYPz$U)K< zg0~k!NMwxhJ4rG*eiX+Mp|o^Yn`UasX)+oxx?{uGaI-A`7{`wqAA-^So&H_^`-jtD z_hCW9d*ku++ssqy;Na-}`_ri3W3F>~d3kjB`26!3B6jWg)$`~71F+48jlNPMRsaA1 M07*qoM6N<$g6+3*`v3p{ diff --git a/mesecons_textures/textures/jeija_piston_side.png b/mesecons_textures/textures/jeija_piston_side.png deleted file mode 100644 index 7ae047c02366db37c9988c5633e41bd125a8431f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 793 zcmV+!1LpjRP)Px#32;bRa{vGgP5=N469IKCxxWAa00(qQO+^RX1P=i{rBuS){{eFKso%+7dxyZ6C8btHij1bc8hF9<2;nnK# z_V1rjmHw91j;CRauO%pooKh-F|diFVT23_B)+D|4EoM!2Ak=TlM`+m;3Xc|6w{^>)KTu+ytM}B?%*WlPEs-~)%H|odn0aHpH z+d%7v>ZV3X)39o@v?+gn)`JKkQQJDTI|0=-uh%8>7#$Cfb<17v+1ty-ci;c%jXpE{ zKDIp7asgI{AARB-eb_2$3)TIhIz2tbi+GXV-;3%neA;{Y?dPlaZ&=GXV^v*Nht{-o z01-rpV5~YPm;bD=&ba<_RXo`j+62c3%H^*Xz`d5AA>bOV|u(M^jGg>k{T zl)U8t)cf7~zKN4R{AXV$Nr8L4e(1oBT!NA)n3mP!K}y54poF`k?0Amr+fit$u37;dO_vUj6hx XU{h&y>z;%|00000NkvXXu0mjfw_|#3 diff --git a/mesecons_textures/textures/jeija_piston_sticky_side.png b/mesecons_textures/textures/jeija_piston_sticky_side.png deleted file mode 100644 index 544da97391136d08cf223c076eeb75f7926585a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 782 zcmV+p1M&QcP)Px#32;bRa{vGgP5=N469IKCxxWAa00(qQO+^RX1P=i zpFZ)Mo5j_~H>^&7&6=R+2x&<1LpZq*HPPwZKV-et8s6C#J^pCpVzOkX&(Rh^SiTW`Aya;9FB~1V6{Zov%EgV z9tlI%josHTuXq>+u1|pZzr1-ujYA3Rbd4LZY{4u>R!gLW5(?#pO(GseBkub_5F|C7 zGajNgh*och$_{!VQLVNetSSYqwwUaQ#P=eeWs7{pSMx$CW(;LaP)-#P1XFJjfFNky zLOsvi+4cOteLfh)vAkQD-%tsQGK8inP2dV31Y0e*Z3GWI!GyNTy&sN$;(4BzQzK{> zB`QUTF-q}=&`LGsN7J?~ql!?V3;}>~bOYPz$U)K< zg0~k!NMwxhJ4rG*eiX+Mp|o^Yn`UasX)+oxx?{uGaI-A`7{`wqAA-^So&H_^`-jtD z_hCW9d*ku++ssqy;Na-}`_ri3W3F>~d3kjB`26!3B6jWg)$`~71F+48jlNPMRsaA1 M07*qoM6N<$f>jN2WdHyG diff --git a/mesecons_textures/textures/jeija_piston_tb.png b/mesecons_textures/textures/jeija_piston_tb.png deleted file mode 100644 index 43751e0d992ddf3a93875e0e8ac3cb7ee07ea36a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 778 zcmV+l1NHogP)Px#32;bRa{vGgP5=N469IKCxxWAa00(qQO+^RX1P=i=9(EcALjV8*oJmAMR4C5{ z!An!4NB{s}`T;b}BSD1NiTGGkwR3T5*TZVA-Vm!H1&AS65?R)mRAe^!&7s!^;al-mYbgzfXVay4IBW+cZK5 zR{3Gbyd>RcS;ngxUS9rTnU?1|004|o!Asqs=^+zMQ`L2r7oO|vlKo=2F$_8$kMVZ9 z?OVoV8B|pr?UF;58@g`ldb~?iS#g~H%k&3EsO`F@X@ekugs550B?*M_4kM&fjcNpA z+_bHGY?oza8G2OC>Mu2!gUK=ZjUpX8{P?uA@|I+eXxl-Lw9Ce9Cj)vrI_>s;d6~_=x-cJ^b$h=uX)>f#JzoTU3;u>ugVfj65k6j@;>o}p<}*Ms>S4h93y zbtE7q>0ukin=l@@$ChcVHsO4^)+q&0DhmEQearLW^Yt}M({#1oJU+itLfW3;7zcGtBC!7z$n zUZ*|N06@aS(dh4+8`pKqvQlIj%lN9U{SjMjLyXWh0GwBy)T*-LpP%>aV{~_S$Jh|d z%0IWas;2e&_U+xjv&C|B>W@y(lJs!>`L8VJ0Lz|t^6>ER8#BUTKR)=MCIA2c07*qo IM6N<$f|>4X=>Px# diff --git a/mesecons_textures/textures/mesecons_piston_back.png b/mesecons_textures/textures/mesecons_piston_back.png new file mode 100644 index 0000000000000000000000000000000000000000..6a57dcef5056e33760273087f7e7ff45caf99c88 GIT binary patch literal 763 zcmV)mb#0ET6bWX!TmWQHD{D|N8R} zNs=7LnHVGEXjvAlR8@YliFH%^ z@6&$axQ3>xs?uXT^w{%#(KJm>*M0Gn zzrUXta{}*Nw@H$)kskAWVVQ)|c(eKX@U?B*AP7`Vou;`g3%I>~^Y7pBNG@Cus-m<_ z>*hMC>gseZ>!y}PP&Kuw8(L5aDpD*WO**D>SnV6jPd&qKQhLWS{w}Po zkZIQb>qV}a`>$nt66}o0%kLTX(B3!CU;S`)_5q!ooIHdpDH_q#2ttfuv<`KR0!1WI zq)~EvbHnSBs)&%*^x1Qa5c>0v-y2@5SnZnKBu;9?;=JOV zcRHP()zdUu>lBBuR~Shf)e5+-`SK6bmWSG__0< zV~kzb1proM;S6jcmGi&Fq4v*1S?AAe0)0v06U}31q|Bw&+>i z$HzPfLzNKU_i<4aKmGiUb3UCui=v29G9Hib?(QthY8yrp$ByIVdCocaeE;M5`Tw^H VcM={&nEC(!002ovPDHLkV1m|Kc`*P0 literal 0 HcmV?d00001 diff --git a/mesecons_textures/textures/mesecons_piston_left.png b/mesecons_textures/textures/mesecons_piston_left.png new file mode 100644 index 0000000000000000000000000000000000000000..215dd739d082e02320b319e05c416e8ab620d438 GIT binary patch literal 790 zcmV+x1L^#UP)^2t7yw}H?kg>@ z2nm7t7)Zt+SRB%se&o=L@6G@4u|KGt#+{zq-rAY|h9uLDJLOQvP>5}Wunb7Zl2~aa zZJ!7Icy;yp7hk@8`@_Y>1;*s|_Ty+YisN{@+r9qk^=vi;fWcs}SS$vEK@bG!=U;w( z`t!T~*Wd2_%^$!2=C~^Yzz zN~r?Kvgmia0Dv85)v@%KFJB0eQ&2md&U5ta@BKrP5JDJZDNnPa%!Dw_Mx)Wdc`nid z{WF==YSjj-=b1P$MAFqK!9LLItX`!xjfP<;rBoC}(=^w0 z5g~{`97VXCDnT0f>jB%D`S1%s+m&D%Wf{6Heb(CZk?zNu|uoD2g5)9`JZ<-~9D1%hIwatd^zM>TS!aRVZUj2w|G$d_F%vJ3Tu+ zY3MrVDV|Pes7!~$At5;2hm_LQYDKB0s_JI5@jMRzFjA^iRgi4A+fbIJl;vzTt7xjo z1+CCZwUTgNN~uvwR6q!A{aw9YQ$brS=6GzMr<^m!7-Iy~q9`$eL&6Cm-qTZ&7g?Gi z1oulf%X0ugmzS5{ym|BC{d?QC2_dfQHk%d!vfFNLd%Rw|2%&zz@4BvKS)B9#0k_t7 Ush*y(5dZ)H07*qoM6N<$f-xj|eEXu^8Wt5>-r=~Hk*F|AP52o!|;dizr$fjqG&R4 ztGdm11?8L(Eo^Z-9bLyIR0B5#rGEMKH%QYIWdP)V@Lh>*sirH(z5xSp3AkLPh8 zoC7Z|E-)smG#w6yNs=g~qA0q#xe3Ei2$^Nsa5TJ|%`nEhyZv|9*XYxy)%Ne7?S6Pa z2U2uW@PFQvyzSnuHkK89@#XVwd3A`DP%SM;oB-5zU6wBW9bW-iX2oXn*|IFtuyz76 zy;&GkIf3c9JyTmt zPbS}>G)pyA6H1XzQ7;HWr{D7(qPeJZ9b-O^0fZ(JhKYzlE*A?#DdinmubZNJ9PIX- zXWwU4mDGtoc`-OX1`iLb*FRF55yL_R;|inwC;Pvr>AKv;nQ+5B0D$=TThKM_=JERW z7whSFu4^NNAFGOK?DX^$%@=d3Ye(b#moJA|o=GY1XCI)1O|xwp&LCVp#F~zD1-4}t zXIIE|JbwV1-Rt06r$Jnc-ww1OGu#U`zX&d9PDw<8PFg>bzRHw>!K*ywskzGt}4)=)iT|r zMK~ZulAysLI{)cc&%ySNK`}w(PpCnRDHkFYO0*sHU1k`7h4F0l)wgG;EZ5@$3qV8+ z1b|Yq0TOBin!1*+bH@vm%KtrS9u-a|_RG450Wm9uqH}b3u`}$~a&-Fc^>C`gw&+L7!-IpxBIdk1I+|QwUIu~B7@JOSPfm`f(_1O!$?@dXt3Un+fM{S#AB85I&007{;U-@jC zuQu(vIo;eULzy3lD4qlb1&s|C;h@QMS|BHwR5n(v+V5_t1T#}}3(xgq>ym^z? z-{A8T9`NDd;Oe#OXReD7*7e$O=$ocBpQlL@Z>(<&P6t_**_M6$=U619(Wv7}P5`6zg!X~VXlB_CdGG?fe)HBe^dK1Jd46tl(>-%7 z%R&f-Vc6+(eBTEEtgWrNu3NY5@niy3MX6S*x~}i<@2{3i(=?h*Ck#W&vWCMTil(xn z9336SaXg#P7Rx1OtoZc)Ip^pnMwEfeckZ4YN3)aDm8_0tSi$+?`)W9jwl8k3riOOm z31%#(lu0t?f`CO42&gE^ETcK+H*el{2Y)0~$$^xnv#MSJoWq@+U4-PEm4W~O1P}s< z5QMNSipj{$R*OcxsathbRg)xcwOa7-@GuNx&IL)836WS)@{&V@K?(9agMttziRbzR z6GroHxBK5q*fb39^ShB3ESB@3W^V26t%h;n1>rb~zL~NnDS&_Z?dKG3oL}F%_Y7xQ z)_M5KnoQd5w&!`A^H!^sb-P=ZRTO0yhRyXh-5wA^9H$XYW2`8O|MkE<@%m*BAXaMC zRASL6c9)BKvz;V!@8fv3^CJ5y?7&1yJr4V6^Nwuog z48>|x^;*3s_~~GP%d(7uv7)I63F&l|rr}I3OIBcn78$LmDky4n&KS!JP6;9KQfD^| zTp8t@vPn3#nhp?EQLP9FX%!8NM3f~W6DR^n5*??3Y}>xIZ>XBmADo@runVBfGuhA} sh`)( zoqV%cd0z7SAHT`@%^|hgc6`Z-86cgMRXLA$Vhc=DEmy1Wp69uax0A5Z-PGYWNZcsw zDJ8cIHVq+1he!4Q{PV{L2z6Q3X+Hxr85fVmmst>!o3|f?FVg-ahMYR|Rwc4q z#yP>9^pYeE`n@<{C?qlroXMmB5V}M=E@2M4nobGlTuJuy)GpUQ2D`mh!;fFTAOLt6 zZj2-%BGlo&V2(!^rE7}zf7zdxWigxIe_m`9&G!$(B;mdXjNYzVUx+aDDP=#_YpK-P z*%_HkCmf^Wqy6X4^Qx|HuU{Ljp@D6?Xx)-iv zI*AZM1p7P?7D%Nq#$DGbtr>TR!<_iO=w%s#crDvF3XL`hV{5Dh$|%#dTZDk>y6;T` z8Fb^A)OAIZJ*AWY2r@zdMhGfxw3Zr5DT!*gi+Q;!m+62lXEQPwWEU^~ivsHJIGi%V z7(|d#-f3;L)t!vuP&f_{X)#{>`S&?#nx~@!4?w~k0)Vxq1qLDpU5x6dI*1Z$ln6u+ zx`Qluco-9{mFo#@l`+5=jWCqTv`fhe_go)Af)IUkJ#vNTV3{2tGR*V!W(A<7j6!JI zt-{!;t0wK^;oe>tM*v~&x%GTe&5QH%U*SI&7k(H`rqjcNgXy$TN**7dTwPryNi2jI pjqXoRpN&TM#+cJ*C$C<;{0VaRsK7~ zB2ESY-H<=uXcY-__%L&Mr&L$WN25T$#Q60?71XXFW?3E7YUh`YI0ziR^Dv95YLn+a zPTo&|(R_W2gPYRJD>UFRN0_c{w6$f`RBcmHF}J@S7eA-dDPLtPKTr_st+1v*4Jd_E z7OdSu=(9H0q5@51ZP)*2esP*|*L9yP6D}0bhI7Z4&@_rVV2DJdTC~K3L}a*aj1Ypq zee?Fe;*a*fy-G+{42|exKgI{JVCnw%+N=Ugf%i5#mMP?{VDL1bhU@%1`;*8Qi)x-5x^`7Use ziICb3o03!uZ9`TWvU)h#e7~6S(P;ejQ}*V_0tYZ`E17U0kW2&BTRBjn20g)x6m{Q=n;0e=eM|UJGs@$c`_>SG8Fyul4mAx~ zgGkav*&py?sb}BR&+`Q$^1UP}$`%2|Q@~&7Xj1hCxV@)t=|TP1i`a{kY<1x)RaWKv z`1pu@`TV)pAKa(u`~Ceieb8Ec_%J;?I~xw8FbuD+Zw?MVUSHo>YY#q7Pf!2-1C<_y U5?;T5G5`Po07*qoM6N<$f|$ftoB#j- literal 0 HcmV?d00001 diff --git a/mesecons_textures/textures/mesecons_piston_pusher_left.png b/mesecons_textures/textures/mesecons_piston_pusher_left.png new file mode 100644 index 0000000000000000000000000000000000000000..bc5495bef63a47e722ee926ad33b97b4c7f6afb8 GIT binary patch literal 790 zcmV+x1L^#UP)N-~RCSmmiElSCe3Nho%?4*W;XRbfA<55B3j`ZX`*<82fyYF=4cDkWKHCB*D65jD2{2K05vI zIla94G)726B`u-aOsCVm!Jz2{0crPpowg3A)9F`_qMgBDW&sNc(?YtbFKz)c41+UW zDV0z1Mw*QP7gv|C)e4nbE09le)9)FsqnkF;@z>uxgoC}otSqA_B803tP6qp45E!l< zMbV~i2qB*5Vyxe0#u4%Bi&7p=g)mm5d z9&6C^e81xoLMWwdvyxi|RZBw}A%ye-N~vYppw;3+K%`^SMy~7hqDTli91bVNo)i*l znvzNg8OGs*;qcZ>$!-DwIQ{#tvv)_McSo0}|0KJ~f1?oqVEtw3n5N^9JSz;ifmQY8 z;Gun;WpNzqNCDZjcmu)qI?J~8JdR@}x$RidAb9?K@3xpDA-H8b7~?$8ITug^jLT-h z2*$SM=6Mbw{`chEa%@v$2haA=Zj!9lbr|;BZW{p6Y`CVGb6SOAU&LXr+vN{p!?xzL zg3fZEbihxqUb&t>o=j}Z;#_df9zT9^e0=PdiK003a#FR+b? z%}bmZ{Ix7K{ZOSTr(M#Xw?DAsF42y=E`MXUohI$rUr?#iRH>D^_E2fsp-tnYX^k78 zHpYN~*T4(xdBEA(*`r5~FK1T}!s+x5V@#5yO%Nn;a&mHVeSL*7!5F2C4F`ib3ehh= z^j<#s18?VY>7eB5V0t=#{(H|nee>7(?SIc!7k>xWFYcfI1R?n6&tHH1`8OQ;K|_}P zD7|$)Os5lkyk0p=v|M$mQiDorG^(=p*6T0~TTS`aw(-qJYcd%E5tpTqY!kyU{$+7d z6nkAIOLu}$V=Nek;dvfQ6NE54+*jYfU%1vLO&EaKaU4-rN8@o-ivpHvDCHbDjx!pM zZ$77;&K~;y!AMcWXyXYY=};;g-?h;u;Oe1T9}Y&EKJ1N#Ksj11R}b#Dp>l*7C*4+| z54uW6!6NVX`|}SWrL%`$i^H-qP4n_;H5?2vXsDzJ+O1Z$OSjtu z`F=x|T-VLwlnH6ZvL-Hk->>WHK+~*+1>e1X#aWOieikoxp=S(?Ca3`bRHet0ZzNPp zaAyn*001U=mSs@Hbr|PS%o#^pRxd2;;-jnU`s}m)#S51H_N%v9SeCBq6=-Nw!oa0RTyw gwwld-O)HB0e`EH5NEJrRc>n+a07*qoM6N<$g5xi72mk;8 literal 0 HcmV?d00001 diff --git a/mesecons_textures/textures/mesecons_piston_pusher_top.png b/mesecons_textures/textures/mesecons_piston_pusher_top.png new file mode 100644 index 0000000000000000000000000000000000000000..72f04e90a81131447f6911309253aaba98a41f72 GIT binary patch literal 787 zcmV+u1MK{XP)%syKd7^002&v70tdA1hjK-;uJ{|j#hexB8mFD5MUr7|*da!{9gP|kRJQXZq zDHal9Q5;L0r|G#YA=)2XrU?j6xNO$l@B2S6V+_dzW0{LtGK~c)XbL$862z!v7?T9* zg#zc&G>WTBEe0WMwps{*U^1e^a5A2TVU%So=NTac6H==;Bnd`gw7fiT%~h6{m$2t~ zRqJNPuP)wZ%~q>>+BHqnMvzjv*lzcFJph2?INffyW?3W8!@8z_-+p$|Ih9FH7VT7k z-_dOB`DU%!>DIYy{My_56#1H3q)y$raUX0v-~3Bm*F8Hs6GGUwy}!S2nkMHtrPRIP z9v>aavRtpv`QrdjCX?a&XKF!vw|(Be=u)2sMU9@GjWKfPn`PDd`uZgV>0}&!rs2xn zhp^plV>f zT_A)Wl4Q45%d#99$lKYO#qnQ%KTos#!>hCB|GY#}N(@-|uu>yJVTxWHRx6Uu4c@D7HMcDJ7=aYBne(UQjKz=3?=H9oN-LYNZ%sLI?l=gwXT6O(wEJ zuh#tVQ9Tn`vlZ+{5@npqg*!1t5IqW{aUqwzRT zZx;3yYBU;w?-fec>vhvK%jGfvfD$65jG_oz=8~^Bo9)S9Kn#tsiI>ae!^6^ZOAsPL z3FjO_=y;wD5zt^dooWC~6aV<}Go7za+btxeyt}^#$jGHMF|O5WQpzMrN(2R-bGYAm z)M4cv7eZhf;^y`iwc2gdBE#_eV!3u4cN)!nKTt(+A19fHliA!N&fdYnU@&O5Sf|~F z=jZ3X?~ljhZnrxgkEN8oUjO5#kJU=Wah&Vx>!YK`MWHS)FVD_ieEstIe~CnK;r@@b QD*ylh07*qoM6N<$f-N6zjsO4v literal 0 HcmV?d00001 diff --git a/mesecons_textures/textures/mesecons_piston_top.png b/mesecons_textures/textures/mesecons_piston_top.png new file mode 100644 index 0000000000000000000000000000000000000000..5c8bacea24158f5cb7ccba193fd613f850a7d6fd GIT binary patch literal 790 zcmV+x1L^#UP)K0Eq&`iR7uXYY_qoWlMollKRf&}-9|Y4V z1_H+Ca6Z`YhYk)7zI^%eHc0@W-|uHx<_E#5u8X4B+S z`KKRQOQX?fFzDySL%PV21}f^XjqAGZyRL#d9gLRq-+uoCk|bf2KAUYTQjm3nZ428y zq-mb(T;1GAF8hJpS2yW$xr8{5{lMpp=>SO6v(KL~#%Y=sMP4^+)G370wx##^ z5+R792$Cd03QE$9aZU+kjEzRxcsyR_1w!i6>Gb^k8~|(wx3o>uROOr(WjP!URfNJY zuq1J$al(x;1ir5u z#whUCR8r1#(=bi_$>yYotxu;Ht~anP(=?5Skaa`+AW$*JR?k|mNnYetRRI8iVVFi$ zHwx-FXNF-U$?dvnR819Jz$<@h3nA3Q!$WTvcADXO{#X022osOvZKLN@4VgXP zW4v2aHt-*jmXVg7o}Qxj?~jlEe6zSsnJ_nemkKm_9RGK6BwO~yb_{sq)A13KwCf}# z Date: Thu, 27 Dec 2012 12:48:02 -0500 Subject: [PATCH 22/28] Added a couple of needed textures for curved/corner wires and tweak code to use them. Also fixed the "on" state image for wire ends so that it works for curved wires also. --- mesecons_extrawires/corner.lua | 8 ++++---- .../jeija_insulated_wire_curved_tb_off.png | Bin 0 -> 253 bytes .../jeija_insulated_wire_curved_tb_on.png | Bin 0 -> 196 bytes .../textures/jeija_insulated_wire_ends_off.png | Bin 172 -> 173 bytes .../textures/jeija_insulated_wire_ends_on.png | Bin 172 -> 166 bytes 5 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 mesecons_textures/textures/jeija_insulated_wire_curved_tb_off.png create mode 100644 mesecons_textures/textures/jeija_insulated_wire_curved_tb_on.png diff --git a/mesecons_extrawires/corner.lua b/mesecons_extrawires/corner.lua index 885a1ca..df45d41 100644 --- a/mesecons_extrawires/corner.lua +++ b/mesecons_extrawires/corner.lua @@ -24,9 +24,9 @@ end minetest.register_node("mesecons_extrawires:corner_on", { drawtype = "nodebox", tiles = { + "jeija_insulated_wire_curved_tb_on.png", + "jeija_insulated_wire_curved_tb_on.png^[transformR270", "jeija_insulated_wire_sides_on.png", - "jeija_insulated_wire_sides_on.png", - "jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_sides_on.png", "jeija_insulated_wire_ends_on.png" @@ -51,9 +51,9 @@ minetest.register_node("mesecons_extrawires:corner_off", { drawtype = "nodebox", description = "Mesecon Corner", tiles = { + "jeija_insulated_wire_curved_tb_off.png", + "jeija_insulated_wire_curved_tb_off.png^[transformR270", "jeija_insulated_wire_sides_off.png", - "jeija_insulated_wire_sides_off.png", - "jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_sides_off.png", "jeija_insulated_wire_ends_off.png" diff --git a/mesecons_textures/textures/jeija_insulated_wire_curved_tb_off.png b/mesecons_textures/textures/jeija_insulated_wire_curved_tb_off.png new file mode 100644 index 0000000000000000000000000000000000000000..85ca90b36ebb88fb95099bc7d2503cfdf56d4636 GIT binary patch literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#4v(~;Dvx-g+ykJ{98VX=5RLQ62@&D5FHk4$9up2Oijj{=jZ1y z&P=!@T3h{dtHJgq*RDUme&NRUy4T6K4zzfGl~y}CUw&S~#fH;wp6lDc?Amwq%7G3| zm3*mBf1av$Jd5uyTX?%+C1cVzptc>VTQ^v626sdUz5bM)*deELuuJnx|IB_M|K#cQ vyB6hdWYJ#6wxe2aznI!7&w}p>Uzr)A?{XE z)7O>#4v(~;nrhv@tNuWtWKS2z5RLQ62@1*$q2PcS;L+5??*&PhZ~Yik_PItEWyKbLh*2~7YgL^*N* literal 0 HcmV?d00001 diff --git a/mesecons_textures/textures/jeija_insulated_wire_ends_off.png b/mesecons_textures/textures/jeija_insulated_wire_ends_off.png index accb72a4636fd3f111db7a5c72b0e69056be84cd..1fb478258825327f34df5033644143ba0dc492dc 100644 GIT binary patch delta 128 zcmV-`0Du3i0j&X$83+OZ005AYXf}}{A8ia95g9c*m+uz<002x$L_t(2&tqnjbK}$S z{m0B_pd#>=RhJ-}VHAu4DgkCe^8(^i-dk2(=6}q5x}t9{zZT|})cX4T8bLM-R?(J( i<^TUP6m{rh>I48FSVcd4(0}(% bAFECPZoEeeNQbGN00000NkvXXu0mjfViYad delta 127 zcmV-_0D%9d0jvR#83+ad001BJ|6!3KA8ZK<5GpGabYl4c002u#L_t(I%VT7dbNkON zsm1X1`85Vz(YFkjUkfvk!XE{rU=%n~48(C71^{iFU Date: Thu, 27 Dec 2012 19:14:54 +0100 Subject: [PATCH 23/28] Fix very rare piston bug (needs testing) --- mesecons_pistons/init.lua | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index ab04026..576c03a 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -643,13 +643,18 @@ local piston_up_down_get_stopper = function (node, dir, stack, stackid) end local piston_get_stopper = function (node, dir, stack, stackid) - if (stack[stackid + 1] - and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher - and stack[stackid + 1].node.param2 == node.param2) - or (stack[stackid - 1] - and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher - and stack[stackid + 1].node.param2 == node.param2) then - return false + pistonspec = minetest.registered_nodes[node.name].mesecons_piston + dir = piston_get_direction(pistonspec.dir, node) + local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir) + local pushernode = minetest.env:get_node(pusherpos) + + if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then + for _, s in ipairs(stack) do + if mesecon:cmpPos(s.pos, pusherpos) -- pusher is also to be pushed + and s.node.param2 == node.param2 then + return false + end + end end return true end @@ -657,11 +662,11 @@ end mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_get_stopper) mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_pusher_get_stopper) -mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_up_down_get_stopper) -mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_up_normal_on", piston_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_up_sticky_on", piston_up_down_get_stopper) -mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_up_down_get_stopper) -mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_down_normal_on", piston_up_down_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_down_sticky_on", piston_up_down_get_stopper) --craft recipes minetest.register_craft({ From 92122379de3b92d66942e1dbe8900c0708e4b45c Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Thu, 27 Dec 2012 13:50:54 -0500 Subject: [PATCH 24/28] added and tweaked textures to improve appearance and tiling of insulated T-junctions. --- mesecons_extrawires/tjunction.lua | 8 ++++---- .../jeija_insulated_wire_tjunction_tb_off.png | Bin 0 -> 244 bytes .../jeija_insulated_wire_tjunction_tb_on.png | Bin 0 -> 207 bytes 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 mesecons_textures/textures/jeija_insulated_wire_tjunction_tb_off.png create mode 100644 mesecons_textures/textures/jeija_insulated_wire_tjunction_tb_on.png diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua index 9188b5b..5146b0c 100644 --- a/mesecons_extrawires/tjunction.lua +++ b/mesecons_extrawires/tjunction.lua @@ -25,8 +25,8 @@ end minetest.register_node("mesecons_extrawires:tjunction_on", { drawtype = "nodebox", tiles = { - "jeija_insulated_wire_sides_on.png", - "jeija_insulated_wire_sides_on.png", + "jeija_insulated_wire_tjunction_tb_on.png", + "jeija_insulated_wire_tjunction_tb_on.png^[transformR180", "jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_ends_on.png", "jeija_insulated_wire_sides_on.png", @@ -52,8 +52,8 @@ minetest.register_node("mesecons_extrawires:tjunction_off", { drawtype = "nodebox", description = "T-junction", tiles = { - "jeija_insulated_wire_sides_off.png", - "jeija_insulated_wire_sides_off.png", + "jeija_insulated_wire_tjunction_tb_off.png", + "jeija_insulated_wire_tjunction_tb_off.png^[transformR180", "jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_ends_off.png", "jeija_insulated_wire_sides_off.png", diff --git a/mesecons_textures/textures/jeija_insulated_wire_tjunction_tb_off.png b/mesecons_textures/textures/jeija_insulated_wire_tjunction_tb_off.png new file mode 100644 index 0000000000000000000000000000000000000000..a897b2901683e2353e803beb8e46845ee0007e2c GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#4v(~ufsW*#v{azbWKS2z5RLQ62@BQk|GGNCw7QQ!ehHdHs`>Et+kalQ zIriV@$Ct(Jgnc4)q;{xo)!Q$2O|(A8OnH1$8S9cXC_~&QwAv1?F nZ8w~!On&h0;j}AQ literal 0 HcmV?d00001 diff --git a/mesecons_textures/textures/jeija_insulated_wire_tjunction_tb_on.png b/mesecons_textures/textures/jeija_insulated_wire_tjunction_tb_on.png new file mode 100644 index 0000000000000000000000000000000000000000..8fc312b144f16993071830adfa8ff1df0b54e423 GIT binary patch literal 207 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#4v(~ufp+_h&&Pm5d7dtgAsXkC6C_w$7>%2+OwovMJe_}8a?v&;8*$Y$eO+Bi z6J{Nn@Nd3j7MEcT+oTY8S69Oc%c8Ql#PTC8pBw(TlVor+F(J51^K^@5$(vnKBJs?J zH(QHu+1!5J4l*ztei@~6OwU{fXfuPStDnm{r-UW|howQ> literal 0 HcmV?d00001 From c062411fa18100c6aa0645d6b7663be42268602d Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 27 Dec 2012 20:38:12 +0100 Subject: [PATCH 25/28] Fix another two piston-related bugs --- mesecons_mvps/init.lua | 2 +- mesecons_pistons/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index 98bbc94..9f8242b 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -94,7 +94,7 @@ function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: dire mesecon.on_dignode(np, nn) mesecon:update_autoconnect(np) end - return {{pos = np, node = nn}} + return {{pos = np, node = {param2 = 0, name = "air"}}, {pos = pos, node = nn}} end function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 576c03a..a51e16e 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -660,7 +660,7 @@ local piston_get_stopper = function (node, dir, stack, stackid) end mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_get_stopper) -mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_pusher_get_stopper) +mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_get_stopper) mesecon:register_mvps_stopper("mesecons_pistons:piston_up_normal_on", piston_up_down_get_stopper) mesecon:register_mvps_stopper("mesecons_pistons:piston_up_sticky_on", piston_up_down_get_stopper) From 2bbc9dd4b76ba5df543442b1e30f91b26de45da5 Mon Sep 17 00:00:00 2001 From: Jeija Date: Thu, 27 Dec 2012 22:28:39 +0100 Subject: [PATCH 26/28] Rework the next nodes: Pressure Plates --- mesecons_pressureplates/init.lua | 248 +++++++++++++------------------ 1 file changed, 101 insertions(+), 147 deletions(-) diff --git a/mesecons_pressureplates/init.lua b/mesecons_pressureplates/init.lua index 78389a4..2e80edb 100644 --- a/mesecons_pressureplates/init.lua +++ b/mesecons_pressureplates/init.lua @@ -1,159 +1,113 @@ --- PRESSURE PLATE WOOD +local pp_box_off = { + type = "fixed", + fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, +} -minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", { - drawtype = "nodebox", - tiles = {"jeija_pressure_plate_wood_off.png"}, - inventory_image = "jeija_pressure_plate_wood_off.png", - wield_image = "jeija_pressure_plate_wood_off.png", - paramtype = "light", - is_ground_content = true, - walkable = true, - selection_box = { - type = "fixed", - fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, - }, - node_box = { - type = "fixed", - fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, - }, - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3}, - description="Wood Pressure Plate", - - on_timer = function(pos, elapsed) - local objs = minetest.env:get_objects_inside_radius(pos, 1) +local pp_box_on = { + type = "fixed", + fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, +} + +pp_on_timer = function (pos, elapsed) + local node = minetest.env:get_node(pos) + local ppspec = minetest.registered_nodes[node.name].pressureplate + + -- This is a workaround for a strange bug that occurs when the server is started + -- For some reason the first time on_timer is called, the pos is wrong + if not ppspec then return end + + local objs = minetest.env:get_objects_inside_radius(pos, 1) + + if objs[1] == nil and node.name == ppspec.onstate then + minetest.env:add_node(pos, {name = ppspec.offstate}) + mesecon:receptor_off(pos) + -- force deactivation of mesecon two blocks below (hacky) + mesecon:turnoff(mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})) + else for k, obj in pairs(objs) do - local objpos=obj:getpos() - if objpos.y>pos.y-1 and objpos.y pos.y-1 and objpos.y < pos.y then + minetest.env:add_node(pos, {name=ppspec.onstate}) mesecon:receptor_on(pos) + -- force activation of mesecon two blocks below (hacky) + mesecon:turnon(mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})) end end - return true - end, - mesecons = {receptor = { - state = mesecon.state.off - }}, - on_construct = function(pos) - minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) - end, -}) + end + return true +end -minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", { - drawtype = "nodebox", - tiles = {"jeija_pressure_plate_wood_on.png"}, - paramtype = "light", - is_ground_content = true, - walkable = true, - selection_box = { - type = "fixed", - fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, - }, - node_box = { - type = "fixed", - fixed = { -7/16, -8/16, -7/16, 7/16, -31/64, 7/16 }, - }, - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1}, - drop='"mesecons_pressureplates:pressure_plate_wood_off" 1', - - on_timer = function(pos, elapsed) - local objs = minetest.env:get_objects_inside_radius(pos, 1) - if objs[1]==nil then - minetest.env:add_node(pos, {name="mesecons_pressureplates:pressure_plate_wood_off"}) - mesecon:receptor_off(pos) - end - return true - end, - mesecons = {receptor = { - state = mesecon.state.on - }}, - on_construct = function(pos) - minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) - end, -}) +-- Register a Pressure Plate +-- offstate: name of the pressure plate when inactive +-- onstate: name of the pressure plate when active +-- description: description displayed in the player's inventory +-- tiles_off: textures of the pressure plate when inactive +-- tiles_on: textures of the pressure plate when active +-- image: inventory and wield image of the pressure plate +-- recipe: crafting recipe of the pressure plate -minetest.register_craft({ - output = '"mesecons_pressureplates:pressure_plate_wood_off" 1', - recipe = { - {'"default:wood"', '"default:wood"'}, +function mesecon:register_pressure_plate(offstate, onstate, description, texture_off, texture_on, recipe) + local ppspec = { + offstate = offstate, + onstate = onstate } -}) --- PRESSURE PLATE STONE + minetest.register_node(offstate, { + drawtype = "nodebox", + tiles = {texture_off}, + inventory_image = texture_off, + wield_image = image, + paramtype = "light", + selection_box = pp_box_off, + node_box = pp_box_off, + groups = {snappy = 2, oddly_breakable_by_hand = 3}, + description = description, + pressureplate = ppspec, + on_timer = pp_on_timer, + mesecons = {receptor = { + state = mesecon.state.off + }}, + on_construct = function(pos) + minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) + end, + }) -minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", { - drawtype = "nodebox", - tiles = {"jeija_pressure_plate_stone_off.png"}, - inventory_image = "jeija_pressure_plate_stone_off.png", - wield_image = "jeija_pressure_plate_stone_off.png", - paramtype = "light", - is_ground_content = true, - walkable = true, - selection_box = { - type = "fixed", - fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, - }, - node_box = { - type = "fixed", - fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, - }, - groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3}, - description="Stone Pressure Plate", - - on_timer = function(pos, elapsed) - local objs = minetest.env:get_objects_inside_radius(pos, 1) - for k, obj in pairs(objs) do - local objpos=obj:getpos() - if objpos.y>pos.y-1 and objpos.y Date: Fri, 28 Dec 2012 07:33:16 +0100 Subject: [PATCH 27/28] Make nr in rules rotation local in order not to pullute the holy global namespace --- mesecons/internal.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mesecons/internal.lua b/mesecons/internal.lua index ac16103..2d84787 100644 --- a/mesecons/internal.lua +++ b/mesecons/internal.lua @@ -428,7 +428,7 @@ end --Rules rotation Functions: function mesecon:rotate_rules_right(rules) - nr = {} + local nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = -rule.z, @@ -439,7 +439,7 @@ function mesecon:rotate_rules_right(rules) end function mesecon:rotate_rules_left(rules) - nr = {} + local nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = rule.z, @@ -450,7 +450,7 @@ function mesecon:rotate_rules_left(rules) end function mesecon:rotate_rules_down(rules) - nr = {} + local nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = -rule.y, @@ -461,7 +461,7 @@ function mesecon:rotate_rules_down(rules) end function mesecon:rotate_rules_up(rules) - nr = {} + local nr = {} for i, rule in ipairs(rules) do table.insert(nr, { x = rule.y, From 52ddd4bdc931a1f806ea581002b0f39ba83158bc Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 30 Dec 2012 09:07:49 +0100 Subject: [PATCH 28/28] Add crafting recipe for the delayer (similar to redstone, but with cobble instead of stone) --- mesecons_delayer/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua index 2175c3c..f70629a 100644 --- a/mesecons_delayer/init.lua +++ b/mesecons_delayer/init.lua @@ -178,3 +178,11 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { } }) end + +minetest.register_craft({ + output = "mesecons_delayer:delayer_off_1", + recipe = { + {"mesecons_torch:mesecon_torch_on", "group:mesecon_conductor_craftable", "mesecons_torch:mesecon_torch_on"}, + {"default:cobble","default:cobble", "default:cobble"}, + } +})