mob/Login()
..()
src.loc=locate(100,100,1)
src.invisibility = 1
src.client.StartHotkeys()
for(var/mob/Walkingmobforlogin/M in world)
client.eye = M
mob/Walkingmobforlogin
New()
..()
sleep(1)
spawn(10)if(!key)RandWalk(0.1)
proc/RandWalk(Delay)
for()
sleep(Delay)
step_rand(src)
Problem description:
Hi! I'm trying to do something cool in login screen like some invisibility mobs walking around the map for show a bit of the game but im having some erros.
After some time I get black screen using the code this way(like in 10 seconds?) I tried to check what could be causing but nothing uses eye.
How I can pick "Walkingmobforlogin" randomly also?
It defaults to MOB_PERSPECTIVE. This affects what is in range of your mob's viewport.
As for picking your eyes:
for in world pattern... Bad. The sooner you break this habit the better your code is going to be. Read Snippet Sunday #6
http://www.byond.com/forum/?post=1810538
For in world literally has to look at everything in the memory of your game just to find a specific set of objects you might already have laying around.
Notice we're storing wandercam in a global list. If you need data later, best practice is to hang on to it somewhere you can access it later. In this case, our only real choice is in the global scope.
Now for swapping cameras every ten seconds:
And now let's drop in your initial code, modified to do what you want.
One other point:
This isn't technically wrong. It's best practice to avoid an unconditional infinite loop though. This can cause problems for you when shutting down a world. Every "infinte loop" in your code needs a termination condition at the very least. You risk running into problems down the line if you don't do this.