ID:1840827
 
(See the best response by Lummox JR.)
Is there a way to delete a z-level off the map. Let's say I have 11 z-levels on my map, and my 11th level is blank space in which I copy to make many more z-levels like
maps.copy(11)


After awhile I end up with like 40+ z-levels and I want it so after there are no more players on a z>11 it dissappears.
You can only remove the last z-level by using --world.maxz

There's no way to delete z-levels any other way.
In response to Superbike32
Best response
Not exactly correct--you can set world.maxz to any value, so you can delete a bunch of levels at once. But they do all have to be at the "top".

If you have players logging in and using new Z levels, and want to free those when the players log out, keep track of which ones are unused. If at any time the top Z-level is unused, you can remove it from the world map. (Or, you can reduce churn by waiting for multiple levels at the top to go unused, or wait some long period of time between updates. Removing Z levels will trigger a search for references to any of the old turfs, so it's best to minimize how often you do this.)
In response to Lummox JR
That's basically what I meant is that it has to be the last z-level/at the "top" to delete it.

There's currently no way to delete other z-levels even though I think it'd technically be feasible to build a way, even though I don't think it'd really be used outside of people that may use something like swapmaps or another lib to load areas on demand.

Personally I just put everybody at the same place literally and use image() to display the stuff to the needed people. Since this is usually only used for battles Final Fantasy style. (by me at least)

***Message to original poster.
If you have a similar use case, you may think about doing the same thing and using image() to display what's needed to the user such as enemy icons and you'd have to use it to display yourself/players in the party too.
Is it possible to move or copy maps?

For example, copy the contents of z-15 to z-12, Then delete z-15?

Alternatively, If you have no other way, You can check if there are any players on the lowest map, and move upwards until it finds an empty map beneath maxz, then use that one instead of creating a new one, then when maxz is no longer populated, destroy it. This should prevent more z levels being created if there are empty z-levels, and destroy all the empty ones at the top as soon as possible.
In response to Superbike32
Superbike32 wrote:
That's basically what I meant is that it has to be the last z-level/at the "top" to delete it.

There's currently no way to delete other z-levels even though I think it'd technically be feasible to build a way, even though I don't think it'd really be used outside of people that may use something like swapmaps or another lib to load areas on demand.

Personally I just put everybody at the same place literally and use image() to display the stuff to the needed people. Since this is usually only used for battles Final Fantasy style. (by me at least)

***Message to original poster.
If you have a similar use case, you may think about doing the same thing and using image() to display what's needed to the user such as enemy icons and you'd have to use it to display yourself/players in the party too.

I
have the last z-level(11) with small areas for story missions and whenever a player initiates story it creates an instance by copying z=11 onto a new z-level for the player to play on.

Problem:

I couldn't use just one z because multiple story scenarios and cutscenes would be happening at once if 2 players or more start story and that's chaotic.
I can't remove the top layer because lots of people do story at the same time and I would end up deleting a player.

Solution:

I want it so I could maybe get rid of the z-levels that are finished being used or maybe even reuse them(deleting all story mobs on that map before initiating the story of course)
In response to Critical172
I would have to know how it works specifically to know if it's feasible to use image() even for the story, using image() is built to show things to one player and not another, which would include AI, etc...so one player could be in a cut-scene that involves AI walking around, etc... and the other player on the same z-level wont see the other player or the other AI for example.

Copying the z-level and making lots of z-levels isn't a very good solution because you get to all the limits much quicker, and it takes a lot more resources to create/delete/move z-levels around.

Re-using z-levels is easy though, you just have to keep track of all created z-levels and the player(s) on each one, if only one player is allowed on each a simple occupied/not occupied is enough.

Creating lots of z-levels though if your game ever becomes popular you'll likely fairly quickly run into issues, but less so if you use the image() approach as you probably wont be creating too much as the story other than cut-scenes should be mostly static(as in the same/identical) for everybody that goes through it.
thats what i was suggesting, reuse lower unpopulated z-levels, or recreate them if possible. If there are no unpopulated ones, create a new one at the top. As soon as the top z-level is unpopulated, delete it and all unpopulated z-levels beneath it.

For a check to see if its populated, couldnt you just do something like "for client in world.z" or something?
In response to Nullbear
The simplest method is to loop through all clients in the world, and look for whether they're on the level and if they're still using it (which may be separate questions--for instance if they have a custom house you probably want to leave it loaded).

One thing that has not been discussed is sharing Z-levels. Typically the world map will be fairly large, but an individual customizable section may be smaller. (This also comes up if you have a temporary battle arena space, as in a JRPG.) SwapMaps is built to handle this approach, though you may want to roll your own.

The huge advantage of sharing Z-levels is that they grow much slower. The world map is always a cuboid structure, so if you only use part of a Z-level a lot of space goes wasted. If your maps are all 200x200 and players only need 20x20 of customizable space--including a border to separate their regions, so they'd actually get 19x19--you can host 100 players per new level, which means you'll probably only ever need one or two.