for(var/mob/human/x in oview(10))
if(x.name==src.owner)
step_to(src, x,1)
sleep(5)
goto loop
This is suppost to be a proc for an OBJ to follow its owner but this doesn't work
ID:264913
Mar 28 2011, 3:19 pm
|
|
Code:
for(var/mob/human/x in oview(10)) This is suppost to be a proc for an OBJ to follow its owner but this doesn't work |
In response to Garthor
|
|
Yes thank you it is working but after, i tried to change the new location and it doesn't follow anymore
mob/verb asd() var/obj/follower/R = new/obj/follower if(src.dir==NORTH) R.loc = locate(usr.x+4,usr.y,usr.z) if(src.dir==SOUTH) R.loc = locate(usr.x+4,usr.y,usr.z) if(src.dir==EAST) R.loc = locate(usr.x+4,usr.y,usr.z) if(src.dir==WEST) R.loc = locate(usr.x+4,usr.y,usr.z) im guessing there is a problem with this |
In response to Millennium Earl
|
|
You did not create it properly. See my example.
|
In response to Garthor
|
|
I already seen your example but it seems that it is too advanced for me.
Currently im using a proc for a /mob that pulls the obj/follower instead of the obj/follower to follow the mob when it is made. mob/proc asdasd() var/i=4 for(var/obj/follower/T in oview(10)) if(T.owner==src.name) while(i) step_to(T,src,1) sleep(5) i-- del(T) Right now, whenever i make the follower 4 tiles away, it automatically executes this proc which works fine but i want to understand yours properly. Could you explain a little more? I dont quite understand how yours work |
In response to Millennium Earl
|
|
Ok, i tried to make a proc for the /obj/follower again
obj/follower proc followowner() var/i=4 while(i) step_to(src,src.owner,1) sleep(2) i-- del(src) theicon icon='dfsfiojd.dmi' New() ..() spawn() src.followowner() mob/verb makefollower() var/obj/follower/theicon/T = new/obj/follower/theicon T.loc=locate(usr.x,usr.y+4,usr.z) T.owner=usr.name but it still doesn't follow Can you please or someone else help me? |
In response to Millennium Earl
|
|
Ok nevermind! After so many experiments, i finally got it!!
|
In response to Millennium Earl
|
|
If you check your similar post on the Developer How-To forum, I posted a solution for you.
|
Second, never use goto for any reason. while(), for(), and do while() are the proper structures to use for looping.
Third, you do not need to loop through mobs in range. Instead, you should just store a reference to the mob you're following, and follow them. Like so: