ID:162738
 
Out of Curiosity is it possible to make new turfs and place them in a location with a line of code, or can this only be done with mobs and objs? I've tried several ways to attempt to make new turfs, but they all just fail to do anything or come up with a runtime error.
One thing is if I wanted my player to use a spell to surround himself in a lake of water. Now water in most cases is a turf, and cannot be walked upon in games, unless its a Naruto game, but if I decide to make the water created an object, the exit and enter procs do not return the same results even though coded the exact same, and making the density = 1 would go against my purposes, because I want it possible to drown instead of not being able to walk upon the water at all.

Any suggestions, or need me to rephrase this? It was a bit confusing I suppose.
[edit] I just realized I forgot that areas can have density, too. I've fixed that.

Turfs can only be created to immediately replace turfs that already exist. In addition, deleted turfs are simply replaced with a turf of the base type, /turf, so you can never have more or fewer turfs than you started with. Because of the destructive property of creating new turfs, you generally don't want to do that.

As for what you want to do... you'll want to create new procs for objs that work similarly to Enter(), Exit(), Entered(), and Exited() (note that these procs all already exist for objs, but they are used only when something moves into an obj's contents). We'll call them StepOn(), StepOff(), SteppedOn(), and SteppedOff(). They are not too complicated to define:

atom
movable
proc
//analogous to Enter()
StepOn(atom/movable/A)
//always allow an object to step on itself
if(A == src) return 1
//do not allow two dense objects in the same turf
else return !(density & A.density)
//analogous to Exit()
StepOff(atom/movable/A)
//always allow stepping off of something by default
return 1
//analogous to Entered()
SteppedOn(atom/movable/A)
//analogous to Exited()
SteppedOff(atom/movable/A)

turf
Enter(atom/movable/A)
//don't allow dense movables onto dense turfs
if((density | loc.density) & A.density) return 0
else
//check contents of this turf for something else that will block A
for(var/atom/movable/M in src)
if(!M.StepOn(A))
return 0

return 1
Exit(atom/movable/A)
//check for something that will prevent A exiting src
for(var/atom/movable/M in src)
if(!M.StepOff(A))
return 0

return 1

Entered(atom/movable/A)
//perform the default action
..()
//call SteppedOn() for everything in contents
for(var/atom/movable/M in src)
M.SteppedOn(A)

Exited(atom/movable/A)
..()
for(var/atom/movable/M in src)
M.SteppedOff(A)


Now, you can give new definitions of StepOn(), StepOff(), SteppedOn(), and SteppedOff() for anything you may need it for, such as a water obj.
In response to Garthor
Ah I see, thanks this helps quite a lot.