ID:156747
 
I was wondering if it was possible to create a turf, let's say 'water', that soon after it's made will be removed and the old turf that was in it's spot is recreated.

I currently have-

        Move()
for(var/turf/T in get_step(src,src.dir))
var/turf/Water3/D=new(src.loc)
D.oldturf=T
..()


to look for the turfs

and-

        New()
spawn(30)
new oldturf(src.loc)

to recreate the old turf to replace the water. The current variable I'm using to store the turf is-
var/oldturf=null


None of this seems to be working.. any ideas?
Instead of

new oldturf(src.loc)


You want

new oldturf(src)


In the context of a turf, 'src.loc' means the /area it's inhabiting, so you're actually creating the turf in the bottom-left-most place of the area.
In response to Unknown Person
Alright thanks. I'm not getting errors anymore but the water isn't being created as the wave moves so I'm assuming get_step isn't fighting turfs or something? I'm not sure but here's the code I'm using for the wave.
        Move()
for(var/turf/T in get_step(src,src.dir))
var/turf/Water3/D=new(src.loc)
D.oldturf=T
..()
..()
In response to AbdelJN
You're looping through turfs in what get_step() returns. get_step() returns a turf (or false if none was found). As there are never any turfs inside of a turf, the body of your for() loop never runs.

The solution is to think carefully when programming and consider what each function does (by reading its reference entry if you haven't memorized that yet), then write your code accordingly, instead of automatically sticking in a loop for no reason.

Also,
-You have ..() in a loop. Bad. Rarely, if you'll ever encounter such a case, it would do you anything but harm to call it more than once.
-I doubt you actually need that object var on your turfs. Try to use a local one in a proc.
-When you let the parent or default function run again, you should preserve its return value if it has any meaningful one. Move() does, so you need to do something like return ..() if you let it run at the end of the proc, instead of just ..() alone which discards the returned value. If you let the parent proc run before the end of the proc then you can use something like . = ..() instead (. is a built-in var, look it up and use the forum search for more info).