Rewrite Logic Gates: Makes it super-easy to add new gates and cleans up code

Fix bugs in the Luacontroller (when placing, false input pin values were given) and fix variables
leaking into the global environment in pistons.
This commit is contained in:
Jeija
2014-11-29 15:08:37 +01:00
parent d2373eb605
commit c326dc221a
6 changed files with 156 additions and 285 deletions

View File

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