ID:176200
 
In my game i kinda have a verb that makes a mob then puts it where the barracks are...but for some reaon if they is two barracks or more it creates one for each barrack. How could i edit this code so it only get created in one of the barracks location not both:

                    for(var/mob/units/buildings/Barracks/M in world)
if(M.owner == src)
var/mob/units/soldiers/Digger/T = new(M.loc)
T:owner = usr
T:team = usr.team


Thanks!
-Crio
Koolguy900095 wrote:
In my game i kinda have a verb that makes a mob then puts it where the barracks are...but for some reaon if they is two barracks or more it creates one for each barrack. How could i edit this code so it only get created in one of the barracks location not both:

                    for(var/mob/units/buildings/Barracks/M in world)
> if(M.owner == src)
> var/mob/units/soldiers/Digger/T = new(M.loc)
> T:owner = usr
> T:team = usr.team

Thanks!
-Crio

Try putting a break right below T:team = user.team. Another thing, I'm pretty sure that you should use '.' in this case, not colon.

~>Volte
In response to Volte
works alright for me...why change it?
In response to Koolguy900095
Koolguy900095 wrote:
works alright for me...why change it?

Stability and compatability reasons, mostly. (I think.)

~>Volte
From looking at just that bit of code, it looks like you're using usr in a case where src should be used. Replace usr with src in that snippet, unless you have a good reason for using usr that I don't know about. =)

T:owner = usr
T:team = usr.team

Argh! Use the . operator, not the : operator! You should always use . unless you have a good reason not to.

In answer to your actual question, put the <code>break</code> command after the <code>T.team = src.team</code> line.
In response to Volte
k, any ideas of how i can make this only goto one barracks and not multiple?
In response to Crispy
You looked at my post and stole my text! I'm telling Dantom! :]

~>Volte
In response to Koolguy900095
I just hate it when I miss three posts while typing my own post ([link]). =P
In response to Volte
I gave him a more comprehensive answer. =P
In response to Crispy
i changed all the :'s to .'s and the code works with the break, thanks!