ID:160891
 
This is what not working on BYOND for a year or so does to one.

I feel stupid asking this question, but I need to create turfs at a specific location, how would I do it?
I tried
new /turf/floor (rx,ry,rz) but it doesn't work because I get a bad loc runtime.

It's been a while since I've done any major BYOND stuff, so I feel like the answer is sitting in my brain and I just don't know what it is. Any help would be great.

~Polantaris
You need to use the existing turf at that spot in order to let DM know where you want to create the new turf. At that point, the old turf is seemingly replaced with the new one.
Remember: a location == an atom. Numbers/coordinates are not a location, but you can call the locate() proc to get an atom (turf) at those coordinates.
In response to Kaioken
Two things about that though:
1) Theres technically no turf already there (besides the base turf of just /turf)
2) I'm replacing every single turf on the map (I'm creating a random dungeon generator).
How would I refer to that specific spot in the most efficient way?
In response to Polantaris
Polantaris wrote:
1) Theres technically no turf already there (besides the base turf of just /turf)

Which is a turf, so how can you say there is technically no turf? Really. =P
Anyway, it makes no difference.

2) I'm replacing every single turf on the map (I'm creating a random dungeon generator).
How would I refer to that specific spot in the most efficient way?

This is kind of a problem, because I don't think there is a way to create a turf at a specific point other than "replacing" a turf that is already there*.

<small>*: Technically speaking there is one more way - increasing the world.maxX,Y,Z vars, which if you increase by 1, will create 1 turf of the type of world/turf at that specific spot, with the exception of Z which will create X*Y turfs, of course.</small>
In response to Polantaris
He told you efficiently enough. Use locate() if you're using coordinates.

Also, putting a new turf there will replace the one before it, since there can only be one turf on any place on the map.
In response to Naokohiro
Wasn't reading it correctly the first time, my bad.
I've tried that just now, but I may not be doing it correctly (I've never really used locate() in this manner)
    BasicFill(rz)
for(var/rx = 1;rx < world.maxx;rx++)
for(var/ry = 1;ry < world.maxy;ry++)
var/turf/t = locate(rx,ry,rz)
if(rx == 1||ry == 1||rx == world.maxx||ry == world.maxy)
t = new /turf/permawall
else
t = new /turf/floor
world << "[t] spawned."

I still get a bad loc runtime.

Am I using it incorrectly?
In response to Polantaris
Polantaris wrote:
I still get a bad loc runtime.

Am I using it incorrectly?

You are now not supplying an argument for the loc at all. If you are rusty on DM, you should use the documentation even more. Look up 'new()' in the Reference (I also suggest reading the DM Guide) - the loc argument is supposed to be the first argument in the parentheses, if any. Since you've used the syntax with no parentheses, you are supplying no arguments.

Also, variables' defined type has almost no purpose outside of the compiler's error checking. It does not effect the variable's value or any other function at all (except in special instructions where it can be used as a shortcut or those that specifically use it such as for()) - so both of these blocks of code are the same (and wrong):
var/turf/t = whatever
t = new /turf/permawall
var/t = whatever
t = new /turf/permawall
In response to Polantaris
No need for your var/turf/t. Turfs must have their loc set in their new proc, which is what is giving you that error.
e.g.
new/turf/permawall(locate(rx,ry,rz))
In response to Kaioken
Ah now it's working for me. Thanks, I can't believe I'm this rusty, but thanks again.