Advertisement
Guest User

Untitled

a guest
Jul 26th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.61 KB | None | 0 0
  1. function modifyportalwalls(portalnumber, i, newx, newy, side)
  2.         print(portalnumber, portals[portalnumber])
  3.     --Create and remove new stuff
  4.     if side == "up" then
  5.         objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx-1, newy-1, 0, 1, true)
  6.         objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx-1, newy, 1, 0, true)
  7.         objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx, newy, 1, 0, true)
  8.         objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx+1, newy-1, 0, 1, true)
  9.         objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx-1, newy-1, 0, 0, true)
  10.         objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx+1, newy-1, 0, 0, true)
  11.        
  12.         modifyportaltiles(newx, newy, 1, 0, portals[portalnumber], i, "remove")
  13.     elseif side == "down" then
  14.         objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx-2, newy-1, 1, 0, true)
  15.         objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx-1, newy-1, 1, 0, true)
  16.         objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx-2, newy-1, 0, 1, true)
  17.         objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx, newy-1, 0, 1, true)
  18.         objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx-2, newy, 0, 0, true)
  19.         objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx, newy, 0, 0, true)
  20.        
  21.         modifyportaltiles(newx, newy, -1, 0, portals[portalnumber], i, "remove")
  22.     elseif side == "left" then
  23.         objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx, newy-2, 0, 1, true)
  24.         objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx, newy-1, 0, 1, true)
  25.         objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx-1, newy-2, 1, 0, true)
  26.         objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx-1, newy, 1, 0, true)
  27.         objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx-1, newy, 0, 0, true)
  28.         objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx-1, newy-2, 0, 0, true)
  29.        
  30.         modifyportaltiles(newx, newy, 0, -1, portals[portalnumber], i, "remove")
  31.     elseif side == "right" then
  32.         objects["portalwall"][portalnumber .. "-" .. i .. "-1"] = portalwall:new(newx-1, newy-1, 0, 1, true)
  33.         objects["portalwall"][portalnumber .. "-" .. i .. "-2"] = portalwall:new(newx-1, newy, 0, 1, true)
  34.         objects["portalwall"][portalnumber .. "-" .. i .. "-3"] = portalwall:new(newx-1, newy-1, 1, 0, true)
  35.         objects["portalwall"][portalnumber .. "-" .. i .. "-4"] = portalwall:new(newx-1, newy+1, 1, 0, true)
  36.         objects["portalwall"][portalnumber .. "-" .. i .. "-5"] = portalwall:new(newx, newy-1, 0, 0, true)
  37.         objects["portalwall"][portalnumber .. "-" .. i .. "-6"] = portalwall:new(newx, newy+1, 0, 0, true)
  38.        
  39.         modifyportaltiles(newx, newy, 0, 1, portals[portalnumber], i, "remove")
  40.     end
  41.    
  42.     --remove conflicting portalwalls (only exist when both portals exists!)
  43.     for a, b in pairs(portals) do
  44.         for c, d in pairs(portals) do
  45.             if b.x ~= d.x or b.y ~= d.y or b.facing ~= d.facing then
  46.                 for j = 1, 2 do
  47.                     if v.x1 and v.x2 then
  48.                         local otherj = 1
  49.                         if j == 1 then
  50.                             otherj = 2
  51.                         end
  52.                        
  53.                         local conside, conx, cony = v["facing" .. j], v["x" .. j], v["y" .. j]
  54.                        
  55.                         for k = 1, 4 do
  56.                             local w = objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k]
  57.                             if w then
  58.                                 if conside == "right" then
  59.                                     if w.x == conx and w.y == cony-1 and w.height == 1 then
  60.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  61.                                     end
  62.                                     if w.x == conx and w.y == cony and w.height == 1 then
  63.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  64.                                     end
  65.                                     if w.x == conx-1 and w.y == cony and w.width == 1 then
  66.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  67.                                     end
  68.                                 elseif conside == "left" then
  69.                                     if w.x == conx-1 and w.y == cony-2 and w.height == 1 then
  70.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  71.                                     end
  72.                                     if w.x == conx-1 and w.y == cony-1 and w.height == 1 then
  73.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  74.                                     end
  75.                                     if w.x == conx-1 and w.y == cony-1 and w.width == 1 then
  76.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  77.                                     end
  78.                                 elseif conside == "up" then
  79.                                     if w.x == conx-1 and w.y == cony-1 and w.width == 1 then
  80.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  81.                                     end
  82.                                     if w.x == conx and w.y == cony-1 and w.width == 1 then
  83.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  84.                                     end
  85.                                     if w.x == conx and w.y == cony-1 and w.height == 1 then
  86.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  87.                                     end
  88.                                 else
  89.                                     if w.x == conx-2 and w.y == cony and w.width == 1 then
  90.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  91.                                     end
  92.                                     if w.x == conx-1 and w.y == cony and w.width == 1 then
  93.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  94.                                     end
  95.                                     if w.x == conx-1 and w.y == cony-1 and w.height == 1 then
  96.                                         objects["portalwall"][portalnumber .. "-" .. otherj .. "-" .. k] = nil
  97.                                     end
  98.                                 end
  99.                             end
  100.                         end
  101.                     end
  102.                 end
  103.             end
  104.         end
  105.     end
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement