update mods

master
Brett O'Donnell 2012-09-10 19:25:37 +09:30
parent c897c623bc
commit a5e2a50bb5
108 changed files with 2280 additions and 1441 deletions

View File

@ -15,6 +15,10 @@ minerd247: Some textures
...other contributors
This is a mod for minetest-c55.
Copy the mesecons_* directories into minetest/data/mods/ to install it.
Copy the minetest-mod-mesecons directory into you game's mod folder
(e.g. games/minetest_game/mods/minetest-mod-mesecons)
VERSION: 0.9 DEV
You can remove modules of this mod by deleting the mesecons_*
folders in the minetest-mod-mesecons directory.
Mod dependencies: none

View File

@ -11,74 +11,7 @@
--
-- See the documentation on the forum for additional information, especially about crafting
--
--Quick Developer documentation for the mesecon API
--=================================================
--
--RECEPTORS
--
--A receptor is a node that emits power, e.g. a solar panel, a switch or a power plant.
--Usually you create two blocks per receptor that have to be switched when switching the on/off state:
-- # An off-state node (e.g. mesecons:mesecon_switch_off"
-- # An on-state node (e.g. mesecons:mesecon_switch_on"
--The on-state and off-state nodes should be registered in the mesecon api,
--so that the Mesecon circuit can be recalculated. This can be done using
--
--mesecon:add_receptor_node(nodename) -- for on-state node
--mesecon:add_receptor_node_off(nodename) -- for off-state node
--example: mesecon:add_receptor_node("mesecons:mesecon_switch_on")
--
--Turning receptors on and off
--Usually the receptor has to turn on and off. For this, you have to
-- # Remove the node and replace it with the node in the other state (e.g. replace on by off)
-- # Send the event to the mesecon circuit by using the api functions
-- mesecon:receptor_on (pos, rules) } These functions take the position of your receptor
-- mesecon:receptor_off(pos, rules) } as their parameter.
--
--You can specify the rules using the rules parameter. If you don't want special rules, just leave it out
--e.g. if you want to use the "pressureplate" rules, you use this command:
--mesecon:receptor_on (pos, mesecon:get_rules("pressureplate"))
--The rules can be manipulated by several rotate functions:
--rules=mesecon:rotate_rules_right/left/up/down(rules)
--
--
--!! If a receptor node is removed, the circuit should be recalculated. This means you have to
--send an mesecon:receptor_off signal to the api when the node is dug, using the
--after_dig_node node property.
--
--EFFECTORS
--
--A receptor is a node that uses power and transfers the signal to a mechanical, optical whatever
--event. e.g. the meselamp, the movestone or the removestone.
--
--There are two callback functions for receptors.
-- # function mesecon:register_on_signal_on (action)
-- # function mesecon:register_on_signal_off(action)
--
--These functions will be called for each block next to a mesecon conductor.
--
--Example: The removestone
--The removestone only uses one callback: The mesecon:register_on_signal_on function
--
--mesecon:register_on_signal_on(function(pos, node) -- As the action prameter you have to use a function
-- if node.name=="mesecons:removestone" then -- Check if it really is removestone. If you wouldn't use this, every node next to mesecons would be removed
-- minetest.env:remove_node(pos) -- The action: The removestone is removed
-- end -- end of if
--end) -- end of the function, )=end of the parameters of mesecon:register_on_signal_on
--
--CONDUCTORS: (new feature!! yay)
--You can specify your custom conductors using
--# mesecon:register_conductor(onstate, offstate)
-- onstate=the conductor's nodename when it is turned on
-- offstate=the conductor's nodename when it is turned off
--
--As you can see, conductors need an offstate and an onstate node, just like receptors
--mesecons:mesecon_on / mesecons:mesecon_off are the default conductors
--Other conductors connect to other conductors. It's always "the same energy"
--! As there is no special drawtype, conductors don't connect to others visually,
--but it works in fact.
--
--The function # mesecon:register_conductor(onstate, offstate) is the only thing you need to do,
--the mod does everything else for you (turn the conductor on and off...)
-- For developer documentation see the Developers' section on mesecons.tk
-- PUBLIC VARIABLES
@ -86,8 +19,7 @@ mesecon={} -- contains all functions and all global variables
mesecon.actions_on={} -- Saves registered function callbacks for mesecon on
mesecon.actions_off={} -- Saves registered function callbacks for mesecon off
mesecon.actions_change={} -- Saves registered function callbacks for mesecon change
mesecon.pwr_srcs={}
mesecon.pwr_srcs_off={}
mesecon.receptors={}
mesecon.effectors={}
mesecon.rules={}
mesecon.conductors={}
@ -96,39 +28,30 @@ mesecon.conductors={}
dofile(minetest.get_modpath("mesecons").."/settings.lua")
--Internal API
dofile(minetest.get_modpath("mesecons").."/internal_api.lua");
dofile(minetest.get_modpath("mesecons").."/internal.lua");
-- API API API API API API API API API API API API API API API API API API
function mesecon:add_receptor_node(nodename, rules, get_rules) --rules table is optional; if rules depend on param2 pass (nodename, nil, function get_rules)
local i=1
repeat
if mesecon.pwr_srcs[i]==nil then break end
i=i+1
until false
if get_rules==nil and rules==nil then
rules=mesecon:get_rules("default")
function mesecon:register_receptor(onstate, offstate, rules, get_rules)
if get_rules == nil and rules == nil then
rules = mesecon:get_rules("default")
end
mesecon.pwr_srcs[i]={}
mesecon.pwr_srcs[i].name=nodename
mesecon.pwr_srcs[i].rules=rules
mesecon.pwr_srcs[i].get_rules=get_rules
table.insert(mesecon.receptors,
{onstate = onstate,
offstate = offstate,
rules = rules,
get_rules = get_rules})
end
function mesecon:add_receptor_node_off(nodename, rules, get_rules)
local i=1
repeat
if mesecon.pwr_srcs_off[i]==nil then break end
i=i+1
until false
if get_rules==nil and rules==nil then
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
mesecon.pwr_srcs_off[i]={}
mesecon.pwr_srcs_off[i].name=nodename
mesecon.pwr_srcs_off[i].rules=rules
mesecon.pwr_srcs_off[i].get_rules=get_rules
table.insert(mesecon.effectors,
{onstate = onstate,
offstate = offstate,
input_rules = input_rules,
get_input_rules = get_input_rules})
end
function mesecon:receptor_on(pos, rules)
@ -136,14 +59,14 @@ function mesecon:receptor_on(pos, rules)
rules = mesecon:get_rules("default")
end
local i = 1
while rules[i]~=nil do
local np = {}
np.x = pos.x + rules[i].x
np.y = pos.y + rules[i].y
np.z = pos.z + rules[i].z
mesecon:turnon(np)
i=i+1
for i, rule in ipairs(rules) do
local np = {
x = pos.x + rule.x,
y = pos.y + rule.y,
z = pos.z + rule.z}
if mesecon:rules_link(pos, np, rules) then
mesecon:turnon(np, pos)
end
end
end
@ -152,54 +75,34 @@ function mesecon:receptor_off(pos, rules)
rules = mesecon:get_rules("default")
end
local i = 1
while rules[i]~=nil do
local np = {}
np.x = pos.x + rules[i].x
np.y = pos.y + rules[i].y
np.z = pos.z + rules[i].z
if not mesecon:connected_to_pw_src(np, {}) then
mesecon:turnoff(np)
for i, rule in ipairs(rules) do
local np = {
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
mesecon:turnoff(np, pos)
end
i=i+1
end
end
function mesecon:register_on_signal_on(action)
local i = 1
repeat
i=i+1
if mesecon.actions_on[i]==nil then break end
until false
mesecon.actions_on[i]=action
table.insert(mesecon.actions_on, action)
end
function mesecon:register_on_signal_off(action)
local i = 1
repeat
i=i+1
if mesecon.actions_off[i]==nil then break end
until false
mesecon.actions_off[i]=action
table.insert(mesecon.actions_off, action)
end
function mesecon:register_on_signal_change(action)
local i = 1
repeat
i=i+1
if mesecon.actions_change[i]==nil then break end
until false
mesecon.actions_change[i]=action
table.insert(mesecon.actions_change, action)
end
function mesecon:register_conductor (onstate, offstate)
local i=0
while mesecon.conductors[i]~=nil do
i=i+1
function mesecon:register_conductor (onstate, offstate, rules, get_rules)
if rules == nil then
rules = mesecon:get_rules("default")
end
mesecon.conductors[i]={}
mesecon.conductors[i].on=onstate
mesecon.conductors[i].off=offstate
table.insert(mesecon.conductors, {onstate = onstate, offstate = offstate, rules = rules, get_rules = get_rules})
end
mesecon:add_rules("default",
@ -220,3 +123,8 @@ print("[MESEcons] Main mod Loaded!")
--The actual wires
dofile(minetest.get_modpath("mesecons").."/wires.lua");
--Services like turnoff receptor on dignode and so on
dofile(minetest.get_modpath("mesecons").."/services.lua");
--Deprecated stuff
dofile(minetest.get_modpath("mesecons").."/legacy.lua");

View File

@ -0,0 +1,452 @@
-- INTERNAL
--Receptors
function mesecon:is_receptor_node(nodename)
for i, receptor in ipairs(mesecon.receptors) do
if receptor.onstate == nodename then
return true
end
end
return false
end
function mesecon:is_receptor_node_off(nodename, pos, ownpos)
for i, receptor in ipairs(mesecon.receptors) do
if receptor.offstate == nodename then
return true
end
end
return false
end
function mesecon:receptor_get_rules(node)
for i, receptor in ipairs(mesecon.receptors) do
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 nil
end
-- Effectors
function mesecon:is_effector_on(nodename)
for i, effector in ipairs(mesecon.effectors) do
if effector.onstate == nodename then
return true
end
end
return false
end
function mesecon:is_effector_off(nodename)
for i, effector in ipairs(mesecon.effectors) do
if effector.offstate == nodename then
return true
end
end
return false
end
function mesecon:is_effector(nodename)
return mesecon:is_effector_on(nodename) or mesecon:is_effector_off(nodename)
end
function mesecon:effector_get_input_rules(node)
for i, 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 mesecon.effectors[i].input_rules ~=nil then
return effector.input_rules
else
return mesecon:get_rules("default")
end
end
end
end
--Signals
function mesecon:activate(pos)
local node = minetest.env:get_node(pos)
for i, action in ipairs(mesecon.actions_on) do
action(pos, node)
end
end
function mesecon:deactivate(pos)
local node = minetest.env:get_node(pos)
for i, action in ipairs(mesecon.actions_off) do
action(pos, node)
end
end
function mesecon:changesignal(pos)
local node = minetest.env:get_node(pos)
for i, action in ipairs(mesecon.actions_change) do
action(pos, node)
end
end
--Rules
function mesecon:add_rules(name, rules)
table.insert(mesecon.rules, {name = name, rules = rules})
end
function mesecon:get_rules(name)
for i, rule in ipairs(mesecon.rules) do
if rule.name==name then
return rule.rules
end
end
end
--Conductor system stuff
function mesecon:get_conductor_on(offstate)
for i, conductor in ipairs(mesecon.conductors) do
if conductor.offstate == offstate then
return conductor.onstate
end
end
return false
end
function mesecon:get_conductor_off(onstate)
for i, conductor in ipairs(mesecon.conductors) do
if conductor.onstate == onstate then
return conductor.offstate
end
end
return false
end
function mesecon:is_conductor_on(name)
for i, conductor in ipairs(mesecon.conductors) do
if conductor.onstate == name then
return true
end
end
return false
end
function mesecon:is_conductor_off(name)
for i, conductor in ipairs(mesecon.conductors) do
if conductor.offstate == name then
return true
end
end
return false
end
function mesecon:is_conductor(name)
return mesecon:is_conductor_on(name) or mesecon:is_conductor_off(name)
end
function mesecon:conductor_get_rules(node)
for i, conductor in ipairs(mesecon.conductors) do
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
end
--
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
return true
end
return false
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
return true
end
return false
end
function mesecon:turnon(pos)
local node = minetest.env:get_node(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), param2 = node.param2})
for i, rule in ipairs(rules) do
local np = {}
np.x = pos.x + rule.x
np.y = pos.y + rule.y
np.z = pos.z + rule.z
if mesecon:rules_link(pos, np) then
mesecon:turnon(np)
end
end
end
if mesecon:is_effector(node.name) then
mesecon:changesignal(pos)
if mesecon:is_effector_off(node.name) then mesecon:activate(pos) end
end
end
function mesecon:turnoff(pos) --receptor rules used because output could have been dug
local node = minetest.env:get_node(pos)
local rules
if mesecon:is_conductor_on(node.name) then
rules = mesecon:conductor_get_rules(node)
minetest.env:add_node(pos, {name=mesecon:get_conductor_off(node.name), param2 = node.param2})
for i, rule in ipairs(rules) do
local np = {
x = pos.x + rule.x,
y = pos.y + rule.y,
z = pos.z + rule.z,}
if mesecon:rules_link(pos, np) then
mesecon:turnoff(np)
end
end
end
if mesecon:is_effector(node.name) then
mesecon:changesignal(pos)
if mesecon:is_effector_on(node.name) and not mesecon:is_powered(pos) then mesecon:deactivate(pos) end
end
end
function mesecon:connected_to_pw_src(pos, checked)
local c = 1
if checked == nil then checked = {} end
while checked[c] ~= nil do --find out if node has already been checked (to prevent from endless loop)
if compare_pos(checked[c], 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)
for i, rule in ipairs(rules) do
local np = {}
np.x = pos.x + rule.x
np.y = pos.y + rule.y
np.z = pos.z + rule.z
if mesecon:rules_link(pos, np) then
connected, checked = mesecon:connected_to_pw_src(np, checked)
if connected then
return true
end
end
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 k = 1
local l = 1
local outputnode = minetest.env:get_node(output)
local inputnode = minetest.env:get_node(input)
local outputrules = dug_outputrules
local inputrules
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
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 k, outputrule in ipairs(outputrules) do
if outputrule.x + output.x == input.x
and outputrule.y + output.y == input.y
and outputrule.z + output.z == input.z then -- Check if output sends to input
l = 1
for k, inputrule in ipairs(inputrules) do
if inputrule.x + input.x == output.x
and inputrule.y + input.y == output.y
and inputrule.z + input.z == output.z then --Check if input accepts from output
return true
end
end
end
end
return false
end
function mesecon:rules_link_bothdir(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 i, rule in ipairs(rules) do
local con_pos = {
x = pos.x + rule.x,
y = pos.y + rule.y,
z = pos.z + rule.z}
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 i, rule in ipairs(rules) do
local rcpt_pos = {
x = pos.x + rule.x,
y = pos.y + rule.y,
z = pos.z + rule.z}
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)
end
function mesecon:updatenode(pos)
if mesecon:connected_to_pw_src(pos) then
mesecon:turnon(pos)
else
mesecon:turnoff(pos)
end
end
function compare_pos(pos1, pos2)
return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
end
--Rules rotation Functions:
function mesecon:rotate_rules_right(rules)
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
end
return nr
end
function mesecon:rotate_rules_left(rules)
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
end
return nr
end
function mesecon:rotate_rules_down(rules)
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
end
return nr
end
function mesecon:rotate_rules_up(rules)
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
end
return nr
end

