1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 06:11:47 +02:00
Conflicts:
	mods/mesecons/mesecons/internal.lua
	mods/mesecons/mesecons/services.lua
	mods/mesecons/mesecons/util.lua
	mods/mesecons/mesecons_gates/init.lua
	mods/mesecons/mesecons_luacontroller/init.lua
	mods/mesecons/mesecons_movestones/init.lua
	mods/mesecons/mesecons_mvps/init.lua
	mods/mesecons/mesecons_pistons/init.lua
This commit is contained in:
LeMagnesium
2014-11-29 18:56:39 +01:00
230 changed files with 6746 additions and 136 deletions

View File

@ -240,10 +240,14 @@ function mesecon.changesignal(pos, node, rulename, newstate, depth)
return
end
<<<<<<< HEAD
-- Include "change" in overwritecheck so that it cannot be overwritten
-- by "active" / "deactivate" that will be called upon the node at the same time.
local overwritecheck = {"change", rulename}
mesecon.queue:add_action(pos, "change", {rulename, newstate}, nil, overwritecheck, 1 / depth)
=======
mesecon.queue:add_action(pos, "change", {rulename, newstate}, nil, rulename, 1 / depth)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
-- Conductors
@ -517,7 +521,14 @@ function mesecon.rules_link(output, input, dug_outputrules) --output/input are p
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
-- Check if input accepts from output
if mesecon.cmpPos(mesecon.addPosRule(input, inputrule), output) then
<<<<<<< HEAD
return true, inputrule
=======
if inputrule.sx == nil or outputrule.sx == nil
or mesecon.cmpSpecial(inputrule, outputrule) then
return true, inputrule
end
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
end
end
@ -537,7 +548,14 @@ function mesecon.rules_link_rule_all(output, rule)
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
-- Check if input accepts from output
if mesecon.cmpPos(mesecon.addPosRule(input, inputrule), output) then
<<<<<<< HEAD
table.insert(rules, inputrule)
=======
if inputrule.sx == nil or rule.sx == nil
or mesecon.cmpSpecial(inputrule, rule) then
table.insert(rules, inputrule)
end
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
end
return rules
@ -555,7 +573,14 @@ function mesecon.rules_link_rule_all_inverted(input, rule)
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
if mesecon.cmpPos(mesecon.addPosRule(output, outputrule), input) then
<<<<<<< HEAD
table.insert(rules, mesecon.invertRule(outputrule))
=======
if outputrule.sx == nil or rule.sx == nil
or mesecon.cmpSpecial(outputrule, rule) then
table.insert(rules, mesecon.invertRule(outputrule))
end
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
end
return rules
@ -592,7 +617,11 @@ function mesecon.is_powered(pos, rule)
local nn = minetest.get_node(np)
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
or mesecon.is_receptor_on (nn.name)) then
<<<<<<< HEAD
table.insert(sourcepos, np)
=======
sourcepos.insert(np)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
end
end

View File

@ -27,6 +27,7 @@ mesecon.on_placenode = function (pos, node)
-- Effectors: Send changesignal and activate or deactivate
if mesecon.is_effector(node.name) then
<<<<<<< HEAD
local powered_rules = {}
local unpowered_rules = {}
@ -48,6 +49,14 @@ mesecon.on_placenode = function (pos, node)
for _, r in ipairs(unpowered_rules) do
mesecon.deactivate(pos, node, r, 1)
end
=======
if mesecon.is_powered(pos) then
mesecon.changesignal(pos, node, mesecon.effector_get_rules(node), "on", 1)
mesecon.activate(pos, node, nil, 1)
else
mesecon.changesignal(pos, node, mesecon.effector_get_rules(node), "off", 1)
mesecon.deactivate(pos, node, nil, 1)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
end
end

View File

