1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 06:11:47 +02:00

merge server with github

This commit is contained in:
Ombridride
2014-11-29 15:40:55 +01:00
parent 2f89e14839
commit b86fd8cfa9
279 changed files with 7543 additions and 1338 deletions

View File

@ -38,10 +38,6 @@ function lc_update_real_portstates(pos, rulename, newstate)
return
end
local n = meta:get_int("real_portstates") - 1
if n < 0 then
legacy_update_ports(pos)
n = meta:get_int("real_portstates") - 1
end
local L = {}
for i = 1, 4 do
L[i] = n%2
@ -63,9 +59,6 @@ local get_real_portstates = function(pos) -- determine if ports are powered (by
local meta = minetest.get_meta(pos)
local L = {}
local n = meta:get_int("real_portstates") - 1
if n < 0 then
return legacy_update_ports(pos)
end
for _, index in ipairs({"a", "b", "c", "d"}) do
L[index] = ((n%2) == 1)
n = math.floor(n/2)
@ -83,7 +76,6 @@ local merge_portstates = function (ports, vports)
end
local generate_name = function (ports)
local overwrite = overwrite or {}
local d = ports.d and 1 or 0
local c = ports.c and 1 or 0
local b = ports.b and 1 or 0
@ -93,9 +85,9 @@ end
local setport = function (pos, rule, state)
if state then
mesecon:receptor_on(pos, {rule})
mesecon.receptor_on(pos, {rule})
else
mesecon:receptor_off(pos, {rule})
mesecon.receptor_off(pos, {rule})
end
end
@ -123,7 +115,7 @@ end
--------------------
local overheat_off = function(pos)
mesecon:receptor_off(pos, mesecon.rules.flat)
mesecon.receptor_off(pos, mesecon.rules.flat)
end
-------------------
@ -168,7 +160,7 @@ local safe_serialize = function(value)
return minetest.serialize(deep_copy(value))
end
mesecon.queue:add_function("lc_interrupt", function (pos, iid, luac_id)
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})
@ -177,8 +169,8 @@ end)
local getinterrupt = function(pos)
local interrupt = function (time, iid) -- iid = interrupt id
if type(time) ~= "number" then return end
luac_id = minetest.get_meta(pos):get_int("luac_id")
mesecon.queue:add_action(pos, "lc_interrupt", {iid, luac_id}, time, iid, 1)
local luac_id = minetest.get_meta(pos):get_int("luac_id")
mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1)
end
return interrupt
end
@ -209,7 +201,8 @@ local create_environment = function(pos, mem, event)
tostring = tostring,
tonumber = tonumber,
heat = minetest.get_meta(pos):get_int("heat"),
heat_max = OVERHEAT_MAX,
-- 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,
@ -271,7 +264,7 @@ local create_sandbox = function (code, env)
if code:byte(1) == 27 then
return _, "You Hacker You! Don't use binary code!"
end
f, msg = loadstring(code)
local f, msg = loadstring(code)
if not f then return _, msg end
setfenv(f, env)
return f
@ -321,7 +314,7 @@ lc_update = function (pos, event)
-- create the sandbox and execute code
local chunk, msg = create_sandbox (code, env)
if not chunk then return msg end
local success, msg = pcall(f)
local success, msg = pcall(chunk)
if not success then return msg end
if ports_invalid(env.port) then return ports_invalid(env.port) end
@ -477,7 +470,6 @@ minetest.register_node(nodename, {
reset_meta(pos, fields.code, err)
end
end,
on_timer = handle_timer,
sounds = default.node_sound_stone_defaults(),
mesecons = mesecons,
digiline = digiline,
@ -486,7 +478,7 @@ minetest.register_node(nodename, {
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)
mesecon.receptor_off(pos, output_rules)
end,
is_luacontroller = true,
})