proc
RandPlace(NameT,Num)
var/X = rand(1,world.maxx)
var/Y = rand(1,world.maxy)
for(var/i = 0, i != (Num + 1), ++i)
X = rand(1,world.maxx)
Y = rand(1,world.maxy)
new NameT(locate(X,Y,1))
This code works though I want it so that the objects dont get created at the location of others like traps not getting created on walls. I have tried using a number of for commands but none of them worked. Could someone help me.
Just check if something is already in the way before placing the object :P.
Though only use this method if there are a lot of locations the object can be place otherwise it may be really slow or even lock up. If you only have a few possible locations it can be geneated at you may want to just store a list of these locations and use pick to select one. You might also have to write your own Enter() proc for the turf atom to disallow these objects to enter if they can.