Skip to content

Commit

Permalink
Rewrite mesecon wires. This should increase the efficiency and speed of
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jeija committed Nov 22, 2014
1 parent 87bfbb4 commit 194155f
Show file tree
Hide file tree
Showing 33 changed files with 276 additions and 309 deletions.
2 changes: 1 addition & 1 deletion mesecons/actionqueue.lua
Expand Up @@ -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}
Expand Down
18 changes: 1 addition & 17 deletions mesecons/internal.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion mesecons/services.lua
@@ -1,6 +1,8 @@
-- 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))
Expand All @@ -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
Expand All @@ -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)

Expand Down
Binary file removed mesecons/textures/jeija_mesecon_crossing_off.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_crossing_on.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_curved_off.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_curved_on.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_inverter_off.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_inverter_on.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_on.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_plug.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_socket_off.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_socket_on.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_t_junction_off.png
Binary file not shown.
Binary file removed mesecons/textures/jeija_mesecon_t_junction_on.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed mesecons/textures/wires_bump_off.png
Binary file not shown.
Binary file removed mesecons/textures/wires_bump_on.png
Binary file not shown.
Binary file removed mesecons/textures/wires_inv.png
Binary file not shown.
Binary file removed mesecons/textures/wires_off.png
Binary file not shown.
Binary file removed mesecons/textures/wires_on.png
Binary file not shown.
Binary file removed mesecons/textures/wires_vertical_off.png
Binary file not shown.
Binary file removed mesecons/textures/wires_vertical_on.png
Binary file not shown.
17 changes: 17 additions & 0 deletions mesecons/util.lua
Expand Up @@ -193,3 +193,20 @@ function mesecon:cmpAny(t1, t2)
return true
end
-- does not overwrite values
mesecon.mergetable = function(source, dest)
for k, v in pairs(source) do
dest[k] = dest[k] or v
end
end
mesecon.register_node = function(name, spec_common, spec_off, spec_on)
spec_common.drop = spec_common.drop or name .. "_off"
mesecon.mergetable(spec_common, spec_on);
mesecon.mergetable(spec_common, spec_off);
minetest.register_node(name .. "_on", spec_on)
minetest.register_node(name .. "_off", spec_off)
end

0 comments on commit 194155f

Please sign in to comment.