forked from minetest-mods/mesecons
Compare commits
23 Commits
583d2c1441
...
v2022-04-0
Author | SHA1 | Date | |
---|---|---|---|
21ac966ee2 | |||
b630ff9443 | |||
399ee9f5b5 | |||
0d9e0274ae | |||
fef5c8cf68 | |||
f6b0de64b8 | |||
1d30891349 | |||
4dfadd9276 | |||
3c27bb9350 | |||
fb255d292e | |||
c9dd323207 | |||
4c5b13a347 | |||
4eea0834b5 | |||
ecea0a2896 | |||
9323445182 | |||
e15c55c066 | |||
db5879706d | |||
65793514fe | |||
f5c3f798be | |||
69d4a9584d | |||
3f75c06a3b | |||
93aa24dc42 | |||
93f155f604 |
15
.github/workflows/check-release.yml
vendored
Normal file
15
.github/workflows/check-release.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
on: [push, pull_request]
|
||||||
|
name: Check & Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@main
|
||||||
|
- name: apt
|
||||||
|
run: sudo apt-get install -y luarocks
|
||||||
|
- name: luacheck install
|
||||||
|
run: luarocks install --local luacheck
|
||||||
|
- name: luacheck run
|
||||||
|
run: $HOME/.luarocks/bin/luacheck ./
|
36
.luacheckrc
Normal file
36
.luacheckrc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
std = "lua51c"
|
||||||
|
|
||||||
|
ignore = {
|
||||||
|
"21/_+", -- Unused variable, except "_", "__", etc.
|
||||||
|
"213", -- Unused loop variable
|
||||||
|
"421", -- Shadowing a local variable
|
||||||
|
"422", -- Shadowing an argument
|
||||||
|
"423", -- Shadowing a loop variable
|
||||||
|
"431", -- Shadowing an upvalue
|
||||||
|
"432", -- Shadowing an upvalue argument
|
||||||
|
"433", -- Shadowing an upvalue loop variable
|
||||||
|
"542", -- Empty if branch
|
||||||
|
}
|
||||||
|
|
||||||
|
max_line_length = 200
|
||||||
|
|
||||||
|
read_globals = {
|
||||||
|
"default",
|
||||||
|
"digiline",
|
||||||
|
"doors",
|
||||||
|
"dump",
|
||||||
|
"jit",
|
||||||
|
"minetest",
|
||||||
|
"screwdriver",
|
||||||
|
"string.split",
|
||||||
|
"table.copy",
|
||||||
|
"table.insert_all",
|
||||||
|
"vector",
|
||||||
|
"VoxelArea",
|
||||||
|
}
|
||||||
|
|
||||||
|
globals = {"mesecon"}
|
||||||
|
|
||||||
|
files["mesecons/actionqueue.lua"] = {
|
||||||
|
globals = {"minetest.registered_globalsteps"},
|
||||||
|
}
|
10
README.md
10
README.md
@ -12,9 +12,9 @@ MESECONS by Jeija and contributors
|
|||||||
|
|
||||||
Mezzee-what?
|
Mezzee-what?
|
||||||
------------
|
------------
|
||||||
[Mesecons](http://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
|
[Mesecons](https://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
|
||||||
|
|
||||||
Mesecons is a mod for [Minetest](http://minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
|
Mesecons is a mod for [Minetest](https://www.minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
|
||||||
|
|
||||||
Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
|
Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
|
||||||
|
|
||||||
@ -74,8 +74,10 @@ There are also a whole bunch of other people helping with everything from code t
|
|||||||
|
|
||||||
Alright, how can I use it?
|
Alright, how can I use it?
|
||||||
--------------------------
|
--------------------------
|
||||||
All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
|
All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic).
|
||||||
|
That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
|
||||||
|
|
||||||
All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
|
All code in this project is licensed under the LGPL version 3.
|
||||||
|
That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
|
||||||
|
|
||||||
No warranty is provided, express or implied, for any part of the project.
|
No warranty is provided, express or implied, for any part of the project.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "mesecons",
|
"name": "mesecons",
|
||||||
"description": "Mesecons is a mod for Minetest that implements items related to digital circuitry: wires, buttons, lights, and programmable controllers.",
|
"description": "Mesecons is a mod for Minetest that implements items related to digital circuitry: wires, buttons, lights, and programmable controllers.",
|
||||||
"homepage": "http://mesecons.net",
|
"homepage": "https://mesecons.net",
|
||||||
"authors": "Jeija",
|
"authors": ["Jeija"],
|
||||||
"license": "LGPL-3.0+",
|
"license": "LGPL-3.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"mesecons",
|
"mesecons",
|
||||||
"minetest",
|
"minetest",
|
||||||
|
@ -29,7 +29,7 @@ local queue = mesecon.queue
|
|||||||
queue.actions = {} -- contains all ActionQueue actions
|
queue.actions = {} -- contains all ActionQueue actions
|
||||||
|
|
||||||
function queue:add_function(name, func)
|
function queue:add_function(name, func)
|
||||||
queue.funcs[name] = func
|
self.funcs[name] = func
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If add_action with twice the same overwritecheck and same position are called, the first one is overwritten
|
-- If add_action with twice the same overwritecheck and same position are called, the first one is overwritten
|
||||||
@ -51,17 +51,17 @@ function queue:add_action(pos, func, params, time, overwritecheck, priority)
|
|||||||
|
|
||||||
-- check if old action has to be overwritten / removed:
|
-- check if old action has to be overwritten / removed:
|
||||||
if overwritecheck then
|
if overwritecheck then
|
||||||
for i, ac in ipairs(queue.actions) do
|
for i, ac in ipairs(self.actions) do
|
||||||
if vector.equals(pos, ac.pos)
|
if vector.equals(pos, ac.pos)
|
||||||
and mesecon.cmpAny(overwritecheck, ac.owcheck) then
|
and mesecon.cmpAny(overwritecheck, ac.owcheck) then
|
||||||
-- remove the old action
|
-- remove the old action
|
||||||
table.remove(queue.actions, i)
|
table.remove(self.actions, i)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(queue.actions, action)
|
table.insert(self.actions, action)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- execute the stored functions on a globalstep
|
-- execute the stored functions on a globalstep
|
||||||
@ -133,8 +133,8 @@ end
|
|||||||
function queue:execute(action)
|
function queue:execute(action)
|
||||||
-- ignore if action queue function name doesn't exist,
|
-- ignore if action queue function name doesn't exist,
|
||||||
-- (e.g. in case the action queue savegame was written by an old mesecons version)
|
-- (e.g. in case the action queue savegame was written by an old mesecons version)
|
||||||
if queue.funcs[action.func] then
|
if self.funcs[action.func] then
|
||||||
queue.funcs[action.func](action.pos, unpack(action.params))
|
self.funcs[action.func](action.pos, unpack(action.params))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
62
mesecons/fifo_queue.lua
Normal file
62
mesecons/fifo_queue.lua
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
-- a simple first-in-first-out queue
|
||||||
|
-- very similar to the one in https://github.com/minetest/minetest/pull/7683
|
||||||
|
|
||||||
|
local fifo_queue = {}
|
||||||
|
|
||||||
|
local metatable = {__index = fifo_queue}
|
||||||
|
|
||||||
|
-- creates a new empty queue
|
||||||
|
function fifo_queue.new()
|
||||||
|
local q = {n_in = 0, n_out = 0, i_out = 1, buf_in = {}, buf_out = {}}
|
||||||
|
setmetatable(q, metatable)
|
||||||
|
return q
|
||||||
|
end
|
||||||
|
|
||||||
|
-- adds an element to the queue
|
||||||
|
function fifo_queue.add(self, v)
|
||||||
|
local n = self.n_in + 1
|
||||||
|
self.n_in = n
|
||||||
|
self.buf_in[n] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
-- removes and returns the next element, or nil of empty
|
||||||
|
function fifo_queue.take(self)
|
||||||
|
local i_out = self.i_out
|
||||||
|
if i_out <= self.n_out then
|
||||||
|
local v = self.buf_out[i_out]
|
||||||
|
self.i_out = i_out + 1
|
||||||
|
self.buf_out[i_out] = true
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
-- buf_out is empty, try to swap
|
||||||
|
self.i_out = 1
|
||||||
|
self.n_out = 0
|
||||||
|
if self.n_in == 0 then
|
||||||
|
return nil -- empty
|
||||||
|
end
|
||||||
|
|
||||||
|
-- swap
|
||||||
|
self.n_out = self.n_in
|
||||||
|
self.n_in = 0
|
||||||
|
self.buf_out, self.buf_in = self.buf_in, self.buf_out
|
||||||
|
|
||||||
|
local v = self.buf_out[1]
|
||||||
|
self.i_out = 2
|
||||||
|
self.buf_out[1] = true
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
|
||||||
|
-- returns whether the queue is empty
|
||||||
|
function fifo_queue.is_empty(self)
|
||||||
|
return self.n_out == self.i_out + 1 and self.n_in == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- returns stuff for iteration in a for loop, like pairs
|
||||||
|
-- adding new elements while iterating is no problem
|
||||||
|
function fifo_queue.iter(self)
|
||||||
|
return fifo_queue.take, self, nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return fifo_queue
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
-- RECEPTORS
|
-- RECEPTORS
|
||||||
-- mesecon.is_receptor(nodename) --> Returns true if nodename is a receptor
|
-- mesecon.is_receptor(nodename) --> Returns true if nodename is a receptor
|
||||||
-- mesecon.is_receptor_on(nodename --> Returns true if nodename is an receptor with state = mesecon.state.on
|
-- mesecon.is_receptor_on(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.on
|
||||||
-- mesecon.is_receptor_off(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.off
|
-- mesecon.is_receptor_off(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.off
|
||||||
-- mesecon.receptor_get_rules(node) --> Returns the rules of the receptor (mesecon.rules.default if none specified)
|
-- mesecon.receptor_get_rules(node) --> Returns the rules of the receptor (mesecon.rules.default if none specified)
|
||||||
|
|
||||||
@ -46,6 +46,8 @@
|
|||||||
-- mesecon.rotate_rules_down(rules)
|
-- mesecon.rotate_rules_down(rules)
|
||||||
-- These functions return rules that have been rotated in the specific direction
|
-- These functions return rules that have been rotated in the specific direction
|
||||||
|
|
||||||
|
local fifo_queue = dofile(minetest.get_modpath("mesecons").."/fifo_queue.lua")
|
||||||
|
|
||||||
-- General
|
-- General
|
||||||
function mesecon.get_effector(nodename)
|
function mesecon.get_effector(nodename)
|
||||||
if minetest.registered_nodes[nodename]
|
if minetest.registered_nodes[nodename]
|
||||||
@ -316,7 +318,7 @@ function mesecon.get_conductor_on(node_off, rulename)
|
|||||||
return conductor.states[tonumber(binstate,2)+1]
|
return conductor.states[tonumber(binstate,2)+1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return offstate
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.get_conductor_off(node_on, rulename)
|
function mesecon.get_conductor_off(node_on, rulename)
|
||||||
@ -332,7 +334,7 @@ function mesecon.get_conductor_off(node_on, rulename)
|
|||||||
return conductor.states[tonumber(binstate,2)+1]
|
return conductor.states[tonumber(binstate,2)+1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return onstate
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.conductor_get_rules(node)
|
function mesecon.conductor_get_rules(node)
|
||||||
@ -366,37 +368,98 @@ function mesecon.is_power_off(pos, rulename)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- The set of conductor states which require light updates when they change.
|
||||||
|
local light_update_conductors
|
||||||
|
|
||||||
|
-- Calculate the contents of the above set if they have not been calculated.
|
||||||
|
local function find_light_update_conductors()
|
||||||
|
-- The expensive calculation is only done the first time.
|
||||||
|
if light_update_conductors then return end
|
||||||
|
|
||||||
|
light_update_conductors = {}
|
||||||
|
|
||||||
|
-- Find conductors whose lighting characteristics change depending on their state.
|
||||||
|
local checked = {}
|
||||||
|
for name, def in pairs(minetest.registered_nodes) do
|
||||||
|
local conductor = mesecon.get_conductor(name)
|
||||||
|
if conductor and not checked[name] then
|
||||||
|
-- Find the other states of the conductor besides the current one.
|
||||||
|
local other_states
|
||||||
|
if conductor.onstate then
|
||||||
|
other_states = {conductor.onstate}
|
||||||
|
elseif conductor.offstate then
|
||||||
|
other_states = {conductor.offstate}
|
||||||
|
else
|
||||||
|
other_states = conductor.states
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check the conductor. Other states are marked as checked.
|
||||||
|
for _, other_state in ipairs(other_states) do
|
||||||
|
local other_def = minetest.registered_nodes[other_state]
|
||||||
|
if (def.paramtype == "light") ~= (other_def.paramtype == "light")
|
||||||
|
or def.sunlight_propagates ~= other_def.sunlight_propagates
|
||||||
|
or def.light_source ~= other_def.light_source then
|
||||||
|
-- The light characteristics change depending on the state.
|
||||||
|
-- The states are added to the set.
|
||||||
|
light_update_conductors[name] = true
|
||||||
|
for _, other_state in ipairs(other_states) do
|
||||||
|
light_update_conductors[other_state] = true
|
||||||
|
checked[other_state] = true
|
||||||
|
end
|
||||||
|
break
|
||||||
|
end
|
||||||
|
checked[other_state] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Turn off an equipotential section starting at `pos`, which outputs in the direction of `link`.
|
-- Turn off an equipotential section starting at `pos`, which outputs in the direction of `link`.
|
||||||
-- Breadth-first search. Map is abstracted away in a voxelmanip.
|
-- Breadth-first search. Map is abstracted away in a voxelmanip.
|
||||||
-- Follow all all conductor paths replacing conductors that were already
|
-- Follow all all conductor paths replacing conductors that were already
|
||||||
-- looked at, activating / changing all effectors along the way.
|
-- looked at, activating / changing all effectors along the way.
|
||||||
function mesecon.turnon(pos, link)
|
function mesecon.turnon(pos, link)
|
||||||
local frontiers = {{pos = pos, link = link}}
|
find_light_update_conductors()
|
||||||
|
|
||||||
|
local frontiers = fifo_queue.new()
|
||||||
|
frontiers:add({pos = pos, link = link})
|
||||||
|
local pos_can_be_skipped = {}
|
||||||
|
|
||||||
local depth = 1
|
local depth = 1
|
||||||
while frontiers[1] do
|
for f in frontiers:iter() do
|
||||||
local f = table.remove(frontiers, 1)
|
|
||||||
local node = mesecon.get_node_force(f.pos)
|
local node = mesecon.get_node_force(f.pos)
|
||||||
|
|
||||||
if not node then
|
if not node then
|
||||||
-- Area does not exist; do nothing
|
-- Area does not exist; do nothing
|
||||||
elseif mesecon.is_conductor_off(node, f.link) then
|
pos_can_be_skipped[minetest.hash_node_position(f.pos)] = true
|
||||||
|
elseif mesecon.is_conductor(node.name) then
|
||||||
local rules = mesecon.conductor_get_rules(node)
|
local rules = mesecon.conductor_get_rules(node)
|
||||||
|
|
||||||
|
if mesecon.is_conductor_off(node, f.link) then
|
||||||
-- Call turnon on neighbors
|
-- Call turnon on neighbors
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
|
if not pos_can_be_skipped[minetest.hash_node_position(np)] then
|
||||||
for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
||||||
table.insert(frontiers, {pos = np, link = l})
|
frontiers:add({pos = np, link = l})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link))
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link), light_update_conductors[node.name] ~= nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Only conductors with flat rules can be reliably skipped later
|
||||||
|
if not rules[1] or rules[1].x then
|
||||||
|
pos_can_be_skipped[minetest.hash_node_position(f.pos)] = true
|
||||||
|
end
|
||||||
elseif mesecon.is_effector(node.name) then
|
elseif mesecon.is_effector(node.name) then
|
||||||
mesecon.changesignal(f.pos, node, f.link, mesecon.state.on, depth)
|
mesecon.changesignal(f.pos, node, f.link, mesecon.state.on, depth)
|
||||||
if mesecon.is_effector_off(node.name) then
|
if mesecon.is_effector_off(node.name) then
|
||||||
mesecon.activate(f.pos, node, f.link, depth)
|
mesecon.activate(f.pos, node, f.link, depth)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
pos_can_be_skipped[minetest.hash_node_position(f.pos)] = true
|
||||||
end
|
end
|
||||||
depth = depth + 1
|
depth = depth + 1
|
||||||
end
|
end
|
||||||
@ -419,25 +482,32 @@ end
|
|||||||
-- depth = indicates order in which signals wire fired, higher is later
|
-- depth = indicates order in which signals wire fired, higher is later
|
||||||
-- }
|
-- }
|
||||||
function mesecon.turnoff(pos, link)
|
function mesecon.turnoff(pos, link)
|
||||||
local frontiers = {{pos = pos, link = link}}
|
find_light_update_conductors()
|
||||||
|
|
||||||
|
local frontiers = fifo_queue.new()
|
||||||
|
frontiers:add({pos = pos, link = link})
|
||||||
local signals = {}
|
local signals = {}
|
||||||
|
local pos_can_be_skipped = {}
|
||||||
|
|
||||||
local depth = 1
|
local depth = 1
|
||||||
while frontiers[1] do
|
for f in frontiers:iter() do
|
||||||
local f = table.remove(frontiers, 1)
|
|
||||||
local node = mesecon.get_node_force(f.pos)
|
local node = mesecon.get_node_force(f.pos)
|
||||||
|
|
||||||
if not node then
|
if not node then
|
||||||
-- Area does not exist; do nothing
|
-- Area does not exist; do nothing
|
||||||
elseif mesecon.is_conductor_on(node, f.link) then
|
pos_can_be_skipped[minetest.hash_node_position(f.pos)] = true
|
||||||
|
elseif mesecon.is_conductor(node.name) then
|
||||||
local rules = mesecon.conductor_get_rules(node)
|
local rules = mesecon.conductor_get_rules(node)
|
||||||
|
|
||||||
|
if mesecon.is_conductor_on(node, f.link) then
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = vector.add(f.pos, r)
|
||||||
|
|
||||||
|
if not pos_can_be_skipped[minetest.hash_node_position(np)] then
|
||||||
-- Check if an onstate receptor is connected. If that is the case,
|
-- Check if an onstate receptor is connected. If that is the case,
|
||||||
-- abort this turnoff process by returning false. `receptor_off` will
|
-- abort this turnoff process by returning false. `receptor_off` will
|
||||||
-- discard all the changes that we made in the voxelmanip:
|
-- discard all the changes that we made in the voxelmanip:
|
||||||
for _, l in ipairs(mesecon.rules_link_rule_all_inverted(f.pos, r)) do
|
if mesecon.rules_link_rule_all_inverted(f.pos, r)[1] then
|
||||||
if mesecon.is_receptor_on(mesecon.get_node_force(np).name) then
|
if mesecon.is_receptor_on(mesecon.get_node_force(np).name) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -445,11 +515,18 @@ function mesecon.turnoff(pos, link)
|
|||||||
|
|
||||||
-- Call turnoff on neighbors
|
-- Call turnoff on neighbors
|
||||||
for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
||||||
table.insert(frontiers, {pos = np, link = l})
|
frontiers:add({pos = np, link = l})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link), light_update_conductors[node.name] ~= nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Only conductors with flat rules can be reliably skipped later
|
||||||
|
if not rules[1] or rules[1].x then
|
||||||
|
pos_can_be_skipped[minetest.hash_node_position(f.pos)] = true
|
||||||
|
end
|
||||||
elseif mesecon.is_effector(node.name) then
|
elseif mesecon.is_effector(node.name) then
|
||||||
table.insert(signals, {
|
table.insert(signals, {
|
||||||
pos = f.pos,
|
pos = f.pos,
|
||||||
@ -457,6 +534,8 @@ function mesecon.turnoff(pos, link)
|
|||||||
link = f.link,
|
link = f.link,
|
||||||
depth = depth
|
depth = depth
|
||||||
})
|
})
|
||||||
|
else
|
||||||
|
pos_can_be_skipped[minetest.hash_node_position(f.pos)] = true
|
||||||
end
|
end
|
||||||
depth = depth + 1
|
depth = depth + 1
|
||||||
end
|
end
|
||||||
|
@ -11,4 +11,4 @@ local old_forceloaded_blocks = mesecon.file2table("mesecon_forceloaded")
|
|||||||
for hash, _ in pairs(old_forceloaded_blocks) do
|
for hash, _ in pairs(old_forceloaded_blocks) do
|
||||||
minetest.forceload_free_block(unhash_blockpos(hash))
|
minetest.forceload_free_block(unhash_blockpos(hash))
|
||||||
end
|
end
|
||||||
os.remove(minetest.get_worldpath()..DIR_DELIM.."mesecon_forceloaded")
|
os.remove(minetest.get_worldpath().."/mesecon_forceloaded")
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
name = mesecons
|
name = mesecons
|
||||||
depends = default
|
# default is an optional dependency as some mods may expect it as a transitory
|
||||||
|
# dependency when they depend on mesecons.
|
||||||
|
optional_depends = default
|
||||||
|
@ -16,7 +16,7 @@ mesecon.on_placenode = function(pos, node)
|
|||||||
-- also call receptor_on if itself is powered already, so that neighboring
|
-- also call receptor_on if itself is powered already, so that neighboring
|
||||||
-- conductors will be activated (when pushing an on-conductor with a piston)
|
-- conductors will be activated (when pushing an on-conductor with a piston)
|
||||||
for _, s in ipairs(sources) do
|
for _, s in ipairs(sources) do
|
||||||
local rule = vector.subtract(pos, s)
|
local rule = vector.subtract(s, pos)
|
||||||
mesecon.turnon(pos, rule)
|
mesecon.turnon(pos, rule)
|
||||||
end
|
end
|
||||||
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
||||||
@ -63,7 +63,7 @@ mesecon.on_dignode = function(pos, node)
|
|||||||
mesecon.execute_autoconnect_hooks_queue(pos, node)
|
mesecon.execute_autoconnect_hooks_queue(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.on_blastnode(pos, intensity)
|
function mesecon.on_blastnode(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
mesecon.on_dignode(pos, node)
|
mesecon.on_dignode(pos, node)
|
||||||
|
@ -164,7 +164,9 @@ end
|
|||||||
|
|
||||||
function mesecon.get_bit(binary,bit)
|
function mesecon.get_bit(binary,bit)
|
||||||
bit = bit or 1
|
bit = bit or 1
|
||||||
local c = binary:len()-(bit-1)
|
local len = binary:len()
|
||||||
|
if bit > len then return false end
|
||||||
|
local c = len-(bit-1)
|
||||||
return binary:sub(c,c) == "1"
|
return binary:sub(c,c) == "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -284,7 +286,7 @@ end
|
|||||||
-- File writing / reading utilities
|
-- File writing / reading utilities
|
||||||
local wpath = minetest.get_worldpath()
|
local wpath = minetest.get_worldpath()
|
||||||
function mesecon.file2table(filename)
|
function mesecon.file2table(filename)
|
||||||
local f = io.open(wpath..DIR_DELIM..filename, "r")
|
local f = io.open(wpath.."/"..filename, "r")
|
||||||
if f == nil then return {} end
|
if f == nil then return {} end
|
||||||
local t = f:read("*all")
|
local t = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
@ -293,7 +295,7 @@ function mesecon.file2table(filename)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.table2file(filename, table)
|
function mesecon.table2file(filename, table)
|
||||||
local f = io.open(wpath..DIR_DELIM..filename, "w")
|
local f = io.open(wpath.."/"..filename, "w")
|
||||||
f:write(minetest.serialize(table))
|
f:write(minetest.serialize(table))
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
@ -315,15 +317,17 @@ end
|
|||||||
--
|
--
|
||||||
-- Contents of the table are:
|
-- Contents of the table are:
|
||||||
-- “vm” → the VoxelManipulator
|
-- “vm” → the VoxelManipulator
|
||||||
-- “va” → the VoxelArea
|
|
||||||
-- “data” → the data array
|
|
||||||
-- “param1” → the param1 array
|
|
||||||
-- “param2” → the param2 array
|
|
||||||
-- “dirty” → true if data has been modified
|
-- “dirty” → true if data has been modified
|
||||||
--
|
--
|
||||||
-- Nil if no VM-based transaction is in progress.
|
-- Nil if no VM-based transaction is in progress.
|
||||||
local vm_cache = nil
|
local vm_cache = nil
|
||||||
|
|
||||||
|
-- Cache from node position hashes to nodes (represented as tables).
|
||||||
|
local vm_node_cache = nil
|
||||||
|
|
||||||
|
-- Whether the current transaction will need a light update afterward.
|
||||||
|
local vm_update_light = false
|
||||||
|
|
||||||
-- Starts a VoxelManipulator-based transaction.
|
-- Starts a VoxelManipulator-based transaction.
|
||||||
--
|
--
|
||||||
-- During a VM transaction, calls to vm_get_node and vm_swap_node operate on a
|
-- During a VM transaction, calls to vm_get_node and vm_swap_node operate on a
|
||||||
@ -332,6 +336,8 @@ local vm_cache = nil
|
|||||||
-- vm_abort.
|
-- vm_abort.
|
||||||
function mesecon.vm_begin()
|
function mesecon.vm_begin()
|
||||||
vm_cache = {}
|
vm_cache = {}
|
||||||
|
vm_node_cache = {}
|
||||||
|
vm_update_light = false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Finishes a VoxelManipulator-based transaction, freeing the VMs and map data
|
-- Finishes a VoxelManipulator-based transaction, freeing the VMs and map data
|
||||||
@ -340,18 +346,19 @@ function mesecon.vm_commit()
|
|||||||
for hash, tbl in pairs(vm_cache) do
|
for hash, tbl in pairs(vm_cache) do
|
||||||
if tbl.dirty then
|
if tbl.dirty then
|
||||||
local vm = tbl.vm
|
local vm = tbl.vm
|
||||||
vm:set_data(tbl.data)
|
vm:write_to_map(vm_update_light)
|
||||||
vm:write_to_map()
|
|
||||||
vm:update_map()
|
vm:update_map()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vm_cache = nil
|
vm_cache = nil
|
||||||
|
vm_node_cache = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Finishes a VoxelManipulator-based transaction, freeing the VMs and throwing
|
-- Finishes a VoxelManipulator-based transaction, freeing the VMs and throwing
|
||||||
-- away any modified areas.
|
-- away any modified areas.
|
||||||
function mesecon.vm_abort()
|
function mesecon.vm_abort()
|
||||||
vm_cache = nil
|
vm_cache = nil
|
||||||
|
vm_node_cache = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Gets the cache entry covering a position, populating it if necessary.
|
-- Gets the cache entry covering a position, populating it if necessary.
|
||||||
@ -359,10 +366,7 @@ local function vm_get_or_create_entry(pos)
|
|||||||
local hash = hash_blockpos(pos)
|
local hash = hash_blockpos(pos)
|
||||||
local tbl = vm_cache[hash]
|
local tbl = vm_cache[hash]
|
||||||
if not tbl then
|
if not tbl then
|
||||||
local vm = minetest.get_voxel_manip(pos, pos)
|
tbl = {vm = minetest.get_voxel_manip(pos, pos), dirty = false}
|
||||||
local min_pos, max_pos = vm:get_emerged_area()
|
|
||||||
local va = VoxelArea:new{MinEdge = min_pos, MaxEdge = max_pos}
|
|
||||||
tbl = {vm = vm, va = va, data = vm:get_data(), param1 = vm:get_light_data(), param2 = vm:get_param2_data(), dirty = false}
|
|
||||||
vm_cache[hash] = tbl
|
vm_cache[hash] = tbl
|
||||||
end
|
end
|
||||||
return tbl
|
return tbl
|
||||||
@ -371,25 +375,34 @@ end
|
|||||||
-- Gets the node at a given position during a VoxelManipulator-based
|
-- Gets the node at a given position during a VoxelManipulator-based
|
||||||
-- transaction.
|
-- transaction.
|
||||||
function mesecon.vm_get_node(pos)
|
function mesecon.vm_get_node(pos)
|
||||||
local tbl = vm_get_or_create_entry(pos)
|
local hash = minetest.hash_node_position(pos)
|
||||||
local index = tbl.va:indexp(pos)
|
local node = vm_node_cache[hash]
|
||||||
local node_value = tbl.data[index]
|
if not node then
|
||||||
if node_value == core.CONTENT_IGNORE then
|
node = vm_get_or_create_entry(pos).vm:get_node_at(pos)
|
||||||
return nil
|
vm_node_cache[hash] = node
|
||||||
else
|
|
||||||
local node_param1 = tbl.param1[index]
|
|
||||||
local node_param2 = tbl.param2[index]
|
|
||||||
return {name = minetest.get_name_from_content_id(node_value), param1 = node_param1, param2 = node_param2}
|
|
||||||
end
|
end
|
||||||
|
return node.name ~= "ignore" and {name = node.name, param1 = node.param1, param2 = node.param2} or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sets a node’s name during a VoxelManipulator-based transaction.
|
-- Sets a node’s name during a VoxelManipulator-based transaction.
|
||||||
--
|
--
|
||||||
-- Existing param1, param2, and metadata are left alone.
|
-- Existing param1, param2, and metadata are left alone.
|
||||||
function mesecon.vm_swap_node(pos, name)
|
--
|
||||||
|
-- The swap will necessitate a light update unless update_light equals false.
|
||||||
|
function mesecon.vm_swap_node(pos, name, update_light)
|
||||||
|
-- If one node needs a light update, all VMs should use light updates to
|
||||||
|
-- prevent newly calculated light from being overwritten by other VMs.
|
||||||
|
vm_update_light = vm_update_light or update_light ~= false
|
||||||
|
|
||||||
local tbl = vm_get_or_create_entry(pos)
|
local tbl = vm_get_or_create_entry(pos)
|
||||||
local index = tbl.va:indexp(pos)
|
local hash = minetest.hash_node_position(pos)
|
||||||
tbl.data[index] = minetest.get_content_id(name)
|
local node = vm_node_cache[hash]
|
||||||
|
if not node then
|
||||||
|
node = tbl.vm:get_node_at(pos)
|
||||||
|
vm_node_cache[hash] = node
|
||||||
|
end
|
||||||
|
node.name = name
|
||||||
|
tbl.vm:set_node_at(pos, node)
|
||||||
tbl.dirty = true
|
tbl.dirty = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -425,9 +438,11 @@ end
|
|||||||
--
|
--
|
||||||
-- This function can only be used to change the node’s name, not its parameters
|
-- This function can only be used to change the node’s name, not its parameters
|
||||||
-- or metadata.
|
-- or metadata.
|
||||||
function mesecon.swap_node_force(pos, name)
|
--
|
||||||
|
-- The swap will necessitate a light update unless update_light equals false.
|
||||||
|
function mesecon.swap_node_force(pos, name, update_light)
|
||||||
if vm_cache then
|
if vm_cache then
|
||||||
return mesecon.vm_swap_node(pos, name)
|
return mesecon.vm_swap_node(pos, name, update_light)
|
||||||
else
|
else
|
||||||
-- This serves to both ensure the mapblock is loaded and also hand us
|
-- This serves to both ensure the mapblock is loaded and also hand us
|
||||||
-- the old node table so we can preserve param2.
|
-- the old node table so we can preserve param2.
|
||||||
|
@ -32,7 +32,7 @@ mesecon.register_node("mesecons_blinkyplant:blinky_plant", {
|
|||||||
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
|
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
|
||||||
},
|
},
|
||||||
on_timer = on_timer,
|
on_timer = on_timer,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, _, clicker)
|
||||||
if minetest.is_protected(pos, clicker and clicker:get_player_name() or "") then
|
if minetest.is_protected(pos, clicker and clicker:get_player_name() or "") then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_blinkyplant
|
name = mesecons_blinkyplant
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -13,6 +13,8 @@ mesecon.button_turnoff = function (pos)
|
|||||||
mesecon.receptor_off(pos, rules)
|
mesecon.receptor_off(pos, rules)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or nil
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_off", {
|
minetest.register_node("mesecons_button:button_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -23,6 +25,7 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
"jeija_wall_button_sides.png",
|
"jeija_wall_button_sides.png",
|
||||||
"jeija_wall_button_off.png"
|
"jeija_wall_button_off.png"
|
||||||
},
|
},
|
||||||
|
use_texture_alpha = use_texture_alpha,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
@ -67,6 +70,7 @@ minetest.register_node("mesecons_button:button_on", {
|
|||||||
"jeija_wall_button_sides.png",
|
"jeija_wall_button_sides.png",
|
||||||
"jeija_wall_button_on.png"
|
"jeija_wall_button_on.png"
|
||||||
},
|
},
|
||||||
|
use_texture_alpha = use_texture_alpha,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_button
|
name = mesecons_button
|
||||||
depends = mesecons, mesecons_receiver
|
depends = default, mesecons, mesecons_receiver
|
||||||
|
@ -10,6 +10,7 @@ minetest.register_chatcommand("say", {
|
|||||||
minetest.register_chatcommand("tell", {
|
minetest.register_chatcommand("tell", {
|
||||||
params = "<name> <text>",
|
params = "<name> <text>",
|
||||||
description = "Say <text> to <name> privately",
|
description = "Say <text> to <name> privately",
|
||||||
|
privs = {shout=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local found, _, target, message = param:find("^([^%s]+)%s+(.*)$")
|
local found, _, target, message = param:find("^([^%s]+)%s+(.*)$")
|
||||||
if found == nil then
|
if found == nil then
|
||||||
@ -78,7 +79,7 @@ local function after_place(pos, placer)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function receive_fields(pos, formname, fields, sender)
|
local function receive_fields(pos, _, fields, sender)
|
||||||
if not fields.submit then
|
if not fields.submit then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_commandblock
|
name = mesecons_commandblock
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -54,6 +54,7 @@ local boxes = {
|
|||||||
-- Delayer definition defaults
|
-- Delayer definition defaults
|
||||||
local def = {
|
local def = {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or nil,
|
||||||
walkable = true,
|
walkable = true,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_delayer
|
name = mesecons_delayer
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -12,7 +12,7 @@ local function object_detector_make_formspec(pos)
|
|||||||
"button_exit[7,0.75;2,3;;Save]")
|
"button_exit[7,0.75;2,3;;Save]")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function object_detector_on_receive_fields(pos, formname, fields, sender)
|
local function object_detector_on_receive_fields(pos, _, fields, sender)
|
||||||
if not fields.scanname or not fields.digiline_channel then return end
|
if not fields.scanname or not fields.digiline_channel then return end
|
||||||
|
|
||||||
if minetest.is_protected(pos, sender:get_player_name()) then return end
|
if minetest.is_protected(pos, sender:get_player_name()) then return end
|
||||||
@ -53,7 +53,7 @@ end
|
|||||||
-- set player name when receiving a digiline signal on a specific channel
|
-- set player name when receiving a digiline signal on a specific channel
|
||||||
local object_detector_digiline = {
|
local object_detector_digiline = {
|
||||||
effector = {
|
effector = {
|
||||||
action = function(pos, node, channel, msg)
|
action = function(pos, _, channel, msg)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if channel == meta:get_string("digiline_channel") then
|
if channel == meta:get_string("digiline_channel") then
|
||||||
meta:set_string("scanname", msg)
|
meta:set_string("scanname", msg)
|
||||||
@ -156,7 +156,7 @@ local function node_detector_make_formspec(pos)
|
|||||||
"button_exit[7,0.75;2,3;;Save]")
|
"button_exit[7,0.75;2,3;;Save]")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function node_detector_on_receive_fields(pos, fieldname, fields, sender)
|
local function node_detector_on_receive_fields(pos, _, fields, sender)
|
||||||
if not fields.scanname or not fields.digiline_channel then return end
|
if not fields.scanname or not fields.digiline_channel then return end
|
||||||
|
|
||||||
if minetest.is_protected(pos, sender:get_player_name()) then return end
|
if minetest.is_protected(pos, sender:get_player_name()) then return end
|
||||||
@ -238,23 +238,6 @@ local node_detector_digiline = {
|
|||||||
receptor = {}
|
receptor = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function after_place_node_detector(pos, placer)
|
|
||||||
local placer_pos = placer:get_pos()
|
|
||||||
if not placer_pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--correct for the player's height
|
|
||||||
if placer:is_player() then
|
|
||||||
placer_pos.y = placer_pos.y + 1.625
|
|
||||||
end
|
|
||||||
|
|
||||||
--correct for 6d facedir
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
node.param2 = minetest.dir_to_facedir(vector.subtract(pos, placer_pos), true)
|
|
||||||
minetest.set_node(pos, node)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_detector:node_detector_off", {
|
minetest.register_node("mesecons_detector:node_detector_off", {
|
||||||
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "jeija_node_detector_off.png"},
|
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "jeija_node_detector_off.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_detector
|
name = mesecons_detector
|
||||||
depends = mesecons, mesecons_materials
|
depends = default, mesecons, mesecons_materials
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Modified, from minetest_game/mods/doors/init.lua
|
-- Modified, from minetest_game/mods/doors/init.lua
|
||||||
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
||||||
pos.y = pos.y + dir
|
pos.y = pos.y + dir
|
||||||
if not minetest.get_node(pos).name == check_name then
|
if minetest.get_node(pos).name ~= check_name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local p2 = minetest.get_node(pos).param2
|
local p2 = minetest.get_node(pos).param2
|
||||||
@ -22,11 +22,11 @@ end
|
|||||||
local function meseconify_door(name)
|
local function meseconify_door(name)
|
||||||
if minetest.registered_items[name .. "_b_1"] then
|
if minetest.registered_items[name .. "_b_1"] then
|
||||||
-- old style double-node doors
|
-- old style double-node doors
|
||||||
local function toggle_state1 (pos, node)
|
local function toggle_state1 (pos)
|
||||||
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function toggle_state2 (pos, node)
|
local function toggle_state2 (pos)
|
||||||
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,13 +49,13 @@ local function meseconify_door(name)
|
|||||||
-- new style mesh node based doors
|
-- new style mesh node based doors
|
||||||
local override = {
|
local override = {
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_on = function(pos, node)
|
action_on = function(pos)
|
||||||
local door = doors.get(pos)
|
local door = doors.get(pos)
|
||||||
if door then
|
if door then
|
||||||
door:open()
|
door:open()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
action_off = function(pos, node)
|
action_off = function(pos)
|
||||||
local door = doors.get(pos)
|
local door = doors.get(pos)
|
||||||
if door then
|
if door then
|
||||||
door:close()
|
door:close()
|
||||||
@ -66,6 +66,10 @@ local function meseconify_door(name)
|
|||||||
}
|
}
|
||||||
minetest.override_item(name .. "_a", override)
|
minetest.override_item(name .. "_a", override)
|
||||||
minetest.override_item(name .. "_b", override)
|
minetest.override_item(name .. "_b", override)
|
||||||
|
if minetest.registered_items[name .. "_c"] then
|
||||||
|
minetest.override_item(name .. "_c", override)
|
||||||
|
minetest.override_item(name .. "_d", override)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -93,13 +97,13 @@ end
|
|||||||
if doors and doors.get then
|
if doors and doors.get then
|
||||||
local override = {
|
local override = {
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_on = function(pos, node)
|
action_on = function(pos)
|
||||||
local door = doors.get(pos)
|
local door = doors.get(pos)
|
||||||
if door then
|
if door then
|
||||||
door:open()
|
door:open()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
action_off = function(pos, node)
|
action_off = function(pos)
|
||||||
local door = doors.get(pos)
|
local door = doors.get(pos)
|
||||||
if door then
|
if door then
|
||||||
door:close()
|
door:close()
|
||||||
|
@ -30,7 +30,6 @@ minetest.register_node("mesecons_extrawires:corner_on", {
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = corner_selectionbox,
|
selection_box = corner_selectionbox,
|
||||||
node_box = corner_nodebox,
|
|
||||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons_extrawires:corner_off",
|
drop = "mesecons_extrawires:corner_off",
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
@ -58,7 +57,6 @@ minetest.register_node("mesecons_extrawires:corner_off", {
|
|||||||
walkable = false,
|
walkable = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = corner_selectionbox,
|
selection_box = corner_selectionbox,
|
||||||
node_box = corner_nodebox,
|
|
||||||
groups = {dig_immediate = 3},
|
groups = {dig_immediate = 3},
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
mesecons = {conductor =
|
mesecons = {conductor =
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local function crossover_get_rules(node)
|
local crossover_rules = {
|
||||||
return {
|
|
||||||
{--first wire
|
{--first wire
|
||||||
{x=-1,y=0,z=0},
|
{x=-1,y=0,z=0},
|
||||||
{x=1,y=0,z=0},
|
{x=1,y=0,z=0},
|
||||||
@ -9,7 +8,6 @@ local function crossover_get_rules(node)
|
|||||||
{x=0,y=0,z=1},
|
{x=0,y=0,z=1},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
|
||||||
|
|
||||||
local crossover_states = {
|
local crossover_states = {
|
||||||
"mesecons_extrawires:crossover_off",
|
"mesecons_extrawires:crossover_off",
|
||||||
@ -38,7 +36,7 @@ minetest.register_node("mesecons_extrawires:crossover_off", {
|
|||||||
mesecons = {
|
mesecons = {
|
||||||
conductor = {
|
conductor = {
|
||||||
states = crossover_states,
|
states = crossover_states,
|
||||||
rules = crossover_get_rules(),
|
rules = crossover_rules,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_blast = mesecon.on_blastnode,
|
on_blast = mesecon.on_blastnode,
|
||||||
@ -65,7 +63,7 @@ minetest.register_node("mesecons_extrawires:crossover_01", {
|
|||||||
mesecons = {
|
mesecons = {
|
||||||
conductor = {
|
conductor = {
|
||||||
states = crossover_states,
|
states = crossover_states,
|
||||||
rules = crossover_get_rules(),
|
rules = crossover_rules,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_blast = mesecon.on_blastnode,
|
on_blast = mesecon.on_blastnode,
|
||||||
@ -92,7 +90,7 @@ minetest.register_node("mesecons_extrawires:crossover_10", {
|
|||||||
mesecons = {
|
mesecons = {
|
||||||
conductor = {
|
conductor = {
|
||||||
states = crossover_states,
|
states = crossover_states,
|
||||||
rules = crossover_get_rules(),
|
rules = crossover_rules,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_blast = mesecon.on_blastnode,
|
on_blast = mesecon.on_blastnode,
|
||||||
@ -119,7 +117,7 @@ minetest.register_node("mesecons_extrawires:crossover_on", {
|
|||||||
mesecons = {
|
mesecons = {
|
||||||
conductor = {
|
conductor = {
|
||||||
states = crossover_states,
|
states = crossover_states,
|
||||||
rules = crossover_get_rules(),
|
rules = crossover_rules,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
on_blast = mesecon.on_blastnode,
|
on_blast = mesecon.on_blastnode,
|
||||||
|
@ -69,7 +69,7 @@ local vertical_updatepos = function (pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local vertical_update = function (pos, node)
|
local vertical_update = function (pos)
|
||||||
vertical_updatepos(pos) -- this one
|
vertical_updatepos(pos) -- this one
|
||||||
vertical_updatepos(vector.add(pos, vertical_rules[1])) -- above
|
vertical_updatepos(vector.add(pos, vertical_rules[1])) -- above
|
||||||
vertical_updatepos(vector.add(pos, vertical_rules[2])) -- below
|
vertical_updatepos(vector.add(pos, vertical_rules[2])) -- below
|
||||||
@ -175,9 +175,9 @@ mesecon.register_node("mesecons_extrawires:vertical_bottom", {
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_extrawires:vertical_off 3",
|
output = "mesecons_extrawires:vertical_off 3",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons:wire_00000000_off"},
|
{"group:mesecon_conductor_craftable"},
|
||||||
{"mesecons:wire_00000000_off"},
|
{"group:mesecon_conductor_craftable"},
|
||||||
{"mesecons:wire_00000000_off"}
|
{"group:mesecon_conductor_craftable"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ plg.register_nodes({
|
|||||||
meta:set_int("valid", 0)
|
meta:set_int("valid", 0)
|
||||||
meta:set_string("infotext", "FPGA")
|
meta:set_string("infotext", "FPGA")
|
||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, _, clicker)
|
||||||
if not minetest.is_player(clicker) then
|
if not minetest.is_player(clicker) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -113,10 +113,11 @@ plg.register_nodes({
|
|||||||
mesecons = {
|
mesecons = {
|
||||||
effector = {
|
effector = {
|
||||||
rules = {}, -- replaced later
|
rules = {}, -- replaced later
|
||||||
action_change = function(pos, node, rule, newstate)
|
action_change = function(pos, _, rule, newstate)
|
||||||
plg.ports_changed(pos, rule, newstate)
|
if plg.ports_changed(pos, rule, newstate) then
|
||||||
plg.update(pos)
|
plg.update(pos)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
after_dig_node = function(pos, node)
|
after_dig_node = function(pos, node)
|
||||||
@ -129,7 +130,7 @@ plg.register_nodes({
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_blast = mesecon.on_blastnode,
|
on_blast = mesecon.on_blastnode,
|
||||||
on_rotate = function(pos, node, user, mode)
|
on_rotate = function(pos, _, user, mode)
|
||||||
local abcd1 = {"A", "B", "C", "D"}
|
local abcd1 = {"A", "B", "C", "D"}
|
||||||
local abcd2 = {A = 1, B = 2, C = 3, D = 4}
|
local abcd2 = {A = 1, B = 2, C = 3, D = 4}
|
||||||
local ops = {"op1", "op2", "dst"}
|
local ops = {"op1", "op2", "dst"}
|
||||||
@ -326,8 +327,10 @@ plg.update = function(pos)
|
|||||||
plg.setports(pos, A, B, C, D)
|
plg.setports(pos, A, B, C, D)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Updates the port states according to the signal change.
|
||||||
|
-- Returns whether the port states actually changed.
|
||||||
plg.ports_changed = function(pos, rule, newstate)
|
plg.ports_changed = function(pos, rule, newstate)
|
||||||
if rule == nil then return end
|
if rule == nil then return false end
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local states
|
local states
|
||||||
|
|
||||||
@ -347,10 +350,14 @@ plg.ports_changed = function(pos, rule, newstate)
|
|||||||
local portno = ({4, 1, nil, 3, 2})[3 + rule.x + 2*rule.z]
|
local portno = ({4, 1, nil, 3, 2})[3 + rule.x + 2*rule.z]
|
||||||
states[portno] = (newstate == "on")
|
states[portno] = (newstate == "on")
|
||||||
|
|
||||||
meta:set_string("portstates",
|
local new_portstates =
|
||||||
(states[1] and "1" or "0") .. (states[2] and "1" or "0") ..
|
(states[1] and "1" or "0") .. (states[2] and "1" or "0") ..
|
||||||
(states[3] and "1" or "0") .. (states[4] and "1" or "0")
|
(states[3] and "1" or "0") .. (states[4] and "1" or "0")
|
||||||
)
|
if new_portstates ~= s then
|
||||||
|
meta:set_string("portstates", new_portstates)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
plg.getports = function(pos) -- gets merged states of INPUT & OUTPUT
|
plg.getports = function(pos) -- gets merged states of INPUT & OUTPUT
|
||||||
|
@ -10,10 +10,10 @@ local operations = {
|
|||||||
-- unary: Whether this gate only has one input
|
-- unary: Whether this gate only has one input
|
||||||
{ gate = "and", short = "&", fs_name = " AND", func = function(a, b) return a and b end },
|
{ gate = "and", short = "&", fs_name = " AND", func = function(a, b) return a and b end },
|
||||||
{ gate = "or", short = "|", fs_name = " OR", func = function(a, b) return a or b end },
|
{ gate = "or", short = "|", fs_name = " OR", func = function(a, b) return a or b end },
|
||||||
{ gate = "not", short = "~", fs_name = " NOT", func = function(a, b) return not b end, unary = true },
|
{ gate = "not", short = "~", fs_name = " NOT", func = function(_, b) return not b end, unary = true },
|
||||||
{ gate = "xor", short = "^", fs_name = " XOR", func = function(a, b) return a ~= b end },
|
{ gate = "xor", short = "^", fs_name = " XOR", func = function(a, b) return a ~= b end },
|
||||||
{ gate = "nand", short = "?", fs_name = "NAND", func = function(a, b) return not (a and b) end },
|
{ gate = "nand", short = "?", fs_name = "NAND", func = function(a, b) return not (a and b) end },
|
||||||
{ gate = "buf", short = "_", fs_name = " =", func = function(a, b) return b end, unary = true },
|
{ gate = "buf", short = "_", fs_name = " =", func = function(_, b) return b end, unary = true },
|
||||||
{ gate = "xnor", short = "=", fs_name = "XNOR", func = function(a, b) return a == b end },
|
{ gate = "xnor", short = "=", fs_name = "XNOR", func = function(a, b) return a == b end },
|
||||||
{ gate = "nor", short = "!", fs_name = " NOR", func = function(a, b) return not (a or b) end },
|
{ gate = "nor", short = "!", fs_name = " NOR", func = function(a, b) return not (a or b) end },
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
name = mesecons_fpga
|
name = mesecons_fpga
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
optional_depends = screwdriver
|
optional_depends = screwdriver
|
||||||
|
@ -65,7 +65,6 @@ end
|
|||||||
local function register_gate(name, inputnumber, assess, recipe, description)
|
local function register_gate(name, inputnumber, assess, recipe, description)
|
||||||
local get_inputrules = inputnumber == 2 and gate_get_input_rules_twoinputs or
|
local get_inputrules = inputnumber == 2 and gate_get_input_rules_twoinputs or
|
||||||
gate_get_input_rules_oneinput
|
gate_get_input_rules_oneinput
|
||||||
description = "Logic Gate: "..name
|
|
||||||
|
|
||||||
local basename = "mesecons_gates:"..name
|
local basename = "mesecons_gates:"..name
|
||||||
mesecon.register_node(basename, {
|
mesecon.register_node(basename, {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_gates
|
name = mesecons_gates
|
||||||
depends = mesecons, mesecons_microcontroller, mesecons_delayer, mesecons_torch, mesecons_materials
|
depends = default, mesecons, mesecons_microcontroller, mesecons_delayer, mesecons_torch, mesecons_materials
|
||||||
|
@ -12,6 +12,7 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
|
|||||||
"jeija_hydro_turbine_turbine_top_bottom_off.png",
|
"jeija_hydro_turbine_turbine_top_bottom_off.png",
|
||||||
"jeija_hydro_turbine_turbine_misc_off.png"
|
"jeija_hydro_turbine_turbine_misc_off.png"
|
||||||
},
|
},
|
||||||
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or nil,
|
||||||
inventory_image = "jeija_hydro_turbine_inv.png",
|
inventory_image = "jeija_hydro_turbine_inv.png",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
wield_scale = {x=0.75, y=0.75, z=0.75},
|
wield_scale = {x=0.75, y=0.75, z=0.75},
|
||||||
@ -42,6 +43,7 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
|
|||||||
{ name = "jeija_hydro_turbine_turbine_misc_on.png",
|
{ name = "jeija_hydro_turbine_turbine_misc_on.png",
|
||||||
animation = {type = "vertical_frames", aspect_w = 256, aspect_h = 32, length = 0.4} }
|
animation = {type = "vertical_frames", aspect_w = 256, aspect_h = 32, length = 0.4} }
|
||||||
},
|
},
|
||||||
|
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or nil,
|
||||||
inventory_image = "jeija_hydro_turbine_inv.png",
|
inventory_image = "jeija_hydro_turbine_inv.png",
|
||||||
drop = "mesecons_hydroturbine:hydro_turbine_off 1",
|
drop = "mesecons_hydroturbine:hydro_turbine_off 1",
|
||||||
groups = {dig_immediate=2,not_in_creative_inventory=1},
|
groups = {dig_immediate=2,not_in_creative_inventory=1},
|
||||||
@ -70,7 +72,7 @@ minetest.register_abm({
|
|||||||
nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
|
nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos)
|
||||||
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
if is_flowing_water(waterpos) then
|
if is_flowing_water(waterpos) then
|
||||||
minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
|
minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
|
||||||
@ -83,7 +85,7 @@ minetest.register_abm({
|
|||||||
nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
|
nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos)
|
||||||
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
||||||
if not is_flowing_water(waterpos) then
|
if not is_flowing_water(waterpos) then
|
||||||
minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
|
minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_hydroturbine
|
name = mesecons_hydroturbine
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -86,7 +86,7 @@ minetest.register_craft({
|
|||||||
output = "mesecons_insulated:insulated_off 3",
|
output = "mesecons_insulated:insulated_off 3",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
|
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
|
||||||
{"mesecons:wire_00000000_off", "mesecons:wire_00000000_off", "mesecons:wire_00000000_off"},
|
{"group:mesecon_conductor_craftable", "group:mesecon_conductor_craftable", "group:mesecon_conductor_craftable"},
|
||||||
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
|
{"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
name = mesecons_insulated
|
name = mesecons_insulated
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
optional_depends = screwdriver
|
optional_depends = screwdriver
|
||||||
|
@ -9,9 +9,12 @@ local mesecon_lamp_box = {
|
|||||||
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
|
wall_side = {-0.375,-0.3125,-0.3125,-0.5,0.3125,0.3125},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "opaque" or nil
|
||||||
|
|
||||||
minetest.register_node("mesecons_lamp:lamp_on", {
|
minetest.register_node("mesecons_lamp:lamp_on", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"jeija_meselamp_on.png"},
|
tiles = {"jeija_meselamp_on.png"},
|
||||||
|
use_texture_alpha = use_texture_alpha,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
@ -36,6 +39,7 @@ minetest.register_node("mesecons_lamp:lamp_on", {
|
|||||||
minetest.register_node("mesecons_lamp:lamp_off", {
|
minetest.register_node("mesecons_lamp:lamp_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"jeija_meselamp_off.png"},
|
tiles = {"jeija_meselamp_off.png"},
|
||||||
|
use_texture_alpha = use_texture_alpha,
|
||||||
inventory_image = "jeija_meselamp.png",
|
inventory_image = "jeija_meselamp.png",
|
||||||
wield_image = "jeija_meselamp.png",
|
wield_image = "jeija_meselamp.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_lamp
|
name = mesecons_lamp
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_lightstone
|
name = mesecons_lightstone
|
||||||
depends = mesecons, dye
|
depends = default, mesecons, dye
|
||||||
|
@ -43,13 +43,16 @@ local rules = {
|
|||||||
------------------
|
------------------
|
||||||
-- These helpers are required to set the port states of the luacontroller
|
-- These helpers are required to set the port states of the luacontroller
|
||||||
|
|
||||||
|
-- Updates the real port states according to the signal change.
|
||||||
|
-- Returns whether the real port states actually changed.
|
||||||
local function update_real_port_states(pos, rule_name, new_state)
|
local function update_real_port_states(pos, rule_name, new_state)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if rule_name == nil then
|
if rule_name == nil then
|
||||||
meta:set_int("real_portstates", 1)
|
meta:set_int("real_portstates", 1)
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
local n = meta:get_int("real_portstates") - 1
|
local real_portstates = meta:get_int("real_portstates")
|
||||||
|
local n = real_portstates - 1
|
||||||
local L = {}
|
local L = {}
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
L[i] = n % 2
|
L[i] = n % 2
|
||||||
@ -60,18 +63,18 @@ local function update_real_port_states(pos, rule_name, new_state)
|
|||||||
if rule_name.x == nil then
|
if rule_name.x == nil then
|
||||||
for _, rname in ipairs(rule_name) do
|
for _, rname in ipairs(rule_name) do
|
||||||
local port = pos_to_side[rname.x + (2 * rname.z) + 3]
|
local port = pos_to_side[rname.x + (2 * rname.z) + 3]
|
||||||
L[port] = (newstate == "on") and 1 or 0
|
L[port] = (new_state == "on") and 1 or 0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local port = pos_to_side[rule_name.x + (2 * rule_name.z) + 3]
|
local port = pos_to_side[rule_name.x + (2 * rule_name.z) + 3]
|
||||||
L[port] = (new_state == "on") and 1 or 0
|
L[port] = (new_state == "on") and 1 or 0
|
||||||
end
|
end
|
||||||
meta:set_int("real_portstates",
|
local new_portstates = 1 + 1 * L[1] + 2 * L[2] + 4 * L[3] + 8 * L[4]
|
||||||
1 +
|
if new_portstates ~= real_portstates then
|
||||||
1 * L[1] +
|
meta:set_int("real_portstates", new_portstates)
|
||||||
2 * L[2] +
|
return true
|
||||||
4 * L[3] +
|
end
|
||||||
8 * L[4])
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -172,7 +175,7 @@ local function burn_controller(pos)
|
|||||||
minetest.after(0.2, mesecon.receptor_off, pos, mesecon.rules.flat)
|
minetest.after(0.2, mesecon.receptor_off, pos, mesecon.rules.flat)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function overheat(pos, meta)
|
local function overheat(pos)
|
||||||
if mesecon.do_overheat(pos) then -- If too hot
|
if mesecon.do_overheat(pos) then -- If too hot
|
||||||
burn_controller(pos)
|
burn_controller(pos)
|
||||||
return true
|
return true
|
||||||
@ -612,9 +615,8 @@ local function run_inner(pos, code, event)
|
|||||||
if overheat(pos) then return true, "" end
|
if overheat(pos) then return true, "" end
|
||||||
if ignore_event(event, meta) then return true, "" end
|
if ignore_event(event, meta) then return true, "" end
|
||||||
|
|
||||||
-- Load code & mem from meta
|
-- Load mem from meta
|
||||||
local mem = load_memory(meta)
|
local mem = load_memory(meta)
|
||||||
local code = meta:get_string("code")
|
|
||||||
|
|
||||||
-- 'Last warning' label.
|
-- 'Last warning' label.
|
||||||
local warning = ""
|
local warning = ""
|
||||||
@ -626,15 +628,17 @@ local function run_inner(pos, code, event)
|
|||||||
local itbl = {}
|
local itbl = {}
|
||||||
local env = create_environment(pos, mem, event, itbl, send_warning)
|
local env = create_environment(pos, mem, event, itbl, send_warning)
|
||||||
|
|
||||||
|
local success, msg
|
||||||
-- Create the sandbox and execute code
|
-- Create the sandbox and execute code
|
||||||
local f, msg = create_sandbox(code, env)
|
local f
|
||||||
|
f, msg = create_sandbox(code, env)
|
||||||
if not f then return false, msg end
|
if not f then return false, msg end
|
||||||
-- Start string true sandboxing
|
-- Start string true sandboxing
|
||||||
local onetruestring = getmetatable("")
|
local onetruestring = getmetatable("")
|
||||||
-- If a string sandbox is already up yet inconsistent, something is very wrong
|
-- If a string sandbox is already up yet inconsistent, something is very wrong
|
||||||
assert(onetruestring.__index == string)
|
assert(onetruestring.__index == string)
|
||||||
onetruestring.__index = env.string
|
onetruestring.__index = env.string
|
||||||
local success, msg = pcall(f)
|
success, msg = pcall(f)
|
||||||
onetruestring.__index = string
|
onetruestring.__index = string
|
||||||
-- End string true sandboxing
|
-- End string true sandboxing
|
||||||
if not success then return false, msg end
|
if not success then return false, msg end
|
||||||
@ -748,7 +752,7 @@ local selection_box = {
|
|||||||
local digiline = {
|
local digiline = {
|
||||||
receptor = {},
|
receptor = {},
|
||||||
effector = {
|
effector = {
|
||||||
action = function(pos, node, channel, msg)
|
action = function(pos, _, channel, msg)
|
||||||
msg = clean_and_weigh_digiline_message(msg)
|
msg = clean_and_weigh_digiline_message(msg)
|
||||||
run(pos, {type = "digiline", channel = channel, msg = msg})
|
run(pos, {type = "digiline", channel = channel, msg = msg})
|
||||||
end
|
end
|
||||||
@ -766,7 +770,7 @@ local function set_program(pos, code)
|
|||||||
return run(pos, {type="program"})
|
return run(pos, {type="program"})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_receive_fields(pos, form_name, fields, sender)
|
local function on_receive_fields(pos, _, fields, sender)
|
||||||
if not fields.program then
|
if not fields.program then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -825,8 +829,9 @@ for d = 0, 1 do
|
|||||||
effector = {
|
effector = {
|
||||||
rules = input_rules[cid],
|
rules = input_rules[cid],
|
||||||
action_change = function (pos, _, rule_name, new_state)
|
action_change = function (pos, _, rule_name, new_state)
|
||||||
update_real_port_states(pos, rule_name, new_state)
|
if update_real_port_states(pos, rule_name, new_state) then
|
||||||
run(pos, {type=new_state, pin=rule_name})
|
run(pos, {type=new_state, pin=rule_name})
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
receptor = {
|
receptor = {
|
||||||
@ -871,7 +876,7 @@ for d = 0, 1 do
|
|||||||
c = c == 1,
|
c = c == 1,
|
||||||
d = d == 1,
|
d = d == 1,
|
||||||
},
|
},
|
||||||
after_dig_node = function (pos, node)
|
after_dig_node = function (pos)
|
||||||
mesecon.do_cooldown(pos)
|
mesecon.do_cooldown(pos)
|
||||||
mesecon.receptor_off(pos, output_rules)
|
mesecon.receptor_off(pos, output_rules)
|
||||||
end,
|
end,
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_luacontroller
|
name = mesecons_luacontroller
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_materials
|
name = mesecons_materials
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -44,9 +44,10 @@ local mesecons = {effector =
|
|||||||
{
|
{
|
||||||
rules = input_rules,
|
rules = input_rules,
|
||||||
action_change = function (pos, node, rulename, newstate)
|
action_change = function (pos, node, rulename, newstate)
|
||||||
yc.update_real_portstates(pos, node, rulename, newstate)
|
if yc.update_real_portstates(pos, node, rulename, newstate) then
|
||||||
yc.update(pos)
|
yc.update(pos)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
}}
|
}}
|
||||||
if nodename ~= "mesecons_microcontroller:microcontroller0000" then
|
if nodename ~= "mesecons_microcontroller:microcontroller0000" then
|
||||||
mesecons.receptor = {
|
mesecons.receptor = {
|
||||||
@ -102,7 +103,7 @@ minetest.register_node(nodename, {
|
|||||||
for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0"
|
for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0"
|
||||||
meta:set_string("eeprom", r)
|
meta:set_string("eeprom", r)
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formanme, fields, sender)
|
on_receive_fields = function(pos, _, fields, sender)
|
||||||
local player_name = sender:get_player_name()
|
local player_name = sender:get_player_name()
|
||||||
if minetest.is_protected(pos, player_name) and
|
if minetest.is_protected(pos, player_name) and
|
||||||
not minetest.check_player_privs(player_name, {protection_bypass=true}) then
|
not minetest.check_player_privs(player_name, {protection_bypass=true}) then
|
||||||
@ -225,7 +226,6 @@ yc.parsecode = function(code, pos)
|
|||||||
local Lreal = yc.get_real_portstates(pos)
|
local Lreal = yc.get_real_portstates(pos)
|
||||||
local Lvirtual = yc.get_virtual_portstates(pos)
|
local Lvirtual = yc.get_virtual_portstates(pos)
|
||||||
if Lvirtual == nil then return nil end
|
if Lvirtual == nil then return nil end
|
||||||
local c
|
|
||||||
local eeprom = meta:get_string("eeprom")
|
local eeprom = meta:get_string("eeprom")
|
||||||
while true do
|
while true do
|
||||||
local command, params
|
local command, params
|
||||||
@ -251,9 +251,9 @@ yc.parsecode = function(code, pos)
|
|||||||
if not params then return nil end
|
if not params then return nil end
|
||||||
end
|
end
|
||||||
if command == "on" then
|
if command == "on" then
|
||||||
L = yc.command_on (params, Lvirtual)
|
Lvirtual = yc.command_on (params, Lvirtual)
|
||||||
elseif command == "off" then
|
elseif command == "off" then
|
||||||
L = yc.command_off(params, Lvirtual)
|
Lvirtual = yc.command_off(params, Lvirtual)
|
||||||
elseif command == "print" then
|
elseif command == "print" then
|
||||||
local 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
|
if su ~= true then return nil end
|
||||||
@ -384,7 +384,6 @@ end
|
|||||||
|
|
||||||
--Commands
|
--Commands
|
||||||
yc.command_on = function(params, L)
|
yc.command_on = function(params, L)
|
||||||
local rules = {}
|
|
||||||
for i, port in ipairs(params) do
|
for i, port in ipairs(params) do
|
||||||
L = yc.set_portstate (port, true, L)
|
L = yc.set_portstate (port, true, L)
|
||||||
end
|
end
|
||||||
@ -392,7 +391,6 @@ yc.command_on = function(params, L)
|
|||||||
end
|
end
|
||||||
|
|
||||||
yc.command_off = function(params, L)
|
yc.command_off = function(params, L)
|
||||||
local rules = {}
|
|
||||||
for i, port in ipairs(params) do
|
for i, port in ipairs(params) do
|
||||||
L = yc.set_portstate (port, false, L)
|
L = yc.set_portstate (port, false, L)
|
||||||
end
|
end
|
||||||
@ -405,7 +403,7 @@ yc.command_print = function(params, eeprom, L)
|
|||||||
if param:sub(1,1) == '"' and param:sub(#param, #param) == '"' then
|
if param:sub(1,1) == '"' and param:sub(#param, #param) == '"' then
|
||||||
s = s..param:sub(2, #param-1)
|
s = s..param:sub(2, #param-1)
|
||||||
else
|
else
|
||||||
r = yc.command_parsecondition(param, L, eeprom)
|
local r = yc.command_parsecondition(param, L, eeprom)
|
||||||
if r == "1" or r == "0" then
|
if r == "1" or r == "0" then
|
||||||
s = s..r
|
s = s..r
|
||||||
else return nil end
|
else return nil end
|
||||||
@ -469,8 +467,8 @@ yc.command_after_execute = function(params)
|
|||||||
if yc.parsecode(params.code, params.pos) == nil then
|
if yc.parsecode(params.code, params.pos) == nil then
|
||||||
meta:set_string("infotext", "Code in after() not valid!")
|
meta:set_string("infotext", "Code in after() not valid!")
|
||||||
else
|
else
|
||||||
if code ~= nil then
|
if params.code ~= nil then
|
||||||
meta:set_string("infotext", "Working Microcontroller\n"..code)
|
meta:set_string("infotext", "Working Microcontroller\n"..params.code)
|
||||||
else
|
else
|
||||||
meta:set_string("infotext", "Working Microcontroller")
|
meta:set_string("infotext", "Working Microcontroller")
|
||||||
end
|
end
|
||||||
@ -543,8 +541,8 @@ yc.command_parsecondition = function(cond, L, eeprom)
|
|||||||
cond = string.gsub(cond, "!0", "1")
|
cond = string.gsub(cond, "!0", "1")
|
||||||
cond = string.gsub(cond, "!1", "0")
|
cond = string.gsub(cond, "!1", "0")
|
||||||
|
|
||||||
local i = 2
|
i = 2
|
||||||
local l = string.len(cond)
|
l = string.len(cond)
|
||||||
while i<=l do
|
while i<=l do
|
||||||
local s = cond:sub(i,i)
|
local s = cond:sub(i,i)
|
||||||
local b = tonumber(cond:sub(i-1, i-1))
|
local b = tonumber(cond:sub(i-1, i-1))
|
||||||
@ -553,8 +551,7 @@ yc.command_parsecondition = function(cond, L, eeprom)
|
|||||||
if s == "=" then
|
if s == "=" then
|
||||||
if a==nil then return nil end
|
if a==nil then return nil end
|
||||||
if b==nil then return nil end
|
if b==nil then return nil end
|
||||||
if a == b then buf = "1" end
|
local buf = a == b and "1" or "0"
|
||||||
if a ~= b then buf = "0" end
|
|
||||||
cond = string.gsub(cond, b..s..a, buf)
|
cond = string.gsub(cond, b..s..a, buf)
|
||||||
i = 1
|
i = 1
|
||||||
l = string.len(cond)
|
l = string.len(cond)
|
||||||
@ -562,8 +559,8 @@ yc.command_parsecondition = function(cond, L, eeprom)
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local i = 2
|
i = 2
|
||||||
local l = string.len(cond)
|
l = string.len(cond)
|
||||||
while i<=l do
|
while i<=l do
|
||||||
local s = cond:sub(i,i)
|
local s = cond:sub(i,i)
|
||||||
local b = tonumber(cond:sub(i-1, i-1))
|
local b = tonumber(cond:sub(i-1, i-1))
|
||||||
@ -659,13 +656,16 @@ yc.set_portstate = function(port, state, L)
|
|||||||
return L
|
return L
|
||||||
end
|
end
|
||||||
|
|
||||||
yc.update_real_portstates = function(pos, node, rulename, newstate)
|
-- Updates the real port states according to the signal change.
|
||||||
|
-- Returns whether the real port states actually changed.
|
||||||
|
yc.update_real_portstates = function(pos, _, rulename, newstate)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if rulename == nil then
|
if rulename == nil then
|
||||||
meta:set_int("real_portstates", 1)
|
meta:set_int("real_portstates", 1)
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
local n = meta:get_int("real_portstates") - 1
|
local real_portstates = meta:get_int("real_portstates")
|
||||||
|
local n = real_portstates - 1
|
||||||
local L = {}
|
local L = {}
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
L[i] = n%2
|
L[i] = n%2
|
||||||
@ -680,7 +680,12 @@ yc.update_real_portstates = function(pos, node, rulename, newstate)
|
|||||||
local port = ({4, 1, nil, 3, 2})[rulename.x+2*rulename.z+3]
|
local port = ({4, 1, nil, 3, 2})[rulename.x+2*rulename.z+3]
|
||||||
L[port] = (newstate == "on") and 1 or 0
|
L[port] = (newstate == "on") and 1 or 0
|
||||||
end
|
end
|
||||||
meta:set_int("real_portstates", 1 + L[1] + 2*L[2] + 4*L[3] + 8*L[4])
|
local new_portstates = 1 + L[1] + 2*L[2] + 4*L[3] + 8*L[4]
|
||||||
|
if new_portstates ~= real_portstates then
|
||||||
|
meta:set_int("real_portstates", new_portstates)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
yc.get_real_portstates = function(pos) -- determine if ports are powered (by itself or from outside)
|
yc.get_real_portstates = function(pos) -- determine if ports are powered (by itself or from outside)
|
||||||
@ -696,7 +701,7 @@ end
|
|||||||
|
|
||||||
yc.get_virtual_portstates = function(pos) -- portstates according to the name
|
yc.get_virtual_portstates = function(pos) -- portstates according to the name
|
||||||
local name = minetest.get_node(pos).name
|
local name = minetest.get_node(pos).name
|
||||||
local b, a = string.find(name, ":microcontroller")
|
local _, a = string.find(name, ":microcontroller")
|
||||||
if a == nil then return nil end
|
if a == nil then return nil end
|
||||||
a = a + 1
|
a = a + 1
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_microcontroller
|
name = mesecons_microcontroller
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -71,7 +71,7 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
|||||||
-- ### Step 3: If sticky, pull stack behind ###
|
-- ### Step 3: If sticky, pull stack behind ###
|
||||||
if is_sticky then
|
if is_sticky then
|
||||||
local backpos = vector.subtract(pos, direction)
|
local backpos = vector.subtract(pos, direction)
|
||||||
success, stack, oldstack = mesecon.mvps_pull_all(backpos, direction, max_pull, owner)
|
local success, _, oldstack = mesecon.mvps_pull_all(backpos, direction, max_pull, owner)
|
||||||
if success then
|
if success then
|
||||||
mesecon.mvps_move_objects(backpos, vector.multiply(direction, -1), oldstack, -1)
|
mesecon.mvps_move_objects(backpos, vector.multiply(direction, -1), oldstack, -1)
|
||||||
end
|
end
|
||||||
@ -94,7 +94,7 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
|||||||
|
|
||||||
def.after_place_node = mesecon.mvps_set_owner
|
def.after_place_node = mesecon.mvps_set_owner
|
||||||
|
|
||||||
def.on_punch = function(pos, node, player)
|
def.on_punch = function(pos, _, player)
|
||||||
local player_name = player and player.get_player_name and player:get_player_name()
|
local player_name = player and player.get_player_name and player:get_player_name()
|
||||||
if mesecon.mvps_claim(pos, player_name) then
|
if mesecon.mvps_claim(pos, player_name) then
|
||||||
minetest.get_node_timer(pos):start(timer_interval)
|
minetest.get_node_timer(pos):start(timer_interval)
|
||||||
@ -102,7 +102,7 @@ function mesecon.register_movestone(name, def, is_sticky, is_vertical)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def.on_timer = function(pos, elapsed)
|
def.on_timer = function(pos)
|
||||||
local sourcepos = mesecon.is_powered(pos)
|
local sourcepos = mesecon.is_powered(pos)
|
||||||
if not sourcepos then
|
if not sourcepos then
|
||||||
return
|
return
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_movestones
|
name = mesecons_movestones
|
||||||
depends = mesecons, mesecons_materials, mesecons_mvps
|
depends = default, mesecons, mesecons_materials, mesecons_mvps
|
||||||
|
@ -46,11 +46,9 @@ local function on_mvps_move(moved_nodes)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.mvps_process_stack(stack)
|
function mesecon.mvps_process_stack()
|
||||||
-- update mesecons for placed nodes ( has to be done after all nodes have been added )
|
-- This function is kept for compatibility.
|
||||||
for _, n in ipairs(stack) do
|
-- It used to call on_placenode on moved nodes, but that is now done automatically.
|
||||||
mesecon.on_placenode(n.pos, minetest.get_node(n.pos))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- tests if the node can be pushed into, e.g. air, water, grass
|
-- tests if the node can be pushed into, e.g. air, water, grass
|
||||||
@ -273,7 +271,6 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor)
|
function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor)
|
||||||
local objects_to_move = {}
|
|
||||||
local dir_k
|
local dir_k
|
||||||
local dir_l
|
local dir_l
|
||||||
for k, v in pairs(dir) do
|
for k, v in pairs(dir) do
|
||||||
@ -331,11 +328,31 @@ end
|
|||||||
-- TODO: load blocks instead, as with wires.
|
-- TODO: load blocks instead, as with wires.
|
||||||
mesecon.register_mvps_stopper("ignore")
|
mesecon.register_mvps_stopper("ignore")
|
||||||
|
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_b_1")
|
-- All of the locked and internal nodes in Minetest Game
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_t_1")
|
for _, name in ipairs({
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_b_2")
|
"default:chest_locked",
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_t_2")
|
"default:chest_locked_open",
|
||||||
mesecon.register_mvps_stopper("default:chest_locked")
|
"doors:door_steel_b_1", -- old style doors
|
||||||
|
"doors:door_steel_b_2", --
|
||||||
|
"doors:door_steel_t_1", --
|
||||||
|
"doors:door_steel_t_2", --
|
||||||
|
"doors:door_steel_a", -- new style doors
|
||||||
|
"doors:door_steel_b", --
|
||||||
|
"doors:door_steel_c", --
|
||||||
|
"doors:door_steel_d", --
|
||||||
|
"doors:hidden",
|
||||||
|
"doors:trapdoor_steel",
|
||||||
|
"doors:trapdoor_steel_open",
|
||||||
|
"xpanes:door_steel_bar_a",
|
||||||
|
"xpanes:door_steel_bar_b",
|
||||||
|
"xpanes:door_steel_bar_c",
|
||||||
|
"xpanes:door_steel_bar_d",
|
||||||
|
"xpanes:trapdoor_steel_bar",
|
||||||
|
"xpanes:trapdoor_steel_bar_open",
|
||||||
|
}) do
|
||||||
|
mesecon.register_mvps_stopper(name)
|
||||||
|
end
|
||||||
|
|
||||||
mesecon.register_on_mvps_move(mesecon.move_hot_nodes)
|
mesecon.register_on_mvps_move(mesecon.move_hot_nodes)
|
||||||
mesecon.register_on_mvps_move(function(moved_nodes)
|
mesecon.register_on_mvps_move(function(moved_nodes)
|
||||||
for i = 1, #moved_nodes do
|
for i = 1, #moved_nodes do
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_noteblock
|
name = mesecons_noteblock
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -93,7 +93,6 @@ local piston_on = function(pos, node)
|
|||||||
minetest.swap_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
minetest.swap_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||||
minetest.set_node(pusher_pos, {param2 = node.param2, name = pistonspec.pusher})
|
minetest.set_node(pusher_pos, {param2 = node.param2, name = pistonspec.pusher})
|
||||||
minetest.sound_play("piston_extend", { pos = pos, max_hear_distance = 20, gain = 0.3 }, true)
|
minetest.sound_play("piston_extend", { pos = pos, max_hear_distance = 20, gain = 0.3 }, true)
|
||||||
mesecon.mvps_process_stack(stack)
|
|
||||||
mesecon.mvps_move_objects(pusher_pos, dir, oldstack)
|
mesecon.mvps_move_objects(pusher_pos, dir, oldstack)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -108,7 +107,7 @@ local function piston_off(pos, node)
|
|||||||
local dir = minetest.facedir_to_dir(node.param2)
|
local dir = minetest.facedir_to_dir(node.param2)
|
||||||
local pullpos = vector.add(pos, vector.multiply(dir, -2))
|
local pullpos = vector.add(pos, vector.multiply(dir, -2))
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local success, stack, oldstack = mesecon.mvps_pull_single(pullpos, dir, max_pull, meta:get_string("owner"))
|
local success, _, oldstack = mesecon.mvps_pull_single(pullpos, dir, max_pull, meta:get_string("owner"))
|
||||||
if success then
|
if success then
|
||||||
mesecon.mvps_move_objects(pullpos, vector.multiply(dir, -1), oldstack, -1)
|
mesecon.mvps_move_objects(pullpos, vector.multiply(dir, -1), oldstack, -1)
|
||||||
end
|
end
|
||||||
@ -235,7 +234,7 @@ local function piston_rotate_pusher(pos, node, player, mode)
|
|||||||
return piston_rotate_on(piston_pos, piston_node, player, mode)
|
return piston_rotate_on(piston_pos, piston_node, player, mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function piston_punch(pos, node, player)
|
local function piston_punch(pos, _, player)
|
||||||
local player_name = player and player.get_player_name and player:get_player_name()
|
local player_name = player and player.get_player_name and player:get_player_name()
|
||||||
if mesecon.mvps_claim(pos, player_name) then
|
if mesecon.mvps_claim(pos, player_name) then
|
||||||
minetest.chat_send_player(player_name, "Reclaimed piston")
|
minetest.chat_send_player(player_name, "Reclaimed piston")
|
||||||
@ -423,7 +422,7 @@ minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
|
|||||||
|
|
||||||
|
|
||||||
-- Register pushers as stoppers if they would be seperated from the piston
|
-- Register pushers as stoppers if they would be seperated from the piston
|
||||||
local function piston_pusher_get_stopper(node, dir, stack, stackid)
|
local function piston_pusher_get_stopper(node, _, stack, stackid)
|
||||||
if (stack[stackid + 1]
|
if (stack[stackid + 1]
|
||||||
and stack[stackid + 1].node.name == get_pistonspec(node.name, "pusher").onname
|
and stack[stackid + 1].node.name == get_pistonspec(node.name, "pusher").onname
|
||||||
and stack[stackid + 1].node.param2 == node.param2)
|
and stack[stackid + 1].node.param2 == node.param2)
|
||||||
@ -435,32 +434,12 @@ local function piston_pusher_get_stopper(node, dir, stack, stackid)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function piston_pusher_up_down_get_stopper(node, dir, stack, stackid)
|
|
||||||
if (stack[stackid + 1]
|
|
||||||
and stack[stackid + 1].node.name == get_pistonspec(node.name, "pusher").onname)
|
|
||||||
or (stack[stackid - 1]
|
|
||||||
and stack[stackid - 1].node.name == get_pistonspec(node.name, "pusher").onname) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
mesecon.register_mvps_stopper("mesecons_pistons:piston_pusher_normal", piston_pusher_get_stopper)
|
mesecon.register_mvps_stopper("mesecons_pistons:piston_pusher_normal", piston_pusher_get_stopper)
|
||||||
mesecon.register_mvps_stopper("mesecons_pistons:piston_pusher_sticky", piston_pusher_get_stopper)
|
mesecon.register_mvps_stopper("mesecons_pistons:piston_pusher_sticky", piston_pusher_get_stopper)
|
||||||
|
|
||||||
|
|
||||||
-- Register pistons as stoppers if they would be seperated from the stopper
|
-- Register pistons as stoppers if they would be seperated from the stopper
|
||||||
local piston_up_down_get_stopper = function (node, dir, stack, stackid)
|
local function piston_get_stopper(node, _, stack, stackid)
|
||||||
if (stack[stackid + 1]
|
|
||||||
and stack[stackid + 1].node.name == get_pistonspec(node.name, "onname").pusher)
|
|
||||||
or (stack[stackid - 1]
|
|
||||||
and stack[stackid - 1].node.name == get_pistonspec(node.name, "onname").pusher) then
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local function piston_get_stopper(node, dir, stack, stackid)
|
|
||||||
local pistonspec = get_pistonspec(node.name, "onname")
|
local pistonspec = get_pistonspec(node.name, "onname")
|
||||||
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
|
local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1)
|
||||||
local pusherpos = vector.add(stack[stackid].pos, dir)
|
local pusherpos = vector.add(stack[stackid].pos, dir)
|
||||||
@ -500,4 +479,4 @@ minetest.register_craft({
|
|||||||
|
|
||||||
|
|
||||||
-- load legacy code
|
-- load legacy code
|
||||||
dofile(minetest.get_modpath("mesecons_pistons")..DIR_DELIM.."legacy.lua")
|
dofile(minetest.get_modpath("mesecons_pistons").."/legacy.lua")
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_pistons
|
name = mesecons_pistons
|
||||||
depends = mesecons, mesecons_mvps
|
depends = default, mesecons, mesecons_mvps
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_powerplant
|
name = mesecons_powerplant
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -8,7 +8,7 @@ local pp_box_on = {
|
|||||||
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
|
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
|
||||||
}
|
}
|
||||||
|
|
||||||
local function pp_on_timer(pos, elapsed)
|
local function pp_on_timer(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local basename = minetest.registered_nodes[node.name].pressureplate_basename
|
local basename = minetest.registered_nodes[node.name].pressureplate_basename
|
||||||
|
|
||||||
@ -17,7 +17,6 @@ local function pp_on_timer(pos, elapsed)
|
|||||||
if not basename then return end
|
if not basename then return end
|
||||||
|
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 1)
|
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||||
local two_below = vector.add(pos, vector.new(0, -2, 0))
|
|
||||||
|
|
||||||
if objs[1] == nil and node.name == basename .. "_on" then
|
if objs[1] == nil and node.name == basename .. "_on" then
|
||||||
minetest.set_node(pos, {name = basename .. "_off"})
|
minetest.set_node(pos, {name = basename .. "_off"})
|
||||||
@ -46,7 +45,6 @@ end
|
|||||||
-- sounds: sound table
|
-- sounds: sound table
|
||||||
|
|
||||||
function mesecon.register_pressure_plate(basename, description, textures_off, textures_on, image_w, image_i, recipe, groups, sounds)
|
function mesecon.register_pressure_plate(basename, description, textures_off, textures_on, image_w, image_i, recipe, groups, sounds)
|
||||||
local groups_off, groups_on
|
|
||||||
if not groups then
|
if not groups then
|
||||||
groups = {}
|
groups = {}
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_pressureplates
|
name = mesecons_pressureplates
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -59,7 +59,7 @@ minetest.register_node("mesecons_random:ghoststone_active", {
|
|||||||
}},
|
}},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
-- remove shadow
|
-- remove shadow
|
||||||
shadowpos = vector.add(pos, vector.new(0, 1, 0))
|
local shadowpos = vector.add(pos, vector.new(0, 1, 0))
|
||||||
if (minetest.get_node(shadowpos).name == "air") then
|
if (minetest.get_node(shadowpos).name == "air") then
|
||||||
minetest.dig_node(shadowpos)
|
minetest.dig_node(shadowpos)
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_random
|
name = mesecons_random
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_receiver
|
name = mesecons_receiver
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_solarpanel
|
name = mesecons_solarpanel
|
||||||
depends = mesecons, mesecons_materials
|
depends = default, mesecons, mesecons_materials
|
||||||
|
@ -8,7 +8,7 @@ minetest.register_node("mesecons_stickyblocks:sticky_block_all", {
|
|||||||
tiles = {"mesecons_stickyblocks_sticky.png"},
|
tiles = {"mesecons_stickyblocks_sticky.png"},
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {choppy=3, oddly_breakable_by_hand=2},
|
groups = {choppy=3, oddly_breakable_by_hand=2},
|
||||||
mvps_sticky = function (pos, node)
|
mvps_sticky = function (pos)
|
||||||
local connected = {}
|
local connected = {}
|
||||||
for _, r in ipairs(mesecon.rules.alldirs) do
|
for _, r in ipairs(mesecon.rules.alldirs) do
|
||||||
table.insert(connected, vector.add(pos, r))
|
table.insert(connected, vector.add(pos, r))
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_stickyblocks
|
name = mesecons_stickyblocks
|
||||||
depends = mesecons, mesecons_mvps
|
depends = default, mesecons, mesecons_mvps
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_switch
|
name = mesecons_switch
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -27,9 +27,13 @@ local torch_get_output_rules = function(node)
|
|||||||
return rotate_torch_rules(rules, node.param2)
|
return rotate_torch_rules(rules, node.param2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local torch_input_rules_unrotated_horizontal = {vector.new(-2, 0, 0), vector.new(-1, 1, 0)}
|
||||||
|
local torch_input_rules_unrotated_vertical = {vector.new(-2, 0, 0)}
|
||||||
|
|
||||||
local torch_get_input_rules = function(node)
|
local torch_get_input_rules = function(node)
|
||||||
local rules = {{x = -2, y = 0, z = 0},
|
local rules = (node.param2 == 0 or node.param2 == 1)
|
||||||
{x = -1, y = 1, z = 0}}
|
and torch_input_rules_unrotated_vertical
|
||||||
|
or torch_input_rules_unrotated_horizontal
|
||||||
|
|
||||||
return rotate_torch_rules(rules, node.param2)
|
return rotate_torch_rules(rules, node.param2)
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_torch
|
name = mesecons_torch
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_walllever
|
name = mesecons_walllever
|
||||||
depends = mesecons, mesecons_receiver
|
depends = default, mesecons, mesecons_receiver
|
||||||
|
@ -14,7 +14,7 @@ local wire_getconnect = function (from_pos, self_pos)
|
|||||||
if minetest.registered_nodes[node.name]
|
if minetest.registered_nodes[node.name]
|
||||||
and minetest.registered_nodes[node.name].mesecons then
|
and minetest.registered_nodes[node.name].mesecons then
|
||||||
-- rules of node to possibly connect to
|
-- rules of node to possibly connect to
|
||||||
local rules = {}
|
local rules
|
||||||
if (minetest.registered_nodes[node.name].mesecon_wire) then
|
if (minetest.registered_nodes[node.name].mesecon_wire) then
|
||||||
rules = mesecon.rules.default
|
rules = mesecon.rules.default
|
||||||
else
|
else
|
||||||
@ -73,7 +73,7 @@ local update_on_place_dig = function (pos, node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Update nodes around it
|
-- Update nodes around it
|
||||||
local rules = {}
|
local rules
|
||||||
if minetest.registered_nodes[node.name]
|
if minetest.registered_nodes[node.name]
|
||||||
and minetest.registered_nodes[node.name].mesecon_wire then
|
and minetest.registered_nodes[node.name].mesecon_wire then
|
||||||
rules = mesecon.rules.default
|
rules = mesecon.rules.default
|
||||||
@ -195,10 +195,11 @@ local function register_wires()
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
local groups_on = {dig_immediate = 3, mesecon_conductor_craftable = 1,
|
local groups_on = {dig_immediate = 3, mesecon_conductor_craftable = 1,
|
||||||
not_in_creative_inventory = 1}
|
not_in_creative_inventory = 1, not_in_craft_guide = 1}
|
||||||
local groups_off = {dig_immediate = 3, mesecon_conductor_craftable = 1}
|
local groups_off = {dig_immediate = 3, mesecon_conductor_craftable = 1}
|
||||||
if nodeid ~= "00000000" then
|
if nodeid ~= "00000000" then
|
||||||
groups_off["not_in_creative_inventory"] = 1
|
groups_off["not_in_creative_inventory"] = 1
|
||||||
|
groups_off["not_in_craft_guide"] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.register_node(":mesecons:wire_"..nodeid, {
|
mesecon.register_node(":mesecons:wire_"..nodeid, {
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
name = mesecons_wires
|
name = mesecons_wires
|
||||||
depends = mesecons
|
depends = default, mesecons
|
||||||
|
Reference in New Issue
Block a user