View File

@ -1,411 +0,0 @@
-- INTERNAL API
function mesecon:is_receptor_node(nodename, pos, ownpos) --ownpos must be position of the effector/mesecon NOT of the receptor node; pos is the receptor position
local i=1
local j=1
repeat
if mesecon.pwr_srcs[i].name==nodename then
if pos==nil and ownpos==nil then --old usage still possible
return true
end
local rules = mesecon.pwr_srcs[i].rules
local get_rules = mesecon.pwr_srcs[i].get_rules
local node = minetest.env:get_node(pos)
if get_rules~=nil then --get_rules preferred
rules = get_rules(node.param2)
end
j=1
while rules[j]~=nil do --Check if dest. position is specified in the receptor's rules
if pos.x+rules[j].x==ownpos.x
and pos.y+rules[j].y==ownpos.y
and pos.z+rules[j].z==ownpos.z then
return true
end
j=j+1
end
end
i=i+1
until mesecon.pwr_srcs[i]==nil
return false
end
function mesecon:is_receptor_node_off(nodename, pos, ownpos) --ownpos must be position of the effector/mesecon NOT of the receptor node; pos is the receptor position
local i=1
local j=1
repeat
if mesecon.pwr_srcs_off[i].name==nodename then
if pos==nil and ownpos==nil then --old usage still possible
return true
end
local rules = mesecon.pwr_srcs_off[i].rules
local rules = mesecon.pwr_srcs_off[i].get_rules
local node = minetest.env:get_node(pos)
if get_rules ~= nil then
rules = get_rules(node.param2)
end
j=1
while rules[j]~=nil do
if pos.x+rules[j].x==ownpos.x
and pos.y+rules[j].y==ownpos.y
and pos.z+rules[j].z==ownpos.z then
return true
end
j=j+1
end
end
i=i+1
until mesecon.pwr_srcs_off[i]==nil
return false
end
--Signals
function mesecon:activate(pos)
local node = minetest.env:get_node(pos)
local i = 1
repeat
i=i+1
if mesecon.actions_on[i]~=nil then mesecon.actions_on[i](pos, node)
else break
end
until false
end
function mesecon:deactivate(pos)
local node = minetest.env:get_node(pos)
local i = 1
repeat
i=i+1
if mesecon.actions_off[i]~=nil then mesecon.actions_off[i](pos, node)
else break
end
until false
end
function mesecon:changesignal(pos)
local node = minetest.env:get_node(pos)
local i = 1
repeat
i=i+1
if mesecon.actions_change[i]~=nil then mesecon.actions_change[i](pos, node)
else break
end
until false
end
--Rules
function mesecon:add_rules(name, rules)
local i=0
while mesecon.rules[i]~=nil do
i=i+1
end
mesecon.rules[i]={}
mesecon.rules[i].name=name
mesecon.rules[i].rules=rules
end
function mesecon:get_rules(name)
local i=0
while mesecon.rules[i]~=nil do
if mesecon.rules[i].name==name then
return mesecon.rules[i].rules
end
i=i+1
end
end
--Conductor system stuff
function mesecon:get_conductor_on(offstate)
local i=0
while mesecon.conductors[i]~=nil do
if mesecon.conductors[i].off==offstate then
return mesecon.conductors[i].on
end
i=i+1
end
return false
end
function mesecon:get_conductor_off(onstate)
local i=0
while mesecon.conductors[i]~=nil do
if mesecon.conductors[i].on==onstate then
return mesecon.conductors[i].off
end
i=i+1
end
return false
end
function mesecon:is_conductor_on(name)
local i=0
while mesecon.conductors[i]~=nil do
if mesecon.conductors[i].on==name then
return true
end
i=i+1
end
return false
end
function mesecon:is_conductor_off(name)
local i=0
while mesecon.conductors[i]~=nil do
if mesecon.conductors[i].off==name then
return true
end
i=i+1
end
return false
end
--Rules rotation Functions:
function mesecon:rotate_rules_right(rules)
local i=1
local nr={};
while rules[i]~=nil do
nr[i]={}
nr[i].z=rules[i].x
nr[i].x=-rules[i].z
nr[i].y=rules[i].y
i=i+1
end
return nr
end
function mesecon:rotate_rules_left(rules)
local i=1
local nr={};
while rules[i]~=nil do
nr[i]={}
nr[i].z=-rules[i].x
nr[i].x=rules[i].z
nr[i].y=rules[i].y
i=i+1
end
return nr
end
function mesecon:rotate_rules_down(rules)
local i=1
local nr={};
while rules[i]~=nil do
nr[i]={}
nr[i].y=rules[i].x
nr[i].x=-rules[i].y
nr[i].z=rules[i].z
i=i+1
end
return nr
end
function mesecon:rotate_rules_up(rules)
local i=1
local nr={};
while rules[i]~=nil do
nr[i]={}
nr[i].y=-rules[i].x
nr[i].x=rules[i].y
nr[i].z=rules[i].z
i=i+1
end
return nr
end
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
return true
end
return false
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
return 1
end
return 0
end
function mesecon:turnon(pos)
local node = minetest.env:get_node(pos)
if mesecon:is_conductor_off(node.name) then
minetest.env:add_node(pos, {name=mesecon:get_conductor_on(node.name)})
nodeupdate(pos)
rules = mesecon:get_rules("default") --TODO: Use rules of conductor
local i=1
while rules[i]~=nil do
local np = {}
np.x = pos.x + rules[i].x
np.y = pos.y + rules[i].y
np.z = pos.z + rules[i].z
mesecon:turnon(np)
i=i+1
end
end
mesecon:changesignal(pos)
if minetest.get_item_group(node.name, "mesecon_effector_off") == 1 then
mesecon:activate(pos)
end
end
function mesecon:turnoff(pos)
local node = minetest.env:get_node(pos)
if mesecon:is_conductor_on(node.name) then
minetest.env:add_node(pos, {name=mesecon:get_conductor_off(node.name)})
nodeupdate(pos)
rules = mesecon:get_rules("default") --TODO: Use ruels of conductor
local i = 1
while rules[i]~=nil do
local np = {}
np.x = pos.x + rules[i].x
np.y = pos.y + rules[i].y
np.z = pos.z + rules[i].z
mesecon:turnoff(np)
i=i+1
end
end
mesecon:changesignal(pos) --Changesignal is always thrown because nodes can be both receptors and effectors
if minetest.get_item_group(node.name, "mesecon_effector_on") == 1 and
not mesecon:is_powered(pos) then --Check if the signal comes from another source
--Send Signals to effectors:
mesecon:deactivate(pos)
end
end
function mesecon:connected_to_pw_src(pos, checked)
local i = 1
while checked[i] ~= nil do --find out if node has already been checked
if checked[i].x == pos.x and checked[i].y == pos.y and checked[i].z == pos.z then
return false
end
i = i + 1
end
checked[i] = {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 end
if mesecon:is_conductor_on(node.name) or mesecon:is_conductor_off(node.name) then
if mesecon:is_powered_from_receptor(pos) then --return if conductor is powered
return true
end
local rules = mesecon:get_rules("default") --TODO: Use conductor specific rules
local i = 1
while rules[i] ~= nil do
local np = {}
np.x = pos.x + rules[i].x
np.y = pos.y + rules[i].y
np.z = pos.z + rules[i].z
if mesecon:connected_to_pw_src(np, checked) == true then
return true
end
i=i+1
end
end
return false
end
function mesecon:is_powered_from_receptor(pos)
local rcpt
local rcpt_pos = {}
local rcpt_checked = {} --using a checked array speeds this up
local i = 1
local j = 1
local k = 1
local pos_checked = false
while mesecon.rules[i]~=nil do
j=1
while mesecon.rules[i].rules[j]~=nil do
rcpt_pos = {
x = pos.x-mesecon.rules[i].rules[j].x,
y = pos.y-mesecon.rules[i].rules[j].y,
z = pos.z-mesecon.rules[i].rules[j].z}
k = 1
pos_checked = false
while rcpt_checked[k] ~= nil do
if compare_pos(rcpt_checked[k], rcpt_pos) then
pos_checked = true
end
k = k + 1
end
if not pos_checked then
table.insert(rcpt_checked, rcpt_pos)
rcpt = minetest.env:get_node(rcpt_pos)
if mesecon:is_receptor_node(rcpt.name, rcpt_pos, pos) then
return true
end
end
j=j+1
end
i=i+1
end
return false
end
function mesecon:is_powered_from_conductor(pos)
local k=1
rules=mesecon:get_rules("default") --TODO: use conductor specific rules
while rules[k]~=nil do
if mesecon:is_conductor_on(minetest.env:get_node({x=pos.x+rules[k].x, y=pos.y+rules[k].y, z=pos.z+rules[k].z}).name) then
return true
end
k=k+1
end
return false
end
function mesecon:is_powered(pos)
return mesecon:is_powered_from_conductor(pos) or mesecon:is_powered_from_receptor(pos)
end
function mesecon:updatenode(pos)
if mesecon:connected_to_pw_src(pos, {}) then
mesecon:turnon(pos)
else
mesecon:turnoff(pos)
end
end
minetest.register_on_placenode(function(pos, newnode, placer)
if mesecon:is_powered(pos) then
if mesecon:is_conductor_off(newnode.name) then
mesecon:turnon(pos)
else
mesecon:changesignal(pos)
mesecon:activate(pos)
end
end
end)
minetest.register_on_dignode(
function(pos, oldnode, digger)
if mesecon:is_conductor_on(oldnode.name) then
local i = 1
mesecon:receptor_off(pos)
end
end
)
function compare_pos(pos1, pos2)
return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
end

View File

@ -0,0 +1,13 @@
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

View File

@ -0,0 +1,28 @@
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))
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)
else
mesecon:changesignal(pos)
mesecon:activate(pos)
end
end
end
)

View File

@ -1,4 +1,3 @@
-- SETTINGS
BLINKY_PLANT_INTERVAL=3
ENABLE_TEMPEREST = false -- Enable Temperest's plugs and sockets
BLINKY_PLANT_INTERVAL = 3
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires

View File

