ID:266313
 
I only want mobs to be repopulated back on my map but objs are also put back, how do I stop this from happening? Here's what I have now;

world
New()
for(var/mob/M in world)
spawn(M)
while(1)
sleep(10)
Repop()
return..()

What can I do to fix this? Thank you.
Philipe The Bard wrote:
I only want mobs to be repopulated back on my map but objs are also put back, how do I stop this from happening? Here's what I have now;

world
New()
for(var/mob/M in world)
spawn(M)
while(1)
sleep(10)
Repop()
return..()

What can I do to fix this? Thank you.

try world.repop()
In response to Air _King
I still have the same problem.
In response to Philipe The Bard
Try making a proc called Regen_mobs(). What you would have this proc do is check for all the mobs in the world. For each mob you'd have it delete itself and spawn a new one of it's type.

Then you call it when you want to regenerate mobs.
In response to Evilkevkev
Sorry I don't understand what you mean. I was just wondering how I could make the repop proc I showed before check to see if what it's repopulating is a monster, if so, then put it back, if not, then just dont do anything, Here's what I got;

world
New(mob/M as mob)
if(M.Type == "monster")
spawn(M)
while(1)
sleep(10)
Repop()
return..()
else
..()

But with this I just end up with a HUGE runtime error.
In response to Philipe The Bard
If you look at world.Repop(), it states that it repopulates everything, including objs. So, you're not going to want to use Repop() here.
What was the problem with the answer I gave you at [link] when you asked this before?
In response to Shadowdarke
It doesnt work, I must be doing something wrong. I retyped it in and didn't get any errors or warnings, then when I ran it the monster was deleted and never came back. What do I have to do that Im missing? Thank you.
In response to Philipe The Bard
This probably won't work, but I'll give it a shot:
datum
proc
Regen_Mobs(mob/M in world)
if(!M.client)
del(M)
spawn(M)

If this works, it should, when called: cycle through each mob in the game and, if the mob isn't assigned to a client, delete it, then re-spawn it.

[EDIT]
I just thought of something. The above code will only work if a mob is selected. This means that it will display a menu asking to choose a mob that exists in the world.
try this:
datum
proc
Regen_Mobs()
for(var/mob/M in world)
if(!M.client)
del(M)
spawn(M)

Now that I think about it, I'm not sure this will regenerate any mobs that have already been deleted, such as if they have been killed.
In response to Evilkevkev
I put it in, and then I got this error;

Repop.dm:1:error::invalid expression

In response to Philipe The Bard
What line is that in? Don't forget to re-read that post, I edited it.
In response to Evilkevkev
That other example you posted came up w/ the same error. I don't know which line it is, because whenever I double click on it, it takes me to a different code folder and highlights something that's not even related to this.
In response to Evilkevkev
datum
> proc
> Regen_Mobs()
> for(var/mob/M in world)
> if(!M.client)
> del(M)
> spawn(M)


spawn() isn't doing what you're thinking, here. Spawn() is like a sleep().

You're gonna wanna look at Shadowdarke's post, [link].

The code does work.
In response to Philipe The Bard
I finally got around to testing that snippet. It works fine for me. Are you certain that RepopMob() is a global proc in your code? If you make it a mob proc, it won't work.

To make it a global proc, the proc declaration must be flush with the left margin, no indentation.
In response to Philipe The Bard
you could do it the dumb way and just add each mob to a list when they die, then have a function called every once in awhile to go through the list (store the location data for the dead mobs too) and create new instances of them
In response to Shadowdarke
I still can't get it, I have no idea what I'm doin wrong. I even opened a new environment just to see if something else within that my other codes was messin' it up. I made it a global var, or tried to make it a global var, and got this error;

Testing.dm:7:error: beginning_location: expected end of statement

I'm sorry that I'm having so much trouble with this.

[Edit]

Okay, instead of making it global, I just left it as mob, and it worked fine in "Testing", but when I try to put it in the game I want it in, it doesnt repop anything at all. What could be causing this problem? Thank you.
In response to Philipe The Bard
Philipe The Bard wrote:
I still can't get it, I have no idea what I'm doin wrong. I even opened a new environment just to see if something else within that my other codes was messin' it up. I made it a global var, or tried to make it a global var, and got this error;


No, all of it should be under mob, except the RepopMob() proc, which must be global for the example code to work. If you use the same indentation I used in the example, it should work. (You'll probably need to retab it, since the forums turn tabs into spaces.)


Okay, instead of making it global, I just left it as mob, and it worked fine in "Testing", but when I try to put it in the game I want it in, it doesnt repop anything at all. What could be causing this problem? Thank you.

In order for that snippet to work, mobs must be created in a specific location when new() is called. This automatically happens for mobs placed on the map. If you are doing it from the code, it has to be created with a statement like:
new/mob/mobtypepath(Location)

How are you placing mobs in your game?
In response to Shadowdarke
How are you placing mobs in your game?

I just go to the map editor and open the tree, and just place them on the map through there.