Skip to content

Instantly share code, notes, and snippets.

@rubenwardy
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenwardy/4543de8adef215f97ba0 to your computer and use it in GitHub Desktop.
Save rubenwardy/4543de8adef215f97ba0 to your computer and use it in GitHub Desktop.
Quick allocation for Utopia
local x = 0
local z = 0
local c = 0
while (1) do
c = c + 1
if (c > 1000) then
local id = nil
if plot then id = plot.id end
if id == nil then id = "<unknown-id>" end
print("[UTOPIA] Error allocating plot "..id..", maximum looping reached in quick_allocate()")
uto.suggest_full_alloc = true
return false
end
print("("..x..", "..z..")")
if (uto.plot_from_cell(section.x + x,section.z + z)==nil) then
break
end
if z == 0 and x > 0 then
z = x + 1
x = 0
elseif z==0 and x == 0 then
x = 0
z = z + 1
elseif x >= z then
z = z - 1
else
x = x + 1
end
end
plot.alloc = {x,z,x,z}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment