ID:1952541
 
Code:



mob
icon='stone.dmi'


obj/Stone
icon = 'stone.dmi'



mob/verb/Stone()
var/obj/Stone/first = new (src.loc)
sleep 5
walk(first, EAST)
sleep 5
walk(first, SOUTH)
sleep 5
walk(first, WEST)
sleep 5
walk(first, NORTH)
var/obj/Stone/second = new (src.loc)
sleep 5
walk(second, EAST)
sleep 5
walk(second, SOUTH)
sleep 5
walk(second, WEST)
sleep 5
walk(second, NORTH)
sleep 5</b>


Problem description:This is working code but i was wondering how i could make the second stone spawn where the first is at on the map.Ive tried many ways and all i end up with is a bunch of errors and run time errors.Any suggestions would be great

To spawn the second one where the first one currently is:

// first.loc is used here, rather than src.loc.
var/obj/Stone/second = new (first.loc)
Pretty sure the code you're using is terrible practice and should be a procedure. But someone else could probably explain better for you. This would be if you wanted it to spawn where the first was created. Or LordAndrew's method of where it currently is.

var/second_loc = first.loc //this would go below the first stone after you create it.
var/obj/Stone/second = new (second_loc)


thank you so much guys i tried a few combinations like that but i put src.first.loc and it didn't work but this way should work out really well thank you a ton! im gonna try both methods
one more question before i go is it possible to do something like this var/obj/Stone/second = new (first.loc.src.usr.blah.blah) i mean is it possible to add more in there or is it 2 commands per ()
In response to Hishio
new() arguments calls to the source's New() proc.
one more question how would i do multiple spawns on the same location like 5-10 more can i add a number to increase the amount?
In response to Hishio
That would be a for() loop.
for(var/n in 1 to 10)
// this code is repeated 10 times
new blah (loc)
thank you so much :D!
In response to Kaiochao
Kaiochao wrote:
That would be a for() loop.
> for(var/n in 1 to 10)
> // this code is repeated 10 times
> new blah (loc)
>


i tried
for(var/obj/Stone/first 1 in 10)

and it didn't work at all
In response to Hishio
n is the variable that goes from 1 to 10 depending on which repetition you're currently in.
for(var/n in 1 to 10)
world << n