Skip to content
Snippets Groups Projects
Commit 194155ff authored by Jeija's avatar Jeija
Browse files

Rewrite mesecon wires. This should increase the efficiency and speed of

large machines.

It also makes the wires.lua code easier to understand and more
maintainable. In case any other mod depends on
mesecon:update_autoconnect, please update it to use
mesecon.update_autoconnect. This should also fix some other minor bugs.
Please report bugs if this commit creates new ones.

This commit changes wire looks and removes some unneccesary textures.
parent 87bfbb4d
No related branches found
No related tags found
No related merge requests found
Showing
with 8 additions and 19 deletions
......@@ -14,7 +14,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
priority = priority or 1
local action = { pos=mesecon:tablecopy(pos),
func=func,
params=mesecon:tablecopy(params),
params=mesecon:tablecopy(params or {}),
time=time,
owcheck=(overwritecheck and mesecon:tablecopy(overwritecheck)) or nil,
priority=priority}
......
......@@ -26,10 +26,6 @@
-- mesecon:deactivate(pos, node, recdepth) --> Deactivates the effector node at the specific pos (calls nodedef.mesecons.effector.action_off), "
-- mesecon:changesignal(pos, node, rulename, newstate) --> Changes the effector node at the specific pos (calls nodedef.mesecons.effector.action_change), "
-- RULES
-- mesecon:add_rules(name, rules) | deprecated? --> Saves rules table by name
-- mesecon:get_rules(name, rules) | deprecated? --> Loads rules table with name
-- CONDUCTORS
-- mesecon:is_conductor(nodename) --> Returns true if nodename is a conductor
-- mesecon:is_conductor_on(node) --> Returns true if node is a conductor with state = mesecon.state.on
......@@ -244,18 +240,6 @@ function mesecon:changesignal(pos, node, rulename, newstate, recdepth)
mesecon.queue:add_action(pos, "change", {rulename, newstate}, nil, rulename, 1 / recdepth)
end
-- #########
-- # Rules # "Database" for rulenames
-- #########
function mesecon:add_rules(name, rules)
mesecon.rules[name] = rules
end
function mesecon:get_rules(name)
return mesecon.rules[name]
end
-- Conductors
function mesecon:is_conductor_on(node, rulename)
......@@ -548,7 +532,7 @@ function mesecon:rules_link(output, input, dug_outputrules) --output/input are p
return false
end
function mesecon:rules_link_rule_all(output, rule) --output/input are positions (outputrules optional, used if node has been dug), second return value: affected input rules
function mesecon:rules_link_rule_all(output, rule)
local input = mesecon:addPosRule(output, rule)
local inputnode = minetest.get_node(input)
local inputrules = mesecon:get_any_inputrules (inputnode)
......
-- Dig and place services
mesecon.on_placenode = function (pos, node)
mesecon.update_autoconnect(pos, node)
-- Receptors: Send on signal when active
if mesecon:is_receptor_on(node.name) then
mesecon:receptor_on(pos, mesecon:receptor_get_rules(node))
......@@ -18,7 +20,7 @@ mesecon.on_placenode = function (pos, node)
mesecon:turnon(pos, rule)
end
--mesecon:receptor_on (pos, mesecon:conductor_get_rules(node))
elseif mesecon:is_conductor_off(node.name) then
elseif mesecon:is_conductor_on(node) then
minetest.swap_node(pos, {name = mesecon:get_conductor_off(node)})
end
end
......@@ -41,8 +43,11 @@ mesecon.on_dignode = function (pos, node)
elseif mesecon:is_receptor_on(node.name) then
mesecon:receptor_off(pos, mesecon:receptor_get_rules(node))
end
mesecon.queue:add_action(pos, "update_autoconnect", {node})
end
mesecon.queue:add_function("update_autoconnect", mesecon.update_autoconnect)
minetest.register_on_placenode(mesecon.on_placenode)
minetest.register_on_dignode(mesecon.on_dignode)
......
mesecons/textures/jeija_mesecon_crossing_off.png

341 B

mesecons/textures/jeija_mesecon_crossing_on.png

340 B

mesecons/textures/jeija_mesecon_curved_off.png

307 B

mesecons/textures/jeija_mesecon_curved_on.png

307 B

mesecons/textures/jeija_mesecon_inverter_off.png

743 B

mesecons/textures/jeija_mesecon_inverter_on.png

725 B

mesecons/textures/jeija_mesecon_on.png

196 B

mesecons/textures/jeija_mesecon_plug.png

713 B

mesecons/textures/jeija_mesecon_socket_off.png

751 B

mesecons/textures/jeija_mesecon_socket_on.png

737 B

mesecons/textures/jeija_mesecon_t_junction_off.png

330 B

mesecons/textures/jeija_mesecon_t_junction_on.png

319 B

mesecons/textures/wires_bump_off.png

347 B

mesecons/textures/wires_bump_on.png

386 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment