ID:2203708
 
(See the best response by Nadrew.)

Problem description:Not really a problem, just trying to figure out how to do the title. A guiding hand would be enough. Thanks in advance. Here's a little more detail:

1.A player having the ability to create a new map (choosing the size as well) and that map being saved into his world for as long as he has the files.

2.A player having the ability to create items (objs) and being able to edit its variables. (This item will also save to the hosts server.)

3.And lastly, mobs. Same thing as above.



So, as an example, I want to be able to host my server, create a map with an obj on the floor, and a mob in the room. I want those three things to still exist when I shut down the server and reopen it.
Best response
You'd save them like anything else, BYOND's savefiles handle saving all datums the same way, by saving an exact copy of it, including any non-tmp variables that have changed from the initial value. The main thing that doesn't save is location, which is usually handled by the developer manually (this prevents the mob from accidentally saving the location it's standing on).

So for your objects, you'd probably want to keep track of a list of objects that are created on a specific map, saving that list will save every object within it, variables and all.

Creating a new map is as simple as adding to world.maxz -- but keep in mind that the map will always be as large as the largest map in your game. If you alter world.maxx and world.maxy to accomodate maps larger than ones that already exist, the existing ones would be enlarged to match.

So you'd want to account for that.

Once you have the map created, and the system you use to create objects is storing them in a list specific to that map, you just have to save it.

var/savefile/my_save = new("my_map.sav")
my_save["objects"] << my_list_of_objects


Now, this isn't going to save the location of the objects, you'll need to do that yourself.

obj
saved_objects
Write(savefile/F)
if(!isturf(loc)) return ..()
..()
F["saved_x"] << x
F["saved_y"] << y
F["saved_z"] << z
Read(savefile/F)
// I'll let you figure this part out as a challenge to yourself


Not really much to it, just be careful with the variables you create, make very, very sure anything that's being set to a reference to another object (especially mobs) is tmp or you're going to end up saving a lot more than you bargained for, leading to all sorts of headaches like phantom objects, rollbacks, and file corruption.