ID:159255
 
Hey. I've got one problem:
How to create a turf or area in defined location without using a map? Cause when I use normal loc=locate it says that it cannot change a const value.
Turfs and areas can't be moved; their location is static (and therefore their loc is a constant value), and so it is assigned at the moment of their creation and remains the same forever <small>(until the object is deleted)</small>. Only types of /atom/movable may move (this means only objs or mobs). When creating atom objects, the first argument in the new() call is the location in which to create them in.

To create turfs, you must specify such a location in the argument. It should be another, existing turf, which the new turf you're creating should replace. That way DM knows where to put the new turf.

Areas are a little more complicated. They work differently: every single area instance can span across multiple, many many tiles (which don't have to be near each other). Note that when you lay areas through the Map Editor, it only ever lays a single area of each type you use. So even if you laid down 10 "areas" on several tiles, the result is really only one area, which includes all those tiles in it (and its contents).
Now on to how to create areas. Using new area_type(Turf) will have the following effect: if there is already an instance (an object in existence) of that 'area_type', then the Turf used will be added to that existing area <small>(so this doesn't really create a new area)</small>. If there wasn't an existing area of this specific type, then [a new] one will be created and the turf will be added to it.
If you want to create a new area instance of a type that one area of already exists, you specify null (or nothing, which is the same) as the location argument in the new() call. This always creates a new area instance. Then you can keep a reference to it, and manage it like any other area; for example, you can include/add turfs to it by adding them to its contents list.

Further reading: new(), area See also: room