ID:178881
 
How would you represent all mobs in the game in a proc?
like in the code in the DM Guide
proc/timer()
world << "Tick"
spawn(300)
timer()
how would you have that code check for mobs in the world?
Mexus wrote:
How would you represent all mobs in the game in a proc?
like in the code in the DM Guide
proc/timer()
world << "Tick"
spawn(300)
timer()
how would you have that code check for mobs in the world?

proc/timer()
for(var/mob/M in world)
world << M
spawn(300)
timer()
In response to Skysaw
thanks
In response to Skysaw
Skysaw wrote:
Mexus wrote:
How would you represent all mobs in the game in a proc?
like in the code in the DM Guide
proc/timer()
world << "Tick"
spawn(300)
timer()
how would you have that code check for mobs in the world?

proc/timer()
for(var/mob/M in world)
world << M
spawn(300)
timer()

Actually a more efficent way would be not looking through the world.contents each time but to assemble a list to use all the time like so:

list/Mobs
mob/New()
Mobs += src
mob/Del()
Mobs -= src
proc/timer()
for(var/mob/M in Mobs)
world << M
spawn(300)
timer()

This will look through just the mobs instead of going through the entire world list saving some processing time cuting down on some lag in the long run.
In response to Darkness
Darkness wrote:
Skysaw wrote:
Mexus wrote:
How would you represent all mobs in the game in a proc?
like in the code in the DM Guide
proc/timer()
world << "Tick"
spawn(300)
timer()
how would you have that code check for mobs in the world?

proc/timer()
for(var/mob/M in world)
world << M
spawn(300)
timer()

Actually a more efficent way would be not looking through the world.contents each time but to assemble a list to use all the time like so:

list/Mobs
mob/New()
Mobs += src
mob/Del()
Mobs -= src
proc/timer()
for(var/mob/M in Mobs)
world << M
spawn(300)
timer()

This will look through just the mobs instead of going through the entire world list saving some processing time cuting down on some lag in the long run.

Not knowing the nature of his game, I can only give the most general solution. If it's a single-player game with only 10 mobs in it, it's completely unnecessary, for example.

I'm also not sure he's prepared to understand your code, or why it makes sense.