@ -62,7 +62,11 @@ function mesecon.rule2bit(findrule, allrules)
end
for m,metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do
<<<<<<< HEAD
if mesecon.cmpPos(findrule, rule) then
=======
if mesecon.cmpPos(findrule, rule) and mesecon.cmpSpecial(findrule, rule) then
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
return m
end
end
@ -82,7 +86,11 @@ function mesecon.rule2metaindex(findrule, allrules)
for m, metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do
<<<<<<< HEAD
if mesecon.cmpPos(findrule, rule) then
=======
if mesecon.cmpPos(findrule, rule) and mesecon.cmpSpecial(findrule, rule) then
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
return m
end
end
@ -153,7 +161,11 @@ function mesecon.set_bit(binary,bit,value)
end
function mesecon.invertRule(r)
<<<<<<< HEAD
return {x = -r.x, y = -r.y, z = -r.z}
=======
return {x = -r.x, y = -r.y, z = -r.z, sx = r.sx, sy = r.sy, sz = r.sz}
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
function mesecon.addPosRule(p, r)
@ -164,6 +176,13 @@ function mesecon.cmpPos(p1, p2)
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
end
<<<<<<< HEAD
=======
function mesecon.cmpSpecial(r1, r2)
return (r1.sx == r2.sx and r1.sy == r2.sy and r1.sz == r2.sz)
end
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
function mesecon.tablecopy(table) -- deep table copy
if type(table) ~= "table" then return table end -- no need to copy
local newtable = {}

View File

