-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,34 @@ | ||
local function getNorth(window) | ||
return window.getNorth and window:getNorth() or window:isNorthHoppable() | ||
end | ||
|
||
local function getOppositeSquare(window, x, y, z) | ||
return getNorth(window) and getSquare(x, y - 1, z) or getSquare(x - 1, y, z) | ||
end | ||
return { | ||
getDropSquare = function(player, window) | ||
|
||
local function getDropSquare(player, window) | ||
local sq1, sq2, selected | ||
|
||
local dropSquare, floorSquare, oppositeSquare | ||
local playerSquare = player:getSquare() | ||
local px, py, pz = playerSquare:getX(), playerSquare:getY(), playerSquare:getZ() | ||
|
||
local playerSquare = player:getSquare() | ||
local windowSquare = window:getSquare() | ||
local x, y, z = windowSquare:getX(), windowSquare:getY(), windowSquare:getZ() | ||
local oppositeSquare = getOppositeSquare(window, x, y, z) | ||
local windowSquare = window:getSquare() | ||
local wx, wy, wz = windowSquare:getX(), windowSquare:getY(), windowSquare:getZ() | ||
|
||
if getNorth(window) then | ||
dropSquare = getSquare(x, y + 1, z) | ||
else | ||
dropSquare = getSquare(x + 1, y, z) | ||
end | ||
|
||
local dropSquare = playerSquare:equals(windowSquare) and oppositeSquare or dropSquare | ||
if window.getNorth and window:getNorth() or window:isNorthHoppable() then | ||
sq1 = getSquare(wx, wy + 1, wz) | ||
sq2 = getSquare(wx, wy - 1, wz) | ||
selected = (py >= wy) and sq2 or sq1 | ||
else | ||
sq1 = getSquare(wx + 1, wy, wz) | ||
sq2 = getSquare(wx - 1, wy, wz) | ||
selected = (px >= wx) and sq2 or sq1 | ||
end | ||
|
||
x = dropSquare:getX() | ||
y = dropSquare:getY() | ||
x = selected:getX() | ||
y = selected:getY() | ||
|
||
for z = dropSquare:getZ(), 0, -1 do | ||
floorSquare = getSquare(x, y, z) | ||
if floorSquare:isSolidFloor() then | ||
return floorSquare | ||
for z = selected:getZ(), 0, -1 do | ||
local floorSquare = getSquare(x, y, z) | ||
if floorSquare:isSolidFloor() then | ||
return floorSquare | ||
end | ||
end | ||
end | ||
|
||
error('This should never happen!') | ||
end | ||
|
||
return { | ||
getDropSquare = getDropSquare, | ||
error('This should never happen!') | ||
end | ||
} |