more fixes and added globals
This commit is contained in:
parent
537e756091
commit
619b977bb3
|
@ -20,7 +20,8 @@ read_globals = {
|
|||
"DIR_DELIM",
|
||||
|
||||
-- deps
|
||||
"default", "screwdriver"
|
||||
"default", "screwdriver",
|
||||
"digiline", "doors"
|
||||
}
|
||||
|
||||
ignore = {
|
||||
|
|
|
@ -520,8 +520,8 @@ function mesecon.is_powered(pos, rule)
|
|||
local sourcepos = {}
|
||||
|
||||
if not rule then
|
||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
||||
for _, rule_entry in ipairs(mesecon.flattenrules(rules)) do
|
||||
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule_entry)
|
||||
for _, rname in ipairs(rulenames) do
|
||||
local np = vector.add(pos, rname)
|
||||
local nn = mesecon.get_node_force(np)
|
||||
|
|
|
@ -332,13 +332,16 @@ local function vm_get_or_create_entry(pos)
|
|||
return tbl
|
||||
end
|
||||
|
||||
-- ignore content id
|
||||
local c_ignore = minetest.get_content_id("ignore")
|
||||
|
||||
-- Gets the node at a given position during a VoxelManipulator-based
|
||||
-- transaction.
|
||||
function mesecon.vm_get_node(pos)
|
||||
local tbl = vm_get_or_create_entry(pos)
|
||||
local index = tbl.va:indexp(pos)
|
||||
local node_value = tbl.data[index]
|
||||
if node_value == core.CONTENT_IGNORE then
|
||||
if node_value == c_ignore then
|
||||
return nil
|
||||
else
|
||||
local node_param1 = tbl.param1[index]
|
||||
|
|
|
@ -142,11 +142,11 @@ local function commandblock_action_on(pos, node)
|
|||
|
||||
local commands = resolve_commands(meta:get_string("commands"), pos)
|
||||
for _, command in pairs(commands:split("\n")) do
|
||||
local pos = command:find(" ")
|
||||
local space_pos = command:find(" ")
|
||||
local cmd, param = command, ""
|
||||
if pos then
|
||||
cmd = command:sub(1, pos - 1)
|
||||
param = command:sub(pos + 1)
|
||||
if space_pos then
|
||||
cmd = command:sub(1, space_pos - 1)
|
||||
param = command:sub(space_pos + 1)
|
||||
end
|
||||
local cmddef = minetest.chatcommands[cmd]
|
||||
if not cmddef then
|
||||
|
|
|
@ -24,13 +24,13 @@ end
|
|||
|
||||
-- (de)serialize
|
||||
lg.serialize = function(t)
|
||||
local function _op(t)
|
||||
if t == nil then
|
||||
local function _op(_t)
|
||||
if _t == nil then
|
||||
return " "
|
||||
elseif t.type == "io" then
|
||||
return t.port
|
||||
else -- t.type == "reg"
|
||||
return tostring(t.n)
|
||||
elseif _t.type == "io" then
|
||||
return _t.port
|
||||
else -- _t.type == "reg"
|
||||
return tostring(_t.n)
|
||||
end
|
||||
end
|
||||
-- Serialize actions (gates) from eg. "and" to "&"
|
||||
|
@ -97,11 +97,11 @@ end
|
|||
|
||||
-- validation
|
||||
lg.validate_single = function(t, i)
|
||||
local function is_reg_written_to(t, n, max)
|
||||
for i = 1, max-1 do
|
||||
if next(t[i]) ~= nil
|
||||
and t[i].dst and t[i].dst.type == "reg"
|
||||
and t[i].dst.n == n then
|
||||
local function is_reg_written_to(_t, n, max)
|
||||
for j = 1, max-1 do
|
||||
if next(_t[j]) ~= nil
|
||||
and _t[j].dst and _t[j].dst.type == "reg"
|
||||
and _t[j].dst.n == n then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -187,11 +187,11 @@ lg.interpret = function(t, a, b, c, d)
|
|||
end
|
||||
return false -- unknown gate
|
||||
end
|
||||
local function _op(t, regs, io_in)
|
||||
if t.type == "reg" then
|
||||
return regs[t.n]
|
||||
else -- t.type == "io"
|
||||
return io_in[t.port]
|
||||
local function _op(_t, regs, io_in)
|
||||
if _t.type == "reg" then
|
||||
return regs[_t.n]
|
||||
else -- _t.type == "io"
|
||||
return io_in[_t.port]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -231,8 +231,8 @@ local function safe_string_find(...)
|
|||
return string.find(...)
|
||||
end
|
||||
|
||||
local function remove_functions(x)
|
||||
local tp = type(x)
|
||||
local function remove_functions(obj)
|
||||
local tp = type(obj)
|
||||
if tp == "function" then
|
||||
return nil
|
||||
end
|
||||
|
@ -261,9 +261,9 @@ local function remove_functions(x)
|
|||
end
|
||||
end
|
||||
|
||||
rfuncs(x)
|
||||
rfuncs(obj)
|
||||
|
||||
return x
|
||||
return obj
|
||||
end
|
||||
|
||||
-- The setting affects API so is not intended to be changeable at runtime
|
||||
|
@ -582,7 +582,7 @@ local function run_inner(pos, code, event)
|
|||
|
||||
-- Load code & mem from meta
|
||||
local mem = load_memory(meta)
|
||||
local code = meta:get_string("code")
|
||||
code = meta:get_string("code")
|
||||
|
||||
-- 'Last warning' label.
|
||||
local warning = ""
|
||||
|
@ -602,7 +602,8 @@ local function run_inner(pos, code, event)
|
|||
-- If a string sandbox is already up yet inconsistent, something is very wrong
|
||||
assert(onetruestring.__index == string)
|
||||
onetruestring.__index = env.string
|
||||
local success, msg = pcall(f)
|
||||
local success
|
||||
success, msg = pcall(f)
|
||||
onetruestring.__index = string
|
||||
-- End string true sandboxing
|
||||
if not success then return false, msg end
|
||||
|
@ -901,4 +902,3 @@ minetest.register_craft({
|
|||
{'group:mesecon_conductor_craftable', 'group:mesecon_conductor_craftable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -188,9 +188,9 @@ yc.update = function(pos)
|
|||
|
||||
if (mesecon.do_overheat(pos)) then
|
||||
minetest.remove_node(pos)
|
||||
minetest.after(0.2, function (pos)
|
||||
minetest.after(0.2, function()
|
||||
mesecon.receptor_off(pos, mesecon.rules.flat)
|
||||
end , pos) -- wait for pending parsings
|
||||
end) -- wait for pending parsings
|
||||
minetest.add_item(pos, "mesecons_microcontroller:microcontroller0000")
|
||||
end
|
||||
|
||||
|
@ -251,9 +251,9 @@ yc.parsecode = function(code, pos)
|
|||
if not params then return nil end
|
||||
end
|
||||
if command == "on" then
|
||||
L = yc.command_on (params, Lvirtual)
|
||||
yc.command_on (params, Lvirtual)
|
||||
elseif command == "off" then
|
||||
L = yc.command_off(params, Lvirtual)
|
||||
yc.command_off(params, Lvirtual)
|
||||
elseif command == "print" then
|
||||
local su = yc.command_print(params, eeprom, yc.merge_portstates(Lreal, Lvirtual))
|
||||
if su ~= true then return nil end
|
||||
|
|
Loading…
Reference in New Issue