ID:151523
 
I am having issues with thee logic in this. What I am trying to do is to have the map Z level increase so that people can "create a house" there. But, I want to be able to put a system in check so that when I am going to create a house, I could somehow check all Z levels to see if there was a "free one" first that would be from a player logging out who had created their "home". I am using the SwapMaps library.

mob/var
assigned_house_x = 50
assigned_house_y = 50
assigned_house_z
person
mob/verb/set_name()
person = input("Enter your name")

var/tmp/list/Housing
mob
verb
SaveChunk()
if(!loc)
usr << "You must be on the map."
return
//var/_x=round(input("x size:","New map: x size",world.maxx) as num,1)
var/_x = usr.assigned_house_x
var/_y = usr.assigned_house_y
//var/_y=round(input("y size:","New map: y size",world.maxy) as num,1)
_x=max(1,min(_x,world.maxx-x+1))
_y=max(1,min(_y,world.maxy-y+1))
SwapMaps_SaveChunk("chunk",loc,locate(x+_x-1,y+_y-1,assigned_house_z))
LoadChunk()
if(!loc)
usr << "You must be on the map to save your house."
return
var/list/L=SwapMaps_GetSize("chunk")
if(!L)
usr << "House not found."
return
var/_x=max(1,min(x,world.maxx-L[1]+1))
var/_y=max(1,min(y,world.maxy-L[2]+1))
var/oldloc=loc
usr << "Loading house at [_x],[_y],[assigned_house_z]"
SwapMaps_LoadChunk("chunk",locate(_x,_y,assigned_house_z))
loc=oldloc
proc
Load_My_House()
assigned_house_z = world.maxz + 1
world.maxz++
usr << "<font color = red>[world.maxz]-world.maxz.</font> <font color = blue>[assigned_house_z]-assigned_house_z.</font>"
loc = locate(1,5,assigned_house_z)

Clean_Up_Duty()
Housing.Add("[assigned_house_z]_[person]")
// for(assigned_house_z in Housing)
// if(
// verb
// Lay_Down_Flooring()
// new /obj/floor in loc
proc
Set_Up()
obj/floor
icon = 'turfs.dmi'
icon_state = "floor"

/*

Player loads house.

Z level is added on.

Monster loads house.

Z level is added on.


Z level started at one, but is now 3.

Player logs out.

Z-level 2 is available.





Add Z-level 2 to a list

Check for available Z-levels in list before
players are added on.

Player will join Z-level list before they
are able to join a newly created Z level.

Every 5 minutes, the Z-level list is cleared
of Z-levels which do not contain objects.


*/
SwapMaps automatically will find unused areas to place new map chunks. You just need to use Unload() to remove the areas when a player leaves and it should automatically re-use that z-level (or smaller or larger chunk) when needed.