@ -3,7 +3,7 @@
if NEW_STYLE_WIRES == false then --old wires
minetest.register_node("mesecons:mesecon_off", {
drawtype = "raillike",
tile_images = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"},
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",
@ -19,7 +19,7 @@ minetest.register_node("mesecons:mesecon_off", {
minetest.register_node("mesecons:mesecon_on", {
drawtype = "raillike",
tile_images = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"},
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,
@ -48,10 +48,10 @@ box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}
box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/16, 1/16}
box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/16, -1/16}
box_xpy = {.5-1/16, -.5+1/16, -1/16, .5, .5+1/16, 1/16}
box_zpy = {-1/16, -.5+1/16, .5-1/16, 1/16, .5+1/16, .5}
box_xmy = {-.5, -.5+1/16, -1/16, -.5+1/16, .5+1/16, 1/16}
box_zmy = {-1/16, -.5+1/16, -.5, 1/16, .5+1/16, -.5+1/16}
box_xpy = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/16, 1/16}
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}
for xp=0, 1 do
for zp=0, 1 do
@ -87,21 +87,21 @@ for zmy=0, 1 do
if zpy == 1 then table.insert(nodebox, box_zpy) end
if xmy == 1 then table.insert(nodebox, box_xmy) end
if zmy == 1 then table.insert(nodebox, box_zmy) end
nobump = xp+zp+xm+zm
if adjx and adjz and (nobump > 2) then
if adjx and adjz and (xp + zp + xm + zm > 2) then
table.insert(nodebox, box_bump1)
table.insert(nodebox, box_bump2)
tiles_off = {
"wires_off.png",
"wires_off.png",
"wires_bump_off.png",
"wires_bump_off.png",
"wires_vertical_off.png",
"wires_vertical_off.png",
"wires_vertical_off.png",
"wires_vertical_off.png"
}
tiles_on = {
"wires_on.png",
"wires_on.png",
"wires_bump_on.png",
"wires_bump_on.png",
"wires_vertical_on.png",
"wires_vertical_on.png",
"wires_vertical_on.png",
@ -110,16 +110,16 @@ for zmy=0, 1 do
else
table.insert(nodebox, box_center)
tiles_off = {
"wires_vertical_off.png",
"wires_vertical_off.png",
"wires_off.png",
"wires_off.png",
"wires_vertical_off.png",
"wires_vertical_off.png",
"wires_vertical_off.png",
"wires_vertical_off.png"
}
tiles_on = {
"wires_vertical_on.png",
"wires_vertical_on.png",
"wires_on.png",
"wires_on.png",
"wires_vertical_on.png",
"wires_vertical_on.png",
"wires_vertical_on.png",
@ -141,6 +141,7 @@ for zmy=0, 1 do
wield_image = "jeija_mesecon_off.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
@ -161,6 +162,7 @@ for zmy=0, 1 do
tiles = tiles_on,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
@ -232,24 +234,51 @@ 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 the groups mesecon == 1 then wires won't connect to it
xp = (minetest.get_item_group(minetest.env:get_node(xppos).name, "mesecon") > 1 or
minetest.get_item_group(minetest.env:get_node(xpympos).name, "mesecon") > 1) and 1 or 0
zp = (minetest.get_item_group(minetest.env:get_node(zppos).name, "mesecon") > 1 or
minetest.get_item_group(minetest.env:get_node(zpympos).name, "mesecon") > 1) and 1 or 0
xm = (minetest.get_item_group(minetest.env:get_node(xmpos).name, "mesecon") > 1 or
minetest.get_item_group(minetest.env:get_node(xmympos).name, "mesecon") > 1) and 1 or 0
zm = (minetest.get_item_group(minetest.env:get_node(zmpos).name, "mesecon") > 1 or
minetest.get_item_group(minetest.env:get_node(zmympos).name, "mesecon") > 1) and 1 or 0
local zmg = minetest.get_item_group(minetest.env:get_node(zmpos ).name, "mesecon")
local zmymg = minetest.get_item_group(minetest.env:get_node(zmympos).name, "mesecon")
local xmg = minetest.get_item_group(minetest.env:get_node(xmpos ).name, "mesecon")
local xmymg = minetest.get_item_group(minetest.env:get_node(xmympos).name, "mesecon")
local zpg = minetest.get_item_group(minetest.env:get_node(zppos ).name, "mesecon")
local zpymg = minetest.get_item_group(minetest.env:get_node(zpympos).name, "mesecon")
local xpg = minetest.get_item_group(minetest.env:get_node(xppos ).name, "mesecon")
local xpymg = minetest.get_item_group(minetest.env:get_node(xpympos).name, "mesecon")
xpy = (minetest.get_item_group(minetest.env:get_node(xpypos).name, "mesecon") > 1) and 1 or 0
zpy = (minetest.get_item_group(minetest.env:get_node(zpypos).name, "mesecon") > 1) and 1 or 0
xmy = (minetest.get_item_group(minetest.env:get_node(xmypos).name, "mesecon") > 1) and 1 or 0
zmy = (minetest.get_item_group(minetest.env:get_node(zmypos).name, "mesecon") > 1) and 1 or 0
local xpyg = minetest.get_item_group(minetest.env:get_node(xpypos).name, "mesecon")
local zpyg = minetest.get_item_group(minetest.env:get_node(zpypos).name, "mesecon")
local xmyg = minetest.get_item_group(minetest.env:get_node(xmypos).name, "mesecon")
local zmyg = minetest.get_item_group(minetest.env:get_node(zmypos).name, "mesecon")
if ((zmg == 2) or (zmymg == 2)) == true then zm = 1 else zm = 0 end
if ((xmg == 2) or (xmymg == 2)) == true then xm = 1 else xm = 0 end
if ((zpg == 2) or (zpymg == 2)) == true then zp = 1 else zp = 0 end
if ((xpg == 2) or (xpymg == 2)) == true then xp = 1 else xp = 0 end
if xpyg == 2 then xpy = 1 else xpy = 0 end
if zpyg == 2 then zpy = 1 else zpy = 0 end
if xmyg == 2 then xmy = 1 else xmy = 0 end
if zmyg == 2 then zmy = 1 else zmy = 0 end
-- If group == 3 then the mesecon only connects to input and output ports
if xpg == 3 and mesecon:rules_link_bothdir(pos, xppos) then xp = 1 end
if xmg == 3 and mesecon:rules_link_bothdir(pos, xmpos) then xm = 1 end
if zpg == 3 and mesecon:rules_link_bothdir(pos, zppos) then zp = 1 end
if zmg == 3 and mesecon:rules_link_bothdir(pos, zmpos) then zm = 1 end
if xpymg == 3 and mesecon:rules_link_bothdir(pos, xpympos) then xp = 1 end
if xmymg == 3 and mesecon:rules_link_bothdir(pos, xmympos) then xm = 1 end
if zpymg == 3 and mesecon:rules_link_bothdir(pos, zpympos) then zp = 1 end
if zmymg == 3 and mesecon:rules_link_bothdir(pos, zmympos) then zm = 1 end
if xpyg == 3 then if mesecon:rules_link(pos, xpypos) then xpy = 1 end end
if zpyg == 3 then if mesecon:rules_link(pos, zpypos) then zpy = 1 end end
if xmyg == 3 then if mesecon:rules_link(pos, xmypos) then xmy = 1 end end
if zmyg == 3 then if mesecon:rules_link(pos, zmypos) then zmy = 1 end end
-- Backward compatibility
if replace_old then
print ("replacing")
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
@ -273,6 +302,7 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
if string.find(nodename, "_off") ~= nil then
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
else

View File

@ -25,6 +25,7 @@ minetest.register_alias("mesecons:sticky_movestone", "mesecons_movestones:sticky
minetest.register_alias("mesecons:noteblock", "mesecons_noteblock:noteblock")
minetest.register_alias("mesecons:microcontroller", "mesecons_microcontroller:microcontroller")
minetest.register_alias("mesecons:delayer", "mesecons_delayer:delayer_off_1")
minetest.register_alias("mesecons:solarpanel", "mesecons_solarpanel:solar_panel_off")
--Backwards compatibility

View File

@ -1,149 +0,0 @@
for i = 1, 5 do
minetest.register_node("mesecons_battery:battery_charging_"..i, {
drawtype = "nodebox",
tiles = {"jeija_battery_charging.png"},
paramtype = "light",
is_ground_content = true,
walkable = true,
node_box = {
type = "fixed",
fixed = {
{-0.499, -0.499, -0.499, -0.4, 0.499, 0.499},
{ 0.4, -0.499, -0.499, 0.499, 0.499, 0.499},
{-0.499, -0.499, -0.499, 0.499, 0.499, -0.4 },
{-0.499, -0.499, 0.4, 0.499, 0.499, 0.499 },
{-0.4 , -0.5 , -0.4 , 0.4 , 1*(i/5)-0.5, 0.4}}
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
groups = {dig_immediate=2, mesecon = 2, mesecon_effector_on = 1},
description="Battery",
})
mesecon:add_receptor_node_off("mesecons_battery:battery_charging_"..i)
end
for i = 1, 5 do
minetest.register_node("mesecons_battery:battery_discharging_"..i, {
drawtype = "nodebox",
tiles = {"jeija_battery_discharging.png"},
paramtype = "light",
is_ground_content = true,
walkable = true,
node_box = {
type = "fixed",
fixed = {
{-0.499, -0.499, -0.499, -0.4, 0.499, 0.499},
{ 0.4, -0.499, -0.499, 0.499, 0.499, 0.499},
{-0.499, -0.499, -0.499, 0.499, 0.499, -0.4 },
{-0.499, -0.499, 0.4, 0.499, 0.499, 0.499 },
{-0.4 , -0.5 , -0.4 , 0.4 , 1*(i/5)-0.5, 0.4}}
},
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
},
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 2, mesecon_effector_off = 1},
description="Battery",
})
mesecon:add_receptor_node("mesecons_battery:battery_discharging_"..i)
end
minetest.register_on_placenode(function (pos, newnode, placer)
if string.find(newnode.name, "mesecons_battery:battery") then
meta = minetest.env:get_meta(pos)
meta:set_int("batterystate", tonumber(string.sub(newnode.name, string.len(newnode.name)))*20-19)
meta:set_int("charging", 0)
end
end)
minetest.register_on_punchnode(function(pos, node, puncher)
if string.find(node.name, "mesecons_battery:battery_charging") then
local meta = minetest.env:get_meta(pos);
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
minetest.env:remove_node(pos)
minetest.env:place_node(pos, {name=string.gsub(node.name, "charging", "discharging")})
mesecon:receptor_on(pos)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end
if string.find(node.name, "mesecons_battery:battery_discharging") then
local meta = minetest.env:get_meta(pos);
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
minetest.env:remove_node(pos)
minetest.env:place_node(pos, {name=string.gsub(node.name, "discharging", "charging")})
mesecon:receptor_off(pos)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end
end)
minetest.register_abm({
nodenames = {"mesecons_battery:battery_charging_1", "mesecons_battery:battery_charging_2", "mesecons_battery:battery_charging_3", "mesecons_battery:battery_charging_4", "mesecons_battery:battery_charging_5"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos);
if meta:get_int("charging") == 1 then
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
local name = node.name;
if batterystate < 100 then --change battery charging state
batterystate = batterystate + 1
else
node.name=string.gsub(node.name, "charging", "discharging")
mesecon:receptor_on(pos)
end
if string.find(node.name, tostring(math.ceil(batterystate/20))) == nil then
node.name = string.gsub(node.name, tostring(math.ceil(batterystate/20)-1), tostring(math.ceil(batterystate/20))) --change node for new nodebox model
end
minetest.env:add_node(pos, node)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end
end,
})
minetest.register_abm({
nodenames = {"mesecons_battery:battery_discharging_1", "mesecons_battery:battery_discharging_2", "mesecons_battery:battery_discharging_3", "mesecons_battery:battery_discharging_4", "mesecons_battery:battery_discharging_5"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos);
local batterystate = meta:get_int("batterystate")
local charging = meta:get_int("charging")
local name = node.name;
if batterystate > 1 then --change battery charging state
batterystate = batterystate - 1
else
node.name=string.gsub(node.name, "discharging", "charging")
mesecon:receptor_off(pos)
end
if string.find(node.name, tostring(math.ceil(batterystate/20))) == nil then
node.name = string.gsub(node.name, tostring(math.ceil(batterystate/20)+1), tostring(math.ceil(batterystate/20))) --change node for new nodebox model
end
minetest.env:add_node(pos, node)
meta:set_int("batterystate", batterystate)
meta:set_int("charging", charging)
end,
})
mesecon:register_on_signal_on(function(pos, node)
if string.find(node.name, "mesecons_battery:battery") then
minetest.env:get_meta(pos):set_int("charging", 1)
end
end)
mesecon:register_on_signal_off(function(pos, node)
if string.find(node.name, "mesecons_battery:battery") then
minetest.env:get_meta(pos):set_int("charging", 0)
end
end)

View File

@ -3,7 +3,7 @@
minetest.register_node("mesecons_blinkyplant:blinky_plant_off", {
drawtype = "plantlike",
visual_scale = 1,
tile_images = {"jeija_blinky_plant_off.png"},
tiles = {"jeija_blinky_plant_off.png"},
inventory_image = "jeija_blinky_plant_off.png",
paramtype = "light",
walkable = false,
@ -18,7 +18,7 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_off", {
minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
drawtype = "plantlike",
visual_scale = 1,
tile_images = {"jeija_blinky_plant_on.png"},
tiles = {"jeija_blinky_plant_on.png"},
inventory_image = "jeija_blinky_plant_off.png",
paramtype = "light",
walkable = false,
@ -26,9 +26,6 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
drop='"mesecons_blinkyplant:blinky_plant_off" 1',
light_source = LIGHT_MAX-7,
description = "Blinky Plant",
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end,
selection_box = {
type = "fixed",
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
@ -40,7 +37,7 @@ minetest.register_craft({
recipe = {
{'','"group:mesecon_conductor_craftable"',''},
{'','"group:mesecon_conductor_craftable"',''},
{'"default:junglegrass"','"default:junglegrass"','"default:junglegrass"'},
{'"default:sapling"','"default:sapling"','"default:sapling"'},
}
})

View File

@ -1 +1,2 @@
mesecons
mesecons_receiver

View File

@ -13,6 +13,7 @@ minetest.register_node("mesecons_button:button_off", {
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
@ -24,7 +25,7 @@ minetest.register_node("mesecons_button:button_off", {
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
}
},
groups = {dig_immediate=2, mesecon = 1},
groups = {dig_immediate=2, mesecon = 3, mesecon_needs_receiver = 1},
description = "Button",
})
minetest.register_node("mesecons_button:button_on", {
@ -42,6 +43,7 @@ minetest.register_node("mesecons_button:button_on", {
legacy_wallmounted = true,
walkable = false,
light_source = LIGHT_MAX-7,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
@ -53,12 +55,9 @@ minetest.register_node("mesecons_button:button_on", {
{ -4/16, -2/16, 11/32, 4/16, 2/16, 6/16 }
}
},
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 1},
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3, mesecon_needs_receiver = 1},
drop = 'mesecons_button:button_off',
description = "Button",
after_dig_node = function(pos, oldnode)
mesecon:receptor_off(pos, mesecon.button_get_rules(oldnode.param2))
end
})
minetest.register_on_punchnode(function(pos, node, puncher)
@ -100,22 +99,12 @@ minetest.register_craft({
})
mesecon:add_rules("button", {
{x=1, y=0, z=0},
{x=-1, y=0, z=0},
{x=0, y=0, z=1},
{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},
{x=0, y=1, z=-1},
{x=0, y=0, z=-1},
{x=0, y=-1, z=-1},
{x=0, y=-1, z=0},
{x=2, y=0, z=0},
{x=1, y=-1, z=1},
{x=1, y=-1, z=-1}})
{x = 1, y = 0, z = 0},
{x = 1, y = 1, z = 0},
{x = 1, y =-1, z = 0},
{x = 1, y =-1, z = 1},
{x = 1, y =-1, z =-1},
{x = 2, y = 0, z = 0},})
mesecon:add_receptor_node_off("mesecons_button:button_off", nil, mesecon.button_get_rules)
mesecon:add_receptor_node("mesecons_button:button_on", nil, mesecon.button_get_rules)

View File

@ -1,9 +1,9 @@
for i = 1, 4 do
local groups = {}
if i == 1 then
groups = {bendy=2,snappy=1,dig_immediate=2, mesecon = 2}
groups = {bendy=2,snappy=1,dig_immediate=2, mesecon = 3}
else
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1, mesecon = 2}
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1, mesecon = 3}
end
boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
@ -69,7 +69,7 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
type = "fixed",
fixed = boxes
},
groups = {bendy=2,snappy=1,dig_immediate=2,not_in_creative_inventory=1, mesecon = 2},
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1, mesecon = 3},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
@ -115,55 +115,45 @@ end)
mesecon.delayer_update = function(pos, node)
if string.find(node.name, "mesecons_delayer:delayer_off")~=nil then
local input_rules = mesecon.delayer_get_input_rules(node.param2)[1]
np = {x = pos.x + input_rules.x, y = pos.y + input_rules.y, z = pos.z + input_rules.z}
if mesecon:is_power_on(np) then
local time = 0
if node.name=="mesecons_delayer:delayer_off_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1", param2=node.param2})
time=0.1
end
if node.name=="mesecons_delayer:delayer_off_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2", param2=node.param2})
time=0.3
end
if node.name=="mesecons_delayer:delayer_off_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3", param2=node.param2})
time=0.5
end
if node.name=="mesecons_delayer:delayer_off_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4", param2=node.param2})
time=1
end
minetest.after(time, mesecon.delayer_turnon, {pos=pos, param2=node.param2})
local time = 0
if node.name=="mesecons_delayer:delayer_off_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_1", param2=node.param2})
time=0.1
end
if node.name=="mesecons_delayer:delayer_off_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_2", param2=node.param2})
time=0.3
end
if node.name=="mesecons_delayer:delayer_off_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_3", param2=node.param2})
time=0.5
end
if node.name=="mesecons_delayer:delayer_off_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_on_4", param2=node.param2})
time=1
end
minetest.after(time, mesecon.delayer_turnon, {pos=pos, param2=node.param2})
end
if string.find(node.name, "mesecons_delayer:delayer_on")~=nil then
local input_rules = mesecon.delayer_get_input_rules(node.param2)[1]
np = {x = pos.x + input_rules.x, y = pos.y + input_rules.y, z = pos.z + input_rules.z}
if not mesecon:is_power_on(np) then
local time = 0
if node.name=="mesecons_delayer:delayer_on_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2})
time=0.1
end
if node.name=="mesecons_delayer:delayer_on_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2})
time=0.3
end
if node.name=="mesecons_delayer:delayer_on_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2})
time=0.5
end
if node.name=="mesecons_delayer:delayer_on_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2})
time=1
end
minetest.after(time, mesecon.delayer_turnoff, {pos=pos, param2=node.param2})
local time = 0
if node.name=="mesecons_delayer:delayer_on_1" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_1", param2=node.param2})
time=0.1
end
if node.name=="mesecons_delayer:delayer_on_2" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_2", param2=node.param2})
time=0.3
end
if node.name=="mesecons_delayer:delayer_on_3" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_3", param2=node.param2})
time=0.5
end
if node.name=="mesecons_delayer:delayer_on_4" then
minetest.env:add_node(pos, {name="mesecons_delayer:delayer_off_4", param2=node.param2})
time=1
end
minetest.after(time, mesecon.delayer_turnoff, {pos=pos, param2=node.param2})
end
end
@ -218,3 +208,8 @@ mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_1", all_rules, mesec
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_2", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_3", all_rules, mesecon.delayer_get_output_rules)
mesecon:add_receptor_node_off("mesecons_delayer:delayer_off_4", all_rules, mesecon.delayer_get_output_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_1", "mesecons_delayer:delayer_off_1", all_rules, mesecon.delayer_get_input_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_2", "mesecons_delayer:delayer_off_2", all_rules, mesecon.delayer_get_input_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_3", "mesecons_delayer:delayer_off_3", all_rules, mesecon.delayer_get_input_rules)
mesecon:register_effector("mesecons_delayer:delayer_on_4", "mesecons_delayer:delayer_off_4", all_rules, mesecon.delayer_get_input_rules)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 438 B

View File

@ -1,6 +1,6 @@
--SHORT RANGE DETECTORS
minetest.register_node("mesecons_detector:object_detector_off", {
tile_images = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png"},
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png", "jeija_object_detector_off.png"},
paramtype = "light",
walkable = true,
groups = {cracky=3, mesecon = 2},
@ -8,15 +8,12 @@ minetest.register_node("mesecons_detector:object_detector_off", {
})
minetest.register_node("mesecons_detector:object_detector_on", {
tile_images = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"},
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"},
paramtype = "light",
walkable = true,
groups = {cracky=3,not_in_creative_inventory=1, mesecon = 2},
drop = 'mesecons_detector:object_detector_off',
description="Player Detector",
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
})
minetest.register_craft({
@ -76,5 +73,5 @@ minetest.register_abm(
end,
})
mesecon:add_receptor_node("mesecons_detector:object_detector_on")
mesecon:add_receptor_node_off("mesecons_detector:object_detector_off")
mesecon:add_receptor_node("mesecons_detector:object_detector_on", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node_off("mesecons_detector:object_detector_off", mesecon:get_rules("pressureplate"))

View File

@ -1,152 +0,0 @@
-- Mesecons Door
models = {
{
-- bottom part
{-0.5, -0.5, -0.5, -0.4, 0.5, 0.5},
-- A
{-0.5, 0.5, -0.5, -0.4, 1.5, -0.3},
-- B
{-0.5, 0.5, 0.3, -0.4, 1.5, 0.5},
-- C
{-0.5, 1.3, -0.3, -0.4, 1.5, 0.3},
-- D
{-0.5, 0.5, -0.3, -0.4, 0.6, 0.3},
-- E
{-0.5, 0.6, -0.05, -0.4, 1.3, 0.05},
-- F
{-0.5, 0.9, -0.3, -0.4, 1, -0.05},
-- G
{-0.5, 0.9, 0.05, -0.4, 1, 0.3}
},
{
{0.4, -0.5, -0.5, 0.5, 0.5, 0.5},
{0.4, 0.5, -0.5, 0.5, 1.5, -0.3},
{0.4, 0.5, 0.3, 0.5, 1.5, 0.5},
{0.4, 1.3, -0.3, 0.5, 1.5, 0.3},
{0.4, 0.5, -0.3, 0.5, 0.6, 0.3},
{0.4, 0.6, -0.05, 0.5, 1.3, 0.05},
{0.4, 0.9, -0.3, 0.5, 1, -0.05},
{0.4, 0.9, 0.05, 0.5, 1, 0.3}
},
{
{-0.5, -0.5, -0.5, 0.5, 0.5, -0.4},
{-0.5, 0.5, -0.5, -0.3, 1.5, -0.4},
{0.3, 0.5, -0.5, 0.5, 1.5, -0.4},
{-0.3, 1.3, -0.5, 0.3, 1.5, -0.4},
{-0.3, 0.5, -0.5, 0.3, 0.6, -0.4},
{-0.05, 0.6, -0.5, 0.05, 1.3, -0.4},
{-0.3, 0.9, -0.5, -0.05, 1, -0.4},
{0.05, 0.9, -0.5, 0.3, 1, -0.4}
},
{
{-0.5, -0.5, 0.4, 0.5, 0.5, 0.5},
{-0.5, 0.5, 0.4, -0.3, 1.5, 0.5},
{0.3, 0.5, 0.4, 0.5, 1.5, 0.5},
{-0.3, 1.3, 0.4, 0.3, 1.5, 0.5},
{-0.3, 0.5, 0.4, 0.3, 0.6, 0.5},
{-0.05, 0.6, 0.4, 0.05, 1.3, 0.5},
{-0.3, 0.9, 0.4, -0.05, 1, 0.5},
{0.05, 0.9, 0.4, 0.3, 1, 0.5}
}
}
selections = {
{-0.5, -0.5, -0.5, -0.4, 1.5, 0.5},
{0.5, -0.5, -0.5, 0.4, 1.5, 0.5},
{-0.5, -0.5, -0.5, 0.5, 1.5, -0.4},
{-0.5, -0.5, 0.4, 0.5, 1.5, 0.5}
}
transforms = {
door_1_1 = "door_4_2",
door_4_2 = "door_1_1",
door_2_1 = "door_3_2",
door_3_2 = "door_2_1",
door_3_1 = "door_1_2",
door_1_2 = "door_3_1",
door_4_1 = "door_2_2",
door_2_2 = "door_4_1"
}
mesecons_door_transform = function (pos, node)
local x, y = node.name:find(":")
local n = node.name:sub(x + 1)
if transforms[n] ~= nil then
minetest.env:add_node(pos, {name = "mesecons_door:"..transforms[n]})
else
print("not implemented")
end
end
for i = 1, 4 do
for j = 1, 2 do
minetest.register_node("mesecons_door:door_"..i.."_"..j, {
drawtype = "nodebox",
tile_images = {"default_wood.png"},
paramtype = "light",
is_ground_content = true,
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
drop = "mesecons_door:door",
node_box = {
type = "fixed",
fixed = models[i]
},
selection_box = {
type = "fixed",
fixed = {
selections[i]
}
},
on_punch = mesecons_door_transform
})
end
end
minetest.register_node("mesecons_door:door", {
description = "Wooden door",
node_placement_prediction = "",
inventory_image = 'door_wood.png',
wield_image = 'door_wood.png',
after_place_node = function(node_pos, placer)
local best_distance = 1e50
local best_number = 1
local pos = placer:getpos()
for i = 1, 4 do
local box = minetest.registered_nodes["mesecons_door:door_"..i.."_1"].selection_box.fixed[1]
box = {box[1] + node_pos.x, box[2] + node_pos.y, box[3] + node_pos.z, box[4] + node_pos.x, box[5] + node_pos.y, box[6] + node_pos.z}
local center = {x = (box[1] + box[4]) / 2, y = (box[2] + box[5]) / 2, z = (box[3] + box[6]) / 2}
local dist = math.pow(math.pow(center.x - pos.x, 2) + math.pow(center.y - pos.y, 2) + math.pow(center.z - pos.z, 2), 0.5)
if dist < best_distance then
best_distance = dist
best_number = i
end
end
minetest.env:add_node(node_pos, {name = "mesecons_door:door_"..best_number.."_1"})
end
})
minetest.register_on_placenode(function(pos, newnode, placer)
local b_pos = {x = pos.x, y = pos.y - 1, z = pos.z}
local node = minetest.env:get_node(b_pos)
if node.name:find("mesecons_door:door") ~= nil then
minetest.env:remove_node(pos)
minetest.env:add_item(pos, newnode.name)
end
end)
minetest.register_craft({
output = 'mesecons_door:door',
recipe = {
{ 'default:wood', 'default:wood', '' },
{ 'default:wood', 'default:wood', '' },
{ 'default:wood', 'default:wood', '' },
},
})
--MESECONS
mesecon:register_on_signal_change(function(pos, node)
if string.find(node.name, "mesecons_door:door_") then
mesecons_door_transform(pos, node)
end
end)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 B

View File

@ -0,0 +1,138 @@
for x=-1, 1 do for z=-1, 1 do
rules = {}
nodename = "mesecons_extrawires:crossing"
if x == -1 then
nodename = nodename .. "A"
table.insert(rules, {x=-1, y=0, z=0})
end
if z == 1 then
nodename = nodename .. "B"
table.insert(rules, {x=0, y=0, z=1})
end
if x == 1 then
nodename = nodename .. "C"
table.insert(rules, {x=1, y=0, z=0})
end
if z == -1 then
nodename = nodename .. "D"
table.insert(rules, {x=0, y=0, z=-1})
end
mesecon:add_rules(nodename, rules)
mesecon:register_effector(nodename, nodename, all_rules)
if nodename == "mesecons_extrawires:crossing" then
description = "Insulated Crossing"
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}
else
description = "You hacker you!"
drop = "mesecons_extrawires:crossing"
groups = {dig_immediate = 3, not_in_creative_inventory=1, mesecon = 3}
mesecon:add_receptor_node(nodename, rules)
end
minetest.register_node(nodename, {
drawtype = "nodebox",
description = description,
tiles = {
"jeija_insulated_wire_sides.png",
},
paramtype = "light",
walkable = false,
stack_max = 99,
selection_box = {
type = "fixed",
fixed = { -16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001 },
},
node_box = {
type = "fixed",
fixed = {
{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
{ -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
{ -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
{ -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
{ -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
},
},
groups = groups,
drop = drop,
})
end end
function receptor_set(pos, rules, on)
if on then
mesecon:receptor_on(pos, rules)
else
mesecon:receptor_off(pos, rules)
end
end
function update_plus(pos, name)
vL = {
a = string.find(name, "A")~=nil,
b = string.find(name, "B")~=nil,
c = string.find(name, "C")~=nil,
d = string.find(name, "D")~=nil,
}
rL = yc_get_real_portstates(pos)
L = {
a = rL.c and not vL.c,
b = rL.d and not vL.d,
c = rL.a and not vL.a,
d = rL.b and not vL.b,
}
newname = "mesecons_extrawires:crossing"
if L.a then newname = newname .. "A" end
if L.b then newname = newname .. "B" end
if L.c then newname = newname .. "C" end
if L.d then newname = newname .. "D" end
if newname ~= name then
minetest.env:add_node(pos, {name = newname})
end
if L.a ~= vL.a then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingA"), L.a)
if not L.a and yc_get_real_portstates(pos).a then
--catch signal changing direction while on
update_plus(pos, newname)
end
end
if L.b ~= vL.b then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingB"), L.b)
if not L.b and yc_get_real_portstates(pos).b then
update_plus(pos, newname)
end
end
if L.c ~= vL.c then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingC"), L.c)
if not L.c and yc_get_real_portstates(pos).c then
update_plus(pos, newname)
end
end
if L.d ~= vL.d then
receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingD"), L.d)
if not L.c and yc_get_real_portstates(pos).d then
update_plus(pos, newname)
end
end
end
mesecon:register_on_signal_change(function(pos, node)
if string.find(node.name, "mesecons_extrawires:crossing")~=nil then
update_plus(pos, node.name)
end
end)
minetest.register_craft({
type = "shapeless",
output = "mesecons_extrawires:crossing",
recipe = {
"mesecons_insulated:insulated_off",
"mesecons_insulated:insulated_off",
},
})
minetest.register_craft({
type = "shapeless",
output = "mesecons_insulated:insulated_off 2",
recipe = {
"mesecons_extrawires:crossing",
},
})

View File

@ -0,0 +1,6 @@
mesecons
mesecons_microcontroller
mesecons_delayer
mesecons_torch
mesecons_materials

View File

@ -0,0 +1,226 @@
outrules = {
{x=1, y=0, z=0},
}
oneinput = {
{x=-1, y=0, z=0},
{x=1, y=0, z=0},
}
twoinputs = {
{x=0, y=0, z=1},
{x=0, y=0, z=-1},
{x=1, y=0, z=0},
}
function get_gate_rules(param2, onlyout, singleinput)
if onlyout then
rules = outrules
else
if singleinput then
rules = oneinput
else
rules = twoinputs
end
end
for rotations=0, param2-1 do
rules = mesecon:rotate_rules_left(rules)
end
return rules
end
function get_gate_rules_one(param2) return get_gate_rules(param2, false, true) end
function get_gate_rules_two(param2) return get_gate_rules(param2, false, false) end
function get_gate_rules_out(param2) return get_gate_rules(param2, true) end
gates = {"diode", "not", "nand", "and", "xor"}
for g in ipairs(gates) do gate = gates[g]
if g < 3 then
get_rules = get_gate_rules_one
else
get_rules = get_gate_rules_two
end
for on=0,1 do
nodename = "mesecons_gates:"..gate
if on == 1 then
onoff = "on"
drop = nodename.."_off"
nodename = nodename.."_"..onoff
description = "You hacker you!"
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3}
mesecon:add_receptor_node(nodename, get_rules, get_gate_rules_out)
--mesecon:add_receptor_node(nodename, mesecon:get_rules("insulated_all"))
else
onoff = "off"
nodename = nodename.."_"..onoff
description = gate.." Gate"
groups = {dig_immediate=2, mesecon = 3}
--mesecon:add_receptor_node_off(nodename, get_gate_rules_out)
end
tiles = "jeija_microcontroller_bottom.png^"..
"jeija_gate_"..onoff..".png^"..
"jeija_gate_"..gate..".png"
node_box = {
type = "fixed",
fixed = {
{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
}
minetest.register_node(nodename, {
description = description,
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
tiles = {tiles},
inventory_image = tiles,
selection_box = node_box,
node_box = node_box,
walkable = true,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_int("heat", 0)
update_gate(pos)
end,
groups = groups,
drop = drop,
})
mesecon:register_effector(nodename, nodename, all_rules, get_rules)
end
end
function get_gate(pos)
return
string.gsub(
string.gsub(
string.gsub(
minetest.env:get_node(pos).name
, "mesecons_gates:", "") --gate
,"_on", "")
,"_off", "")
end
function gate_state(pos)
name = minetest.env:get_node(pos).name
return string.find(name, "_on") ~= nil
end
function pop_gate(pos)
gate = get_gate(pos)
minetest.env:remove_node(pos)
minetest.after(0.2, yc_overheat_off, pos)
minetest.env:add_item(pos, "mesecons_gates:"..gate.."_off")
end
function set_gate(pos, on)
gate = get_gate(pos)
local meta = minetest.env:get_meta(pos)
if on ~= gate_state(pos) then
yc_heat(meta)
minetest.after(0.5, yc_cool, meta)
if yc_overheat(meta) then
pop_gate(pos)
else
heat = meta:get_int("heat")
if on then
onoff = "_on"
else
onoff = "_off"
end
param2 = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, {
name = "mesecons_gates:"..gate..onoff,
param2 = param2,
})
local meta2 = minetest.env:get_meta(pos)
meta2:set_int("heat", heat)
if on then
mesecon:receptor_on(pos, get_gate_rules(param2, true))
else
mesecon:receptor_off(pos, all_rules)
end
end
end
end
function rotate_ports(L, param2)
for rotations=0, param2-1 do
port = L.a
L.a = L.b
L.b = L.c
L.c = L.d
L.d = port
end
return L
end
function update_gate(pos)
gate = get_gate(pos)
L = rotate_ports(
yc_get_real_portstates(pos),
minetest.env:get_node(pos).param2
)
if gate == "diode" then
set_gate(pos, L.a)
elseif gate == "not" then
set_gate(pos, not L.a)
elseif gate == "nand" then
set_gate(pos, not(L.b and L.d))
elseif gate == "and" then
set_gate(pos, L.b and L.d)
else--if gate == "xor" then
set_gate(pos, (L.b and not L.d) or (not L.b and L.d))
end
end
mesecon:register_on_signal_change(function(pos,node)
if string.find(node.name, "mesecons_gates:")~=nil then
update_gate(pos)
end
end)
minetest.register_craft({
output = 'mesecons_gates:diode_off',
recipe = {
{'', '', ''},
{'mesecons:mesecon', 'mesecons_torch:mesecon_torch_on', 'mesecons_torch:mesecon_torch_on'},
{'', '', ''},
},
})
minetest.register_craft({
output = 'mesecons_gates:not_off',
recipe = {
{'', '', ''},
{'mesecons:mesecon', 'mesecons_torch:mesecon_torch_on', 'mesecons:mesecon'},
{'', '', ''},
},
})
minetest.register_craft({
output = 'mesecons_gates:and_off',
recipe = {
{'mesecons:mesecon', '', ''},
{'', 'mesecons_materials:silicon', 'mesecons:mesecon'},
{'mesecons:mesecon', '', ''},
},
})
minetest.register_craft({
output = 'mesecons_gates:nand_off',
recipe = {
{'mesecons:mesecon', '', ''},
{'', 'mesecons_materials:silicon', 'mesecons_torch:mesecon_torch_on'},
{'mesecons:mesecon', '', ''},
},
})
minetest.register_craft({
output = 'mesecons_gates:xor_off',
recipe = {
{'mesecons:mesecon', '', ''},
{'', 'mesecons_materials:silicon', 'mesecons_materials:silicon'},
{'mesecons:mesecon', '', ''},
},
})

View File

@ -2,7 +2,7 @@
minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
drawtype = "nodebox",
tile_images = {"jeija_hydro_turbine_off.png"},
tiles = {"jeija_hydro_turbine_off.png"},
groups = {dig_immediate=2, mesecon = 2},
description="Water Turbine",
paramtype = "light",
@ -24,7 +24,7 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
drawtype = "nodebox",
tile_images = {"jeija_hydro_turbine_on.png"},
tiles = {"jeija_hydro_turbine_on.png"},
drop = '"mesecons_hydroturbine:hydro_turbine_off" 1',
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 2},
description="Water Turbine",
@ -53,7 +53,6 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.env:get_node(waterpos).name=="default:water_flowing" then
--minetest.env:remove_node(pos)
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
nodeupdate(pos)
mesecon:receptor_on(pos)
@ -68,7 +67,6 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.env:get_node(waterpos).name~="default:water_flowing" then
--minetest.env:remove_node(pos)
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
nodeupdate(pos)
mesecon:receptor_off(pos)

View File

@ -0,0 +1,81 @@
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_ends_on.png",
"jeija_insulated_wire_ends_on.png",
"jeija_insulated_wire_sides.png",
"jeija_insulated_wire_sides.png"
},
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -16/32-0.001, -18/32, -7/32, 16/32+0.001, -12/32, 7/32 }
},
node_box = {
type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
},
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1},
drop = "mesecons_insulated:insulated_off",
})
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_ends_off.png",
"jeija_insulated_wire_ends_off.png",
"jeija_insulated_wire_sides.png",
"jeija_insulated_wire_sides.png"
},
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -16/32-0.001, -18/32, -7/32, 16/32+0.001, -12/32, 7/32 }
},
node_box = {
type = "fixed",
fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
},
groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1},
})
minetest.register_craft({
output = '"mesecons_insulated:insulated_off" 3',
recipe = {
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
{"mesecons:wire_00000000_off", "mesecons:wire_00000000_off", "mesecons:wire_00000000_off"},
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
}
})
mesecon:add_rules("insulated_all", { --all possible 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},})
mesecon:add_rules("insulated", {
{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},})
function insulated_wire_get_rules(param2)
if param2 == 1 or param2 == 3 then
return mesecon:rotate_rules_right(mesecon:get_rules("insulated"))
end
return mesecon:get_rules("insulated")
end
mesecon:register_conductor("mesecons_insulated:insulated_on", "mesecons_insulated:insulated_off", mesecon:get_rules("insulated_all"), insulated_wire_get_rules)

View File

@ -1,7 +1,7 @@
-- MESELAMPS
minetest.register_node("mesecons_lamp:lamp_on", {
drawtype = "nodebox",
tile_images = {"jeija_meselamp_on.png"},
tiles = {"jeija_meselamp_on.png"},
paramtype = "light",
paramtype2 = "wallmounted",
legacy_wallmounted = true,
@ -26,7 +26,7 @@ minetest.register_node("mesecons_lamp:lamp_on", {
minetest.register_node("mesecons_lamp:lamp_off", {
drawtype = "nodebox",
tile_images = {"jeija_meselamp_off.png"},
tiles = {"jeija_meselamp_off.png"},
inventory_image = "jeija_meselamp.png",
wield_image = "jeija_meselamp.png",
paramtype = "light",
@ -71,3 +71,5 @@ mesecon:register_on_signal_off(function(pos, node)
nodeupdate(pos)
end
end)
mesecon:register_effector("mesecons_lamp:lamp_on", "mesecons_lamp:lamp_off")

View File

@ -1,14 +1,14 @@
function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_off", {
tile_images = {texture_off},
tiles = {texture_off},
inventory_image = minetest.inventorycube(texture_off),
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
description=name.." Lightstone",
})
minetest.register_node("mesecons_lightstone:lightstone_" .. name .. "_on", {
tile_images = {texture_on},
tiles = {texture_on},
inventory_image = minetest.inventorycube(texture_on),
groups = {cracky=2,not_in_creative_inventory=1, mesecon_effector_on = 1, mesecon = 2},
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
drop = "node mesecons_lightstone:lightstone_" .. name .. "_off 1",
light_source = LIGHT_MAX-2,
description=name.." Lightstone",
@ -33,10 +33,12 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
{'','group:mesecon_conductor_craftable',''},
}
})
mesecon:register_effector("mesecons_lightstone:lightstone_" .. name .. "_on", "mesecons_lightstone:lightstone_" .. name .. "_off")
end
mesecon:lightstone_add("red", "craft default:clay_brick 1", "jeija_lightstone_red_off.png", "jeija_lightstone_red_on.png")
mesecon:lightstone_add("green", "node default:cactus 1", "jeija_lightstone_green_off.png", "jeija_lightstone_green_on.png")
mesecon:lightstone_add("blue", "node mesecons_materials:fiber 1", "jeija_lightstone_blue_off.png", "jeija_lightstone_blue_on.png")
mesecon:lightstone_add("gray", "node default:cobble 1", "jeija_lightstone_gray_off.png", "jeija_lightstone_gray_on.png")
mesecon:lightstone_add("darkgray", "node default:gravel 1", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_darkgray_on.png")

View File

@ -5,12 +5,24 @@ minetest.register_craftitem("mesecons_materials:glue", {
description="Glue",
})
minetest.register_craftitem("mesecons_materials:fiber", {
image = "jeija_fiber.png",
on_place_on_ground = minetest.craftitem_place_item,
description="Fiber",
})
minetest.register_craft({
output = '"mesecons_materials:glue" 2',
recipe = {
{'"default:junglegrass"', '"default:junglegrass"'},
{'"default:junglegrass"', '"default:junglegrass"'},
}
type = "cooking",
recipe = "default:sapling",
cooktime = 2
})
minetest.register_craft({
output = '"mesecons_materials:fiber" 6',
type = "cooking",
recipe = "mesecons_materials:glue",
cooktime = 4
})
-- Silicon

View File

@ -1,3 +1,9 @@
mesecon:add_rules("microcontroller_all", { --flat rules (looks better with nodebox wires connection)
{x = 1, y = 0, z = 0 },
{x = 0, y = 0, z = 1 },
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = -1}})
EEPROM_SIZE = 255
for a = 0, 1 do
@ -5,25 +11,40 @@ for b = 0, 1 do
for c = 0, 1 do
for d = 0, 1 do
local nodename = "mesecons_microcontroller:microcontroller"..tostring(d)..tostring(c)..tostring(b)..tostring(a)
local top = "jeija_microcontroller_top.png"
if tostring(a) == "1" then
top = top.."^jeija_microcontroller_LED_A.png"
end
if tostring(b) == "1" then
top = top.."^jeija_microcontroller_LED_B.png"
end
if tostring(c) == "1" then
top = top.."^jeija_microcontroller_LED_C.png"
end
if tostring(d) == "1" then
top = top.."^jeija_microcontroller_LED_D.png"
end
if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon_effector_on = 1, mesecon_effector_off = 0, mesecon = 2}
groups = {dig_immediate=2, not_in_creative_inventory=1, mesecon = 3}
else
groups = {dig_immediate=2, mesecon_effector_on = 1, mesecon_effector_off = 0, mesecon = 2}
groups = {dig_immediate=2, mesecon = 3}
end
minetest.register_node(nodename, {
description = "Microcontroller",
drawtype = "nodebox",
tiles = {
"jeija_microcontroller_top_"..tostring(d)..tostring(c)..tostring(b)..tostring(a)..".png",
top,
"jeija_microcontroller_bottom.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png"
},
--inventory_image = "jeija_microcontroller_top_0000.png",
sunlight_propagates = true,
paramtype = "light",
walkable = true,
groups = groups,
material = minetest.digprop_constanttime(1.0),
drop = '"mesecons_microcontroller:microcontroller0000" 1',
selection_box = {
type = "fixed",
@ -51,6 +72,7 @@ minetest.register_node(nodename, {
"button_exit[3.5,1;2,3;program;Program]")
meta:set_string("infotext", "Unprogrammed Microcontroller")
meta:set_int("heat", 0)
meta:set_int("working", 0)
local r = ""
for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0"
meta:set_string("eeprom", r)
@ -69,7 +91,7 @@ minetest.register_node(nodename, {
fields.code = "if(A)sbi(1,1); if(!A&#1&B)off(B)sbi(1,0); if(!A&#1&!B)on(B)sbi(1,0); :A is input, B is output (Q), toggles with falling edge"
elseif fields.brsflop then
fields.code = "if(A)on(C);if(B)off(C); :A is S (Set), B is R (Reset), C is output (R dominates)"
elseif fields.program then --nothing
elseif fields.program or fields.code then --nothing
else return nil end
meta:set_string("code", fields.code)
@ -83,21 +105,21 @@ minetest.register_node(nodename, {
"button[7.5,0.2;1.5,3;brsflop;RS-Flop]"..
"button_exit[3.5,1;2,3;program;Program]")
meta:set_string("infotext", "Programmed Microcontroller")
meta:set_int("heat", 0)
yc_reset (pos)
update_yc(pos)
end,
})
local rules={}
if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end
if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end
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
mesecon:add_rules(nodename, rules)
mesecon:register_effector(nodename, nodename, mesecon:get_rules("microcontroller_all"))
if nodename ~= "mesecons_microcontroller:microcontroller0000" then
mesecon:add_receptor_node(nodename, rules)
else
mesecon:add_receptor_node_off(nodename)
end
end
end
@ -116,6 +138,8 @@ minetest.register_craft({
function yc_reset(pos)
yc_action(pos, {a=false, b=false, c=false, d=false})
local meta = minetest.env:get_meta(pos)
meta:set_int("heat", 0)
meta:set_int("afterid", 0)
local r = ""
for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0"
meta:set_string("eeprom", r)
@ -135,10 +159,10 @@ function update_yc(pos)
code = yc_code_remove_commentary(code)
code = string.gsub(code, " ", "") --Remove all spaces
code = string.gsub(code, " ", "") --Remove all tabs
if parse_yccode(code, pos) == nil then
meta:set_string("infotext", "Code not valid!")
if yc_parsecode(code, pos) == nil then
meta:set_string("infotext", "Code not valid!\n"..code)
else
meta:set_string("infotext", "Working Microcontroller")
meta:set_string("infotext", "Working Microcontroller\n"..code)
end
end
@ -157,13 +181,16 @@ function yc_code_remove_commentary(code)
return code
end
function parse_yccode(code, pos)
function yc_parsecode(code, pos)
local meta = minetest.env:get_meta(pos)
if meta:get_int("working") == 1 then return false end
meta:set_int("working", 1)
local endi = 1
local Lreal = yc_get_real_portstates(pos)
local Lvirtual = yc_get_virtual_portstates(pos)
if Lvirtual == nil then return nil end
local c
local eeprom = minetest.env:get_meta(pos):get_string("eeprom")
local eeprom = meta:get_string("eeprom")
while true do
command, endi = parse_get_command(code, endi)
if command == nil then return nil end
@ -190,8 +217,11 @@ function parse_yccode(code, pos)
elseif command == "off" then
L = yc_command_off(params, Lvirtual)
elseif command == "print" then
su = yc_command_print(params, eeprom, yc_merge_portstates(Lreal, Lvirtual))
local su = yc_command_print(params, eeprom, yc_merge_portstates(Lreal, Lvirtual))
if su ~= true then return nil end
elseif command == "after" then
local su = yc_command_after(params, pos)
if su == nil then return nil end
elseif command == "sbi" then
new_eeprom, Lvirtual = yc_command_sbi (params, eeprom, yc_merge_portstates(Lreal, Lvirtual), Lvirtual)
if new_eeprom == nil then return nil
@ -205,6 +235,7 @@ function parse_yccode(code, pos)
minetest.env:get_meta(pos):set_string("eeprom", eeprom) end
end
yc_action(pos, Lvirtual)
minetest.env:get_meta(pos):set_int("working", 0)
return true
end
@ -373,6 +404,42 @@ function yc_command_sbi(params, eeprom, L, Lv)
return new_eeprom, Lv
end
-- after (delay)
function yc_command_after(params, pos)
if params[1] == nil or params[2] == nil or params[3] ~= nil then return nil end
--get time (maximum time is 200)
local time = tonumber(params[1])
if time == nil or time > 200 then
return nil
end
--get code in quotes "code"
if string.sub(params[2], 1, 1) ~= '"' or string.sub(params[2], #params[2], #params[2]) ~= '"' then return nil end
local code = string.sub(params[2], 2, #params[2] - 1)
local afterid = math.random(10000)
local meta = minetest.env:get_meta(pos)
meta:set_int("afterid", afterid)
minetest.after(time, yc_command_after_execute, {pos = pos, code = code, afterid = afterid})
return true
end
function yc_command_after_execute(params)
local meta = minetest.env:get_meta(params.pos)
if meta:get_int("afterid") == params.afterid then --make sure the node has not been changed
if yc_parsecode(params.code, params.pos) == nil then
meta:set_string("infotext", "Code in after() not valid!")
else
if code ~= nil then
meta:set_string("infotext", "Working Microcontroller\n"..code)
else
meta:set_string("infotext", "Working Microcontroller")
end
end
end
end
--If
function yc_command_if(code, starti, L, eeprom)
local cond, endi = yc_command_if_getcondition(code, starti)
@ -447,6 +514,7 @@ function yc_command_parsecondition(cond, L, eeprom)
if cond:sub(i+1, i+1) == nil then break end
if s == "=" then
if a==nil then return nil end
if b==nil then return nil end
if a == b then buf = "1" end
if a ~= b then buf = "0" end
cond = string.gsub(cond, b..s..a, buf)
@ -506,25 +574,15 @@ end
--Real I/O functions
function yc_action(pos, L) --L-->Lvirtual
Lv = yc_get_virtual_portstates(pos)
local meta = minetest.env:get_meta(pos)
local code = meta:get_string("code")
local heat = meta:get_int("heat")
local eeprom = meta:get_string("eeprom")
local infotext = meta:get_string("infotext")
local formspec = meta:get_string("formspec")
local Lv = yc_get_virtual_portstates(pos)
local metatable = minetest.env:get_meta(pos):to_table()
local name = "mesecons_microcontroller:microcontroller"
..tonumber(L.d and 1 or 0)
..tonumber(L.c and 1 or 0)
..tonumber(L.b and 1 or 0)
..tonumber(L.a and 1 or 0)
minetest.env:add_node(pos, {name=name})
local meta = minetest.env:get_meta(pos)
meta:set_string("code", code)
meta:set_int("heat", heat)
meta:set_string("eeprom", eeprom)
meta:set_string("infotext", infotext)
meta:set_string("formspec", formspec)
minetest.env:get_meta(pos):from_table(metatable)
yc_action_setports(pos, L, Lv)
end
@ -537,7 +595,7 @@ function yc_action_setports(pos, L, Lv)
if L.a == true then mesecon:receptor_on(pos, rules)
else mesecon:receptor_off(pos, rules) end
end
if Lv.b ~= L.b then
if Lv.b ~= L.b then
rules = mesecon:get_rules(name.."0010")
if L.b == true then mesecon:receptor_on(pos, rules)
else mesecon:receptor_off(pos, rules) end
@ -569,10 +627,10 @@ function yc_get_real_portstates(pos)
rulesC = mesecon:get_rules("mesecons_microcontroller:microcontroller0100")
rulesD = mesecon:get_rules("mesecons_microcontroller:microcontroller1000")
L = {
a = mesecon:is_power_on({x=pos.x+rulesA[1].x, y=pos.y+rulesA[1].y, z=pos.z+rulesA[1].z}),
b = mesecon:is_power_on({x=pos.x+rulesB[1].x, y=pos.y+rulesB[1].y, z=pos.z+rulesB[1].z}),
c = mesecon:is_power_on({x=pos.x+rulesC[1].x, y=pos.y+rulesC[1].y, z=pos.z+rulesC[1].z}),
d = mesecon:is_power_on({x=pos.x+rulesD[1].x, y=pos.y+rulesD[1].y, z=pos.z+rulesD[1].z})
a = mesecon:is_power_on({x=pos.x+rulesA[1].x, y=pos.y+rulesA[1].y, z=pos.z+rulesA[1].z}) and mesecon:rules_link({x=pos.x+rulesA[1].x, y=pos.y+rulesA[1].y, z=pos.z+rulesA[1].z}, pos),
b = mesecon:is_power_on({x=pos.x+rulesB[1].x, y=pos.y+rulesB[1].y, z=pos.z+rulesB[1].z}) and mesecon:rules_link({x=pos.x+rulesB[1].x, y=pos.y+rulesB[1].y, z=pos.z+rulesB[1].z}, pos),
c = mesecon:is_power_on({x=pos.x+rulesC[1].x, y=pos.y+rulesC[1].y, z=pos.z+rulesC[1].z}) and mesecon:rules_link({x=pos.x+rulesC[1].x, y=pos.y+rulesC[1].y, z=pos.z+rulesC[1].z}, pos),
d = mesecon:is_power_on({x=pos.x+rulesD[1].x, y=pos.y+rulesD[1].y, z=pos.z+rulesD[1].z}) and mesecon:rules_link({x=pos.x+rulesD[1].x, y=pos.y+rulesD[1].y, z=pos.z+rulesD[1].z}, pos)
}
return L
end
@ -627,7 +685,7 @@ end
function yc_overheat_off(pos)
rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111")
mesecon:receptor_off(pos, rules);
mesecon:receptor_off(pos, rules)
end
mesecon:register_on_signal_change(function(pos, node)

View File

@ -36,12 +36,13 @@ function mesecon:get_movestone_direction(pos)
end
minetest.register_node("mesecons_movestones:movestone", {
tile_images = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
tiles = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_arrows.png", "jeija_movestone_arrows.png"},
paramtype2 = "facedir",
legacy_facedir_simple = true,
groups = {cracky=3, mesecon_effector_on = 1, mesecon_effector_off = 1},
groups = {cracky=3},
description="Movestone",
})
mesecon:register_effector("mesecons_movestones:movestone", "mesecons_movestones:movestone")
minetest.register_entity("mesecons_movestones:movestone_entity", {
physical = false,
@ -98,8 +99,7 @@ mesecon:register_on_signal_on(function (pos, node)
end
until checknode.name=="air"
or checknode.name=="ignore"
or checknode.name=="default:water"
or checknode.name=="default:water_flowing"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
minetest.env:remove_node(pos)
nodeupdate(pos)
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
@ -112,13 +112,14 @@ end)
-- STICKY_MOVESTONE
minetest.register_node("mesecons_movestones:sticky_movestone", {
tile_images = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"},
tiles = {"jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_movestone_side.png", "jeija_sticky_movestone.png", "jeija_sticky_movestone.png"},
inventory_image = minetest.inventorycube("jeija_sticky_movestone.png", "jeija_movestone_side.png", "jeija_movestone_side.png"),
paramtype2 = "facedir",
legacy_facedir_simple = true,
groups = {cracky=3, mesecon_effector_on = 1, mesecon_effector_off = 1},
groups = {cracky=3},
description="Sticky Movestone",
})
mesecon:register_effector("mesecons_movestones:sticky_movestone", "mesecons_movestones:sticky_movestone")
minetest.register_craft({
output = '"mesecons_movestones:sticky_movestone" 2',
@ -175,8 +176,7 @@ mesecon:register_on_signal_on(function (pos, node)
end
until checknode.name=="air"
or checknode.name=="ignore"
or checknode.name=="default:water"
or checknode.name=="default:water_flowing"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
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)
@ -185,9 +185,7 @@ mesecon:register_on_signal_on(function (pos, node)
end
until checknode.name=="air"
or checknode.name=="ignore"
or checknode.name=="default:water"
or checknode.name=="default:water_flowing"
or not(minetest.registered_nodes[checknode.name].liquidtype == "none")
minetest.env:remove_node(pos)
nodeupdate(pos)
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")

View File

@ -29,7 +29,7 @@ function mesecon:mvps_push(pos, direction) -- pos: pos of mvps; direction: direc
local lnode = minetest.env:get_node(lpos)
local newnode
minetest.env:remove_node(lpos)
while not(lnode.name == "ignore" or lnode.name == "air" or lnode.name == "default:water" or lnode.name == "default:water_flowing") do
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
@ -46,8 +46,8 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
local lnode2 = minetest.env:get_node(lpos2)
if lnode.name ~= "ignore" and lnode.name ~= "air" and lnode.name ~= "default:water" and lnode.name ~= "default:water_flowing" then return end
if lnode2.name == "ignore" or lnode2.name == "air" or lnode2.name == "default:water" or lnode2.name == "default:water_flowing" then return end
if lnode.name ~= "ignore" and lnode.name ~= "air" and minetest.registered_nodes[lnode.name].liquidtype == "none" then return end
if lnode2.name == "ignore" or lnode2.name == "air" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") then return end
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
repeat
@ -58,7 +58,7 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
lpos2.y = lpos2.y-direction.y
lpos2.z = lpos2.z-direction.z
lnode = minetest.env:get_node(lpos2)
until lnode.name=="air" or lnode.name=="ignore" or lnode.name=="default:water" or lnode.name=="default:water_flowing"
until lnode.name=="air" or lnode.name=="ignore" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none")
minetest.env:remove_node(oldpos)
end

View File

@ -1,7 +1,7 @@
minetest.register_node("mesecons_noteblock:noteblock", {
description = "Noteblock",
tile_images = {"mesecons_noteblock.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_effector_off = 1, mesecon = 2},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
drawtype = "allfaces_optional",
visual_scale = 1.3,
paramtype="light",
@ -9,6 +9,7 @@ minetest.register_node("mesecons_noteblock:noteblock", {
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
end
})
mesecon:register_effector("mesecons_noteblock:noteblock", "mesecons_noteblock:noteblock")
minetest.register_craft({
output = '"mesecons_noteblock:noteblock" 1',

View File

@ -3,7 +3,7 @@
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_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=3, mesecon = 2},
paramtype2 = "facedir",
after_dig_node = function(pos, oldnode)
local dir = mesecon:piston_get_direction(oldnode)
@ -18,12 +18,13 @@ minetest.register_node("mesecons_pistons:piston_normal", {
end
end,
})
mesecon:register_effector("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal")
--registration sticky one:
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_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=3, mesecon = 2},
paramtype2 = "facedir",
after_dig_node = function(pos, oldnode)
local dir = mesecon:piston_get_direction(oldnode)
@ -38,6 +39,7 @@ minetest.register_node("mesecons_pistons:piston_sticky", {
end
end,
})
mesecon:register_effector("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky")
minetest.register_craft({
output = '"mesecons_pistons:piston_normal" 2',
@ -133,10 +135,7 @@ mesecon:register_on_signal_on(function(pos, node)
--check for column end
if checknode.name == "air"
or checknode.name == "ignore"
or checknode.name == "default:water_source"
or checknode.name == "default:water_flowing"
or checknode.name == "default:lava_source"
or checknode.name == "default:lava_flowing" then
or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then
break
end
@ -201,10 +200,7 @@ mesecon:register_on_signal_off(function(pos, node)
checknode = minetest.env:get_node(checkpos)
if checknode.name ~= "air"
and checknode.name ~= "ignore"
and checknode.name ~= "default:water_source"
and checknode.name ~= "default:water_flowing"
and checknode.name ~= "default:lava_source"
and checknode.name ~= "default:lava_flowing"
and minetest.registered_nodes[checknode.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(checknode.name) then
minetest.env:set_node(pos, checknode)
minetest.env:remove_node(checkpos)

View File

@ -3,7 +3,7 @@
minetest.register_node("mesecons_pistons:piston_down_normal", {
description = "Piston DOWN",
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_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=-1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
@ -18,11 +18,13 @@ minetest.register_node("mesecons_pistons:piston_down_normal", {
end,
})
mesecon:register_effector("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal")
--registration sticky one:
minetest.register_node("mesecons_pistons:piston_down_sticky", {
description = "Sticky Piston DOWN",
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_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=-1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
@ -37,6 +39,8 @@ minetest.register_node("mesecons_pistons:piston_down_sticky", {
end,
})
mesecon:register_effector("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky")
minetest.register_craft({
output = "mesecons_pistons:piston_down_normal",
recipe = {
@ -137,10 +141,7 @@ mesecon:register_on_signal_on(function(pos, node)
--check for column end
if checknode.name == "air"
or checknode.name == "ignore"
or checknode.name == "default:water_source"
or checknode.name == "default:water_flowing"
or checknode.name == "default:lava_source"
or checknode.name == "default:lava_flowing" then
or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then
break
end
@ -205,10 +206,7 @@ mesecon:register_on_signal_off(function(pos, node)
checknode = minetest.env:get_node(checkpos)
if checknode.name ~= "air"
and checknode.name ~= "ignore"
and checknode.name ~= "default:water_source"
and checknode.name ~= "default:water_flowing"
and checknode.name ~= "default:lava_source"
and checknode.name ~= "default:lava_flowing"
and minetest.registered_nodes[checknode.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(checknode.name) then
minetest.env:remove_node(checkpos)
mesecon:updatenode(checkpos)

View File

@ -3,7 +3,7 @@
minetest.register_node("mesecons_pistons:piston_up_normal", {
description = "Piston UP",
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_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
@ -18,11 +18,13 @@ minetest.register_node("mesecons_pistons:piston_up_normal", {
end,
})
mesecon:register_effector("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal")
--registration sticky one:
minetest.register_node("mesecons_pistons:piston_up_sticky", {
description = "Sticky Piston UP",
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_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=3, mesecon = 2},
after_dig_node = function(pos, oldnode)
local dir = {x=0, y=1, z=0}
pos.x, pos.y, pos.z = pos.x + dir.x, pos.y + dir.y, pos.z + dir.z --move to first node to check
@ -37,6 +39,8 @@ minetest.register_node("mesecons_pistons:piston_up_sticky", {
end,
})
mesecon:register_effector("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky")
minetest.register_craft({
output = "mesecons_pistons:piston_up_normal",
recipe = {
@ -125,10 +129,7 @@ mesecon:register_on_signal_on(function(pos, node)
--check for column end
if checknode.name == "air"
or checknode.name == "ignore"
or checknode.name == "default:water_source"
or checknode.name == "default:water_flowing"
or checknode.name == "default:lava_source"
or checknode.name == "default:lava_flowing" then
or not(minetest.registered_nodes[checknode.name].liquidtype == "none") then
break
end
@ -193,10 +194,7 @@ mesecon:register_on_signal_off(function(pos, node)
checknode = minetest.env:get_node(checkpos)
if checknode.name ~= "air"
and checknode.name ~= "ignore"
and checknode.name ~= "default:water_source"
and checknode.name ~= "default:water_flowing"
and checknode.name ~= "default:lava_source"
and checknode.name ~= "default:lava_flowing"
and minetest.registered_nodes[checknode.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(checknode.name) then
minetest.env:remove_node(checkpos)
mesecon:updatenode(checkpos)

View File

@ -10,12 +10,6 @@ minetest.register_node("mesecons_powerplant:power_plant", {
groups = {dig_immediate=3, mesecon = 2},
light_source = LIGHT_MAX-9,
description="Power Plant",
after_place_node = function(pos)
mesecon:receptor_on(pos)
end,
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end,
selection_box = {
type = "fixed",
fixed = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
@ -27,7 +21,7 @@ minetest.register_craft({
recipe = {
{'"group:mesecon_conductor_craftable"'},
{'"group:mesecon_conductor_craftable"'},
{'"default:junglegrass"'},
{'"default:sapling"'},
}
})

View File

@ -2,7 +2,7 @@
minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", {
drawtype = "nodebox",
tile_images = {"jeija_pressure_plate_wood_off.png"},
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",
@ -22,7 +22,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_off", {
minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
drawtype = "nodebox",
tile_images = {"jeija_pressure_plate_wood_on.png"},
tiles = {"jeija_pressure_plate_wood_on.png"},
paramtype = "light",
is_ground_content = true,
walkable = true,
@ -36,9 +36,6 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_wood_on", {
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
drop='"mesecons_pressureplates:pressure_plate_wood_off" 1',
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
})
minetest.register_craft({
@ -77,14 +74,11 @@ minetest.register_abm(
end,
})
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on")
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off")
-- PRESSURE PLATE STONE
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
drawtype = "nodebox",
tile_images = {"jeija_pressure_plate_stone_off.png"},
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",
@ -104,7 +98,7 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_off", {
minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
drawtype = "nodebox",
tile_images = {"jeija_pressure_plate_stone_on.png"},
tiles = {"jeija_pressure_plate_stone_on.png"},
paramtype = "light",
is_ground_content = true,
walkable = true,
@ -118,9 +112,6 @@ minetest.register_node("mesecons_pressureplates:pressure_plate_stone_on", {
},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,not_in_creative_inventory=1, mesecon = 2},
drop='"mesecons_pressureplates:pressure_plate_stone_off" 1',
after_dig_node = function(pos)
mesecon:receptor_off(pos, mesecon:get_rules("pressureplate"))
end
})
minetest.register_craft({
@ -159,9 +150,6 @@ minetest.register_abm(
end,
})
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on")
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off")
mesecon:add_rules("pressureplate",
{{x=0, y=1, z=-1},
{x=0, y=0, z=-1},
@ -178,3 +166,9 @@ mesecon:add_rules("pressureplate",
{x=0, y=-1, z=0},
{x=0, y=-2, z=0},
{x=0, y=1, z=0}})
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_wood_on", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_wood_off", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node("mesecons_pressureplates:pressure_plate_stone_on", mesecon:get_rules("pressureplate"))
mesecon:add_receptor_node_off("mesecons_pressureplates:pressure_plate_stone_off", mesecon:get_rules("pressureplate"))

View File

@ -1,13 +1,15 @@
-- REMOVE_STONE
minetest.register_node("mesecons_random:removestone", {
tile_images = {"jeija_removestone.png"},
tiles = {"jeija_removestone.png"},
inventory_image = minetest.inventorycube("jeija_removestone_inv.png"),
material = minetest.digprop_stonelike(1.0),
groups = {cracky=3, mesecon_effector_off = 1, mesecon = 2},
groups = {cracky=3, mesecon = 2},
description="Removestone",
})
mesecon:register_effector(nil, "mesecons_random:removestone")
minetest.register_craft({
output = '"mesecons_random:removestone" 4',
recipe = {

View File

@ -0,0 +1,167 @@
rcvboxes = {
{ -3/16, -3/16 , -8/16 , 3/16, 3/16, -13/32 }, -- the smaller bump
{ -5/32, -5/32 , -13/32 , 5/32, 5/32, -12/32 }, -- the receiver itself
{ -3/32, -.5-1/32, -.5 , 3/32, 0 , -.5002+3/32 }, -- the vertical wire bit
{ -3/32, -17/32 , -7/16+0.002 , 3/32, -13/32, 16/32+0.001 } -- the horizontal wire
}
minetest.register_node("mesecons_receiver:receiver_on", {
drawtype = "nodebox",
tiles = {
"receiver_top_on.png",
"receiver_bottom_on.png",
"receiver_lr_on.png",
"receiver_lr_on.png",
"receiver_fb_on.png",
"receiver_fb_on.png",
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = rcvboxes
},
groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off",
})
minetest.register_node("mesecons_receiver:receiver_off", {
drawtype = "nodebox",
description = "You hacker you",
tiles = {
"receiver_top_off.png",
"receiver_bottom_off.png",
"receiver_lr_off.png",
"receiver_lr_off.png",
"receiver_fb_off.png",
"receiver_fb_off.png",
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -3/16, -8/16, -8/16, 3/16, 3/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = rcvboxes
},
groups = {dig_immediate = 3, mesecon = 3},
drop = "mesecons:wire_00000000_off",
})
mesecon:add_rules("receiver_pos", {{x = 2, y = 0, z = 0}})
mesecon:add_rules("receiver_pos_all", {
{x = 2, y = 0, z = 0},
{x =-2, y = 0, z = 0},
{x = 0, y = 0, z = 2},
{x = 0, y = 0, z =-2}})
mesecon:add_rules("mesecon_receiver", {
{x = 1, y = 0, z = 0},
{x = -2, y = 0, z = 0},})
mesecon:add_rules("mesecon_receiver_all", {
{x = 1, y = 0, z = 0},
{x =-2, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 2, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-2},
{x = 1, y = 0, z =-1},
{x =-2, y = 0, z = 2},})
function receiver_get_rules(param2)
local rules = mesecon:get_rules("mesecon_receiver")
if param2 == 2 then
rules = mesecon:rotate_rules_left(rules)
elseif param2 == 3 then
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
elseif param2 == 0 then
rules = mesecon:rotate_rules_right(rules)
end
return rules
end
mesecon:register_conductor("mesecons_receiver:receiver_on", "mesecons_receiver:receiver_off", mesecon:get_rules("mesecon_receiver_all"), receiver_get_rules)
function mesecon:receiver_get_pos_from_rcpt(pos, param2)
local rules = mesecon:get_rules("receiver_pos")
if param2 == nil then param2 = minetest.env:get_node(pos).param2 end
if param2 == 2 then
rules = mesecon:rotate_rules_left(rules)
elseif param2 == 3 then
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
elseif param2 == 0 then
rules = mesecon:rotate_rules_right(rules)
end
np = {
x = pos.x + rules[1].x,
y = pos.y + rules[1].y,
z = pos.z + rules[1].z}
return np
end
function mesecon:receiver_place(rcpt_pos)
local node = minetest.env:get_node(rcpt_pos)
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
local nn = minetest.env:get_node(pos)
if string.find(nn.name, "mesecons:wire_") ~= nil then
minetest.env:dig_node(pos)
if mesecon:is_power_on(rcpt_pos) then
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
mesecon:receptor_on(pos, receiver_get_rules(node.param2))
else
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
end
mesecon:update_autoconnect(pos)
end
end
function mesecon:receiver_remove(rcpt_pos, dugnode)
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
local nn = minetest.env:get_node(pos)
if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
minetest.env:dig_node(pos)
minetest.env:place_node(pos, {name = "mesecons:wire_00000000_off"})
mesecon:update_autoconnect(pos)
end
end
minetest.register_on_placenode(function (pos, node)
if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
mesecon:receiver_place(pos)
end
end)
minetest.register_on_dignode(function(pos, node)
if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
mesecon:receiver_remove(pos, node)
end
end)
minetest.register_on_placenode(function (pos, node)
if string.find(node.name, "mesecons:wire_") ~=nil then
rules = mesecon:get_rules("receiver_pos_all")
local i = 1
while rules[i] ~= nil do
np = {
x = pos.x + rules[i].x,
y = pos.y + rules[i].y,
z = pos.z + rules[i].z}
if minetest.get_item_group(minetest.env:get_node(np).name, "mesecon_needs_receiver") == 1 then
mesecon:receiver_place(np)
end
i = i + 1
end
end
end)

View File

@ -1,10 +1,34 @@
-- Solar Panel
minetest.register_node("mesecons_solarpanel:solar_panel", {
minetest.register_node("mesecons_solarpanel:solar_panel_on", {
drawtype = "nodebox",
tile_images = {
"jeija_solar_panel.png",
"jeija_solar_panel_sides.png"
},
tiles = { "jeija_solar_panel.png", },
inventory_image = "jeija_solar_panel.png",
wield_image = "jeija_solar_panel.png",
paramtype = "light",
paramtype2 = "wallmounted",
walkable = false,
is_ground_content = true,
node_box = {
type = "wallmounted",
wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
},
selection_box = {
type = "wallmounted",
wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
},
drop = "mesecons_solarpanel:solar_panel_off",
groups = {dig_immediate=3, mesecon = 2, not_in_creative_inventory = 1},
description="Solar Panel",
})
-- Solar Panel
minetest.register_node("mesecons_solarpanel:solar_panel_off", {
drawtype = "nodebox",
tiles = { "jeija_solar_panel.png", },
inventory_image = "jeija_solar_panel.png",
wield_image = "jeija_solar_panel.png",
paramtype = "light",
@ -23,16 +47,12 @@ minetest.register_node("mesecons_solarpanel:solar_panel", {
wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
},
furnace_burntime = 5,
groups = {dig_immediate=3, mesecon = 2},
description="Solar Panel",
after_dig_node = function(pos, node, digger)
mesecon:receptor_off(pos)
end,
})
minetest.register_craft({
output = '"mesecons_solarpanel:solar_panel" 1',
output = '"mesecons_solarpanel:solar_panel_off" 1',
recipe = {
{'"mesecons_materials:silicon"', '"mesecons_materials:silicon"'},
{'"mesecons_materials:silicon"', '"mesecons_materials:silicon"'},
@ -40,16 +60,32 @@ minetest.register_craft({
})
minetest.register_abm(
{nodenames = {"mesecons_solarpanel:solar_panel"},
interval = 0.1,
{nodenames = {"mesecons_solarpanel:solar_panel_off"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil)
if light == nil then light = 0 end
if light >= 12 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
mesecon:receptor_on(pos)
else
end
end,
})
minetest.register_abm(
{nodenames = {"mesecons_solarpanel:solar_panel_on"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil)
if light < 12 then
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
mesecon:receptor_off(pos)
end
end,
})
mesecon:add_receptor_node("mesecons_solarpanel:solar_panel_on")
mesecon:add_receptor_node_off("mesecons_solarpanel:solar_panel_off")

View File

@ -1,25 +1,21 @@
-- MESECON_SWITCH
minetest.register_node("mesecons_switch:mesecon_switch_off", {
tile_images = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_off.png"},
tiles = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_off.png"},
paramtype2="facedir",
groups = {dig_immediate=2, mesecon = 2},
description="Switch",
})
minetest.register_node("mesecons_switch:mesecon_switch_on", {
tile_images = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_on.png"},
tiles = {"jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_side.png", "jeija_mesecon_switch_on.png"},
paramtype2="facedir",
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon = 2},
drop='"mesecons_switch:mesecon_switch_off" 1',
description="Switch",
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end
})
mesecon:add_receptor_node("mesecons_switch:mesecon_switch_on")
mesecon:add_receptor_node_off("mesecons_switch:mesecon_switch_off")
mesecon:register_receptor("mesecons_switch:mesecon_switch_on", "mesecons_switch:mesecon_switch_off")
minetest.register_on_punchnode(function(pos, node, puncher)
if node.name == "mesecons_switch:mesecon_switch_on" then

View File

@ -1,244 +0,0 @@
--TEMPEREST-PLUG
local set_node_on
local set_node_off
if ENABLE_TEMPEREST then
set_node_on = function(pos)
local node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_socket_off" then
minetest.env:add_node(pos, {name="mesecons_temperest:mesecon_socket_on"})
nodeupdate(pos)
mesecon:receptor_on(pos)
elseif node.name=="mesecons_temperest:mesecon_inverter_on" then
minetest.env:add_node(pos, {name="mesecons_temperest:mesecon_inverter_off"})
nodeupdate(pos)
mesecon:receptor_off(pos)
end
end
set_node_off = function(pos)
node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_socket_on" then
minetest.env:add_node(pos, {name="mesecons_temperest:mesecon_socket_off"})
nodeupdate(pos)
mesecon:receptor_off(pos)
elseif node.name=="mesecons_temperest:mesecon_inverter_off" then
minetest.env:add_node(pos, {name="mesecons_temperest:mesecon_inverter_on"})
nodeupdate(pos)
mesecon:receptor_on(pos)
end
end
else
set_node_on = function(pos)
local node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_socket_off" then
minetest.env:add_node(pos, {name="mesecons_temperest:mesecon_socket_on"})
nodeupdate(pos)
mesecon:receptor_on(pos)
end
end
set_node_off = function(pos)
node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_socket_on" then
minetest.env:add_node(pos, {name="mesecons_temperest:mesecon_socket_off"})
nodeupdate(pos)
mesecon:receptor_off(pos)
end
end
end
local plug_on = function(pos)
local node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_plug" then
local lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x-2, y=pos.y, z=pos.z}) end
local lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x+2, y=pos.y, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y-2, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y+2, z=pos.z}) end
local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z-2}) end
local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z+2}) end
end
end
local plug_off = function(pos)
local node = minetest.env:get_node(pos)
if node.name=="mesecons_temperest:mesecon_plug" then
lnode = minetest.env:get_node({x=pos.x-1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x-2, y=pos.y, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x+2, y=pos.y, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y-2, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y+2, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z-2}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z+1}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z+2}) end
end
end
mesecon:register_on_signal_on(plug_on)
mesecon:register_on_signal_off(plug_off)
minetest.register_node("mesecons_temperest:mesecon_plug", {
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
tile_images = {"jeija_mesecon_plug.png"},
inventory_image = "jeija_mesecon_plug.png",
wield_image = "jeija_mesecon_plug.png",
groups = {dig_immediate=2, mesecon_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
walkable = false,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
description = "Plug",
after_place_node = plug_off,
after_dig_node = plug_off
})
minetest.register_craft({
output = '"mesecons_temperest:mesecon_plug" 2',
recipe = {
{'', '"group:mesecon_conductor_craftable"', ''},
{'"group:mesecon_conductor_craftable"', '"default:steel_ingot"', '"group:mesecon_conductor_craftable"'},
{'', '"group:mesecon_conductor_craftable"', ''},
}
})
--TEMPEREST-SOCKET
minetest.register_node("mesecons_temperest:mesecon_socket_off", {
description = "Socket",
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
tile_images = {"jeija_mesecon_socket_off.png"},
inventory_image = "jeija_mesecon_socket_off.png",
wield_image = "jeija_mesecon_socket_off.png",
groups = {dig_immediate=2, mesecon_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
walkable = false,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
})
minetest.register_node("mesecons_temperest:mesecon_socket_on", {
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
tile_images = {"jeija_mesecon_socket_on.png"},
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
walkable = false,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
drop='"mesecons_temperest:mesecon_socket_off" 1',
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end
})
mesecon:add_receptor_node("mesecons_temperest:mesecon_socket_on")
mesecon:add_receptor_node_off("mesecons_temperest:mesecon_socket_off")
minetest.register_craft({
output = '"mesecons_temperest:mesecon_socket_off" 2',
recipe = {
{'', '"default:steel_ingot"', ''},
{'"default:steel_ingot"', '"mesecons_temperest:mesecon_off"', '"default:steel_ingot"'},
{'', '"default:steel_ingot"', ''},
}
})
--TEMPEREST-INVERTER
if ENABLE_TEMPEREST then
minetest.register_node("mesecons_temperest:mesecon_inverter_off", {
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
tile_images = {"jeija_mesecon_inverter_off.png"},
groups = {dig_immediate=2,not_in_creative_inventory=1, mesecon_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
walkable = false,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
drop='"mesecons_temperest:mesecon_inverter_on" 1',
})
minetest.register_node("mesecons_temperest:mesecon_inverter_on", {
description = "Inverter",
drawtype = "nodebox",
paramtype = "light",
is_ground_content = true,
tile_images = {"jeija_mesecon_inverter_on.png"},
inventory_image = "jeija_mesecon_inverter_on.png",
wield_image = "jeija_mesecon_inverter_on.png",
groups = {dig_immediate=2, mesecon_effector_on = 1, mesecon_effector_off = 1, mesecon = 2},
walkable = false,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -7/16, 8/16 },
},
after_place_node = function(pos)
mesecon:receptor_on(pos)
end,
after_dig_node = function(pos)
mesecon:receptor_off(pos)
end
})
mesecon:add_receptor_node("mesecons_temperest:mesecon_inverter_on")
mesecon:add_receptor_node_off("mesecons_temperest:mesecon_inverter_off")
minetest.register_craft({
output = '"mesecons_temperest:mesecon_inverter_on" 2',
recipe = {
{'"mesecons_temperest:mesecon_off"', '"default:steel_ingot"', '"group:mesecon_conductor_craftable"'},
{'"default:steel_ingot"', '', '"default:steel_ingot"'},
{'"group:mesecon_conductor_craftable"', '"default:steel_ingot"', '"group:mesecon_conductor_craftable"'},
}
})
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 463 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 686 B

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 517 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 532 B

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 643 B

After

Width:  |  Height:  |  Size: 373 B

Some files were not shown because too many files have changed in this diff Show More