ID:139675
 
Code:
obj
hud
SkillTree
screen_loc = "1,1"
icon_state = "SkillTree"
mouse_drop_zone=0
Click()
if(usr.Skill_Tree)
for(var/I in usr.client.images) if(I)
del I
usr.client.eye = usr
usr.Skill_Tree = 0
usr.AddHUD2()
usr.RemoveHUDRemoval()
usr.Frozen=0
return
usr.RemoveHUD()
usr.AddHUDRemove()
usr.Frozen=1
usr<<output("Your view has changed, but you are still in the same spot.","Out")
usr.Skill_Tree = 1
usr.client.eye = locate (7,7,2)
usr.Refresh_Skilltree()


Problem description:

My code problem? The only real problem is that this works 80% of the time. When it's clicked, the person's view is sent directly to the skill tree. However, there's a certain part of my map where you click this hud button and your view goes nowhere. Literally, I'll be standing on one tile, click it, and I'll see the tree. I walk one tile to the east, and I click it again, and all I get is black
The client's viewing perspective is still from his mob, so when you center his eye on something else, anything outside of his mob's sight will not be visible. To avoid this, when changing the eye, you need to change the perspective to EYE_PERSPECTIVE as well.

                    for(var/I in usr.client.images) if(I)
del I


The if() is not needed in this case, as images can only contain /image objects. Also, you can likely achieve the same effect with a mere usr.client.images.Cut() or an equivalent (emptying the list), as the image objects will likely then be garbage collected.
In response to Kaioken
Thank you so much Kaioken! I was worried that it was going to be such a complicated solution.