@ -39,8 +39,31 @@ local function set_gate(pos, node, state)
end
end
<<<<<<< HEAD
local function update_gate(pos, node, link, newstate)
local gate = minetest.registered_nodes[node.name]
=======
function set_gate(pos, on)
gate = get_gate(pos)
local meta = minetest.get_meta(pos)
if on ~= gate_state(pos) then
if mesecon.do_overheat(pos) then
pop_gate(pos)
else
local node = minetest.get_node(pos)
if on then
minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_on", param2=node.param2})
mesecon.receptor_on(pos,
gate_get_output_rules(node))
else
minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_off", param2=node.param2})
mesecon.receptor_off(pos,
gate_get_output_rules(node))
end
end
end
end
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
if gate.inputnumber == 1 then
set_gate(pos, node, gate.assess(newstate == "on"))
@ -54,6 +77,7 @@ local function update_gate(pos, node, link, newstate)
end
end
<<<<<<< HEAD
function register_gate(name, inputnumber, assess, recipe)
local get_inputrules = inputnumber == 2 and gate_get_input_rules_twoinputs or
gate_get_input_rules_oneinput
@ -100,6 +124,15 @@ function register_gate(name, inputnumber, assess, recipe)
})
minetest.register_craft({output = basename.."_off", recipe = recipe})
=======
function pop_gate(pos)
gate = get_gate(pos)
minetest.remove_node(pos)
minetest.after(0.2, function (pos)
mesecon.receptor_off(pos, mesecon.rules.flat)
end , pos) -- wait for pending parsings
minetest.add_item(pos, "mesecons_gates:"..gate.."_off")
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
register_gate("diode", 1, function (input) return input end,

View File

@ -82,9 +82,15 @@ local function get_real_port_states(pos)
local meta = minetest.get_meta(pos)
local L = {}
local n = meta:get_int("real_portstates") - 1
<<<<<<< HEAD
for _, name in ipairs(port_names) do
L[name] = ((n % 2) == 1)
n = math.floor(n / 2)
=======
for _, index in ipairs({"a", "b", "c", "d"}) do
L[index] = ((n%2) == 1)
n = math.floor(n/2)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
return L
end
@ -99,7 +105,11 @@ local function merge_port_states(ports, vports)
}
end
<<<<<<< HEAD
local function generate_name(ports)
=======
local generate_name = function (ports)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
local d = ports.d and 1 or 0
local c = ports.c and 1 or 0
local b = ports.b and 1 or 0
@ -169,6 +179,7 @@ local function overheat_off(pos)
end
<<<<<<< HEAD
local function overheat(pos, meta)
if mesecon.do_overheat(pos) then -- If too hot
local node = minetest.get_node(pos)
@ -178,6 +189,10 @@ local function overheat(pos, meta)
minetest.after(0.2, overheat_off, pos)
return true
end
=======
local overheat_off = function(pos)
mesecon.receptor_off(pos, mesecon.rules.flat)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
------------------------
@ -224,9 +239,24 @@ local function remove_functions(x)
return x
end
<<<<<<< HEAD
local function get_interrupt(pos)
-- iid = interrupt id
local function interrupt(time, iid)
=======
local safe_serialize = function(value)
return minetest.serialize(deep_copy(value))
end
mesecon.queue:add_function("lc_interrupt", function (pos, luac_id, iid)
-- There is no luacontroller anymore / it has been reprogrammed / replaced
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
lc_update(pos, {type="interrupt", iid = iid})
end)
local getinterrupt = function(pos)
local interrupt = function (time, iid) -- iid = interrupt id
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
if type(time) ~= "number" then return end
local luac_id = minetest.get_meta(pos):get_int("luac_id")
mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1)
@ -252,6 +282,7 @@ local safe_globals = {
local function create_environment(pos, mem, event)
-- Gather variables for the environment
local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
<<<<<<< HEAD
local vports_copy = {}
for k, v in pairs(vports) do vports_copy[k] = v end
local rports = get_real_port_states(pos)
@ -323,6 +354,76 @@ local function create_environment(pos, mem, event)
difftime = os.difftime,
time = os.time,
},
=======
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
local rports = get_real_portstates(pos)
return {
print = safe_print,
pin = merge_portstates(vports, rports),
port = vports,
interrupt = getinterrupt(pos),
digiline_send = getdigiline_send(pos),
mem = mem,
tostring = tostring,
tonumber = tonumber,
heat = minetest.get_meta(pos):get_int("heat"),
-- overheat_max Unit: actions per second, checks are every 1 second
heat_max = mesecon.setting("overheat_max", 20),
string = {
byte = string.byte,
char = string.char,
find = string.find,
format = string.format,
gmatch = string.gmatch,
gsub = string.gsub,
len = string.len,
lower = string.lower,
upper = string.upper,
match = string.match,
rep = string.rep,
reverse = string.reverse,
sub = string.sub,
},
math = {
abs = math.abs,
acos = math.acos,
asin = math.asin,
atan = math.atan,
atan2 = math.atan2,
ceil = math.ceil,
cos = math.cos,
cosh = math.cosh,
deg = math.deg,
exp = math.exp,
floor = math.floor,
fmod = math.fmod,
frexp = math.frexp,
huge = math.huge,
ldexp = math.ldexp,
log = math.log,
log10 = math.log10,
max = math.max,
min = math.min,
modf = math.modf,
pi = math.pi,
pow = math.pow,
rad = math.rad,
random = math.random,
sin = math.sin,
sinh = math.sinh,
sqrt = math.sqrt,
tan = math.tan,
tanh = math.tanh,
},
table = {
insert = table.insert,
maxn = table.maxn,
remove = table.remove,
sort = table.sort
},
event = event,
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
}
env._G = env
@ -361,7 +462,11 @@ local function create_sandbox(code, env)
return nil, "Binary code prohibited."
end
local f, msg = loadstring(code)
<<<<<<< HEAD
if not f then return nil, msg end
=======
if not f then return _, msg end
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
setfenv(f, env)
return function(...)
@ -403,10 +508,17 @@ local function run(pos, event)
-- Create environment
local env = create_environment(pos, mem, event)
<<<<<<< HEAD
-- Create the sandbox and execute code
local f, msg = create_sandbox(code, env)
if not f then return msg end
local success, msg = pcall(f)
=======
-- create the sandbox and execute code
local chunk, msg = create_sandbox (code, env)
if not chunk then return msg end
local success, msg = pcall(chunk)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
if not success then return msg end
if type(env.port) ~= "table" then
return "Ports set are invalid."
@ -550,6 +662,7 @@ for d = 0, 1 do
"jeija_microcontroller_sides.png",
"jeija_microcontroller_sides.png"
},
<<<<<<< HEAD
inventory_image = top,
paramtype = "light",
groups = groups,
@ -576,6 +689,41 @@ for d = 0, 1 do
end,
is_luacontroller = true,
})
=======
inventory_image = top,
paramtype = "light",
groups = groups,
drop = BASENAME.."0000",
sunlight_propagates = true,
selection_box = selectionbox,
node_box = nodebox,
on_construct = reset_meta,
on_receive_fields = function(pos, formname, fields)
if not fields.program then
return
end
reset(pos)
reset_meta(pos, fields.code)
local err = lc_update(pos, {type="program"})
if err then
print(err)
reset_meta(pos, fields.code, err)
end
end,
sounds = default.node_sound_stone_defaults(),
mesecons = mesecons,
digiline = digiline,
virtual_portstates = { a = a == 1, -- virtual portstates are
b = b == 1, -- the ports the the
c = c == 1, -- controller powers itself
d = d == 1},-- so those that light up
after_dig_node = function (pos, node)
mesecon.receptor_off(pos, output_rules)
end,
is_luacontroller = true,
})
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
end
end
end

View File

@ -67,7 +67,11 @@ minetest.register_node("mesecons_movestones:movestone", {
local direction=mesecon.get_movestone_direction(pos)
if not direction then return end
minetest.remove_node(pos)
<<<<<<< HEAD
mesecon.on_dignode(pos, node)
=======
mesecon.update_autoconnect(pos)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
minetest.add_entity(pos, "mesecons_movestones:movestone_entity")
end
}}
@ -151,7 +155,11 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
local direction=mesecon.get_movestone_direction(pos)
if not direction then return end
minetest.remove_node(pos)
<<<<<<< HEAD
mesecon.on_dignode(pos, node)
=======
mesecon.update_autoconnect(pos)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
minetest.add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
end
}}
@ -188,8 +196,12 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
if name ~= "air" and name ~= "ignore"
and ((not minetest.registered_nodes[name])
or minetest.registered_nodes[name].liquidtype == "none") then
<<<<<<< HEAD
mesecon.mvps_push(pos, self.lastdir,
mesecon.setting("movestone_max_push", 50))
=======
mesecon.mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
--STICKY
mesecon.mvps_pull_all(pos, self.lastdir)
end
@ -201,7 +213,11 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
end
local success, stack, oldstack =
<<<<<<< HEAD
mesecon.mvps_push(pos, direction, mesecon.setting("movestone_max_push", 50))
=======
mesecon.mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
if not success then -- Too large stack/stopper in the way
local nn = {name="mesecons_movestones:sticky_movestone"}
minetest.add_node(pos, nn)

View File

@ -94,7 +94,11 @@ function mesecon.mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- add nodes
for _, n in ipairs(nodes) do
<<<<<<< HEAD
local np = mesecon.addPosRule(n.pos, dir)
=======
np = mesecon.addPosRule(n.pos, dir)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
minetest.add_node(np, n.node)
minetest.get_meta(np):from_table(n.meta)
end
@ -123,8 +127,13 @@ mesecon.register_on_mvps_move(function(moved_nodes)
end)
function mesecon.mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons)
<<<<<<< HEAD
local np = mesecon.addPosRule(pos, dir)
local nn = minetest.get_node(np)
=======
np = mesecon.addPosRule(pos, dir)
nn = minetest.get_node(np)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
if ((not minetest.registered_nodes[nn.name]) --unregistered node
or minetest.registered_nodes[nn.name].liquidtype == "none") --non-liquid node

View File

@ -55,8 +55,13 @@ piston_get_direction = function(dir, node)
end
local piston_remove_pusher = function(pos, node)
<<<<<<< HEAD
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
local dir = piston_get_direction(pistonspec.dir, node)
=======
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
dir = piston_get_direction(pistonspec.dir, node)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
local pusherpos = mesecon.addPosRule(pos, dir)
local pushername = minetest.get_node(pusherpos).name
@ -100,9 +105,15 @@ local piston_off = function(pos, node)
piston_remove_pusher(pos, node)
if pistonspec.sticky then
<<<<<<< HEAD
local dir = piston_get_direction(pistonspec.dir, node)
local pullpos = mesecon.addPosRule(pos, dir)
local stack = mesecon.mvps_pull_single(pullpos, dir)
=======
dir = piston_get_direction(pistonspec.dir, node)
pullpos = mesecon.addPosRule(pos, dir)
stack = mesecon.mvps_pull_single(pullpos, dir)
>>>>>>> b86fd8cfa9dadcc359b95cdc1135488beae0f467
mesecon.mvps_process_stack(pos, dir, stack)
end
end