Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function modifyportalwalls(portalnumber, i, newx, newy, side)
- print(portalnumber, portals[portalnumber])
- --Create and remove new stuff
- if side == "up" then
- objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx-1, newy-1, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx-1, newy, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx, newy, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx+1, newy-1, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx-1, newy-1, 0, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx+1, newy-1, 0, 0, true)
- modifyportaltiles(newx, newy, 1, 0, portals[portalnumber], i, "remove")
- elseif side == "down" then
- objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx-2, newy-1, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx-1, newy-1, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx-2, newy-1, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx, newy-1, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx-2, newy, 0, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx, newy, 0, 0, true)
- modifyportaltiles(newx, newy, -1, 0, portals[portalnumber], i, "remove")
- elseif side == "left" then
- objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx, newy-2, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx, newy-1, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx-1, newy-2, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx-1, newy, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx-1, newy, 0, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx-1, newy-2, 0, 0, true)
- modifyportaltiles(newx, newy, 0, -1, portals[portalnumber], i, "remove")
- elseif side == "right" then
- objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx-1, newy-1, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx-1, newy, 0, 1, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx-1, newy-1, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx-1, newy+1, 1, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx, newy-1, 0, 0, true)
- objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx, newy+1, 0, 0, true)
- modifyportaltiles(newx, newy, 0, 1, portals[portalnumber], i, "remove")
- end
- --remove conflicting portalwalls (only exist when both portals exists!)
- for a, b in pairs(portals) do
- for c, d in pairs(portals) do
- if b.x ~= d.x or b.y ~= d.y or b.facing ~= d.facing then
- for j = 1, 2 do
- if v.x1 and v.x2 then
- local otherj = 1
- if j == 1 then
- otherj = 2
- end
- local conside, conx, cony = v["facing" .. j], v["x" .. j], v["y" .. j]
- for k = 1, 4 do
- local w = objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k]
- if w then
- if conside == "right" then
- if w.x == conx and w.y == cony-1 and w.height == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx and w.y == cony and w.height == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx-1 and w.y == cony and w.width == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- elseif conside == "left" then
- if w.x == conx-1 and w.y == cony-2 and w.height == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx-1 and w.y == cony-1 and w.height == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx-1 and w.y == cony-1 and w.width == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- elseif conside == "up" then
- if w.x == conx-1 and w.y == cony-1 and w.width == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx and w.y == cony-1 and w.width == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx and w.y == cony-1 and w.height == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- else
- if w.x == conx-2 and w.y == cony and w.width == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx-1 and w.y == cony and w.width == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- if w.x == conx-1 and w.y == cony-1 and w.height == 1 then
- objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement