I have a Lua script that looks for a village within a specific coordinate range. When found, it returns the coordinates of the village, just like how the "Village along the way from A to B" example script does it.
However, if I then try to search for something else, like biomes or structures, and set the relative location to the Lua script, instead of the search being centered on the village found from the script, it will always revert to 0, 0.
So how do I properly set the relative location of another condition through a Lua script? The return value doesn't seem to work, but I could be missing something.
Code:
-- Look for a village located between the first two dependent conditions
function check(seed, at, deps)
local x1, z1, x2, z2 = -220, 82, -700, 102
vils = getStructures(Village, x1, z1, x2, z2)
if vils == nil then return nil end
for i = 1, #vils do
-- calculate the square distance to the line a -> b
local dx, dz = x2 - x1, z2 - z1
local d = dx * (vils[i].z - z1) - dz * (vils[i].x - x1)
d = (d * d) / (dx * dx + dz * dz + 1)
if d < 8*8 then -- village intersecting the line
if getBiomeAt(vils[i].x, vils[i].z) == plains then
return vils[i].x, vils[i].z
end
end
end
return nil
end
I have a Lua script that looks for a village within a specific coordinate range. When found, it returns the coordinates of the village, just like how the "Village along the way from A to B" example script does it.
However, if I then try to search for something else, like biomes or structures, and set the relative location to the Lua script, instead of the search being centered on the village found from the script, it will always revert to 0, 0.
So how do I properly set the relative location of another condition through a Lua script? The return value doesn't seem to work, but I could be missing something.
Code: