ID:157892
 
What would be the best simple way to go about a target arrow just pointing at an atom on the map, so you can easily follow it, while the arrow stays ontop of your character?

proc
Target_Arrow(mob/a,atom/b)
if(!a||!b)
world << "INSUFFICIENT DATA FOR TARGET ARROW"
return
var/obj/target_arrow = new/obj/target_arrow(a.overlays)
while(!a.target_reached)
sleep(5)
target_arrow.dir = get_dir(a,b)
del target_arrow
Speedro wrote:
>       var/obj/target_arrow = new/obj/target_arrow(a.overlays)


A list is not a location - only atoms are. So normally, giving that argument won't accomplish anything.

Also, you only need to update the arrow when the player's location changes (i.e., when he moves), not periodically.

Note however that you can't modify an existing overlay. When you add some data representing an appearance to overlays, it's not added intact to that list; it's converted into a static snapshot of that appearance in an internal format (called an Appearance object). So once you add an object to overlays, modifying that object won't affect the overlay in any way, since it's separate from it. In fact, normally, overlays += /obj and overlays += new /obj have the same effect.
So to "update" an overlay, you need to replace it with a new one.
Use image? Check it out here
In response to Kaioken
Cool, I have done just that.

Does this look as efficient as it could be? Also, when I delete the arrow, will it remove it from the "movement_action" list I created?

atom
proc
movement_action(mob/m)

mob
Move()
..()
for(var/atom/x in action_list)
x.movement_action(src)


obj
target_arrow
layer = MOB_LAYER + 1
icon = 'other.dmi'
icon_state = "arrow"
var/atom/target

New(mob/a,atom/b)
world << a
world << b
..()
target = b
a.action_list += src
while(!a.target_reached)
sleep(5)
del src
movement_action(mob/m)
loc = m.loc
dir = get_dir(